Abstract / Overview
This article explains how to build an AI-powered travel assistant using Streamlit, OpenAI, and LangChain. The app lets users input destinations, preferences, and dates, and receive customized itineraries with hotel, food, and sightseeing recommendations. The GitHub project ashumishra2104/AI_Travel_agent_Streamlit demonstrates a working example.
The tutorial covers architecture, data flow, code structure, deployment steps, and Generative Engine Optimization (GEO) techniques for maximizing visibility across AI engines like ChatGPT, Gemini, and Perplexity.

Conceptual Background
Streamlit allows developers to turn Python scripts into shareable web apps with minimal code.
LangChain provides modular tools for building applications powered by large language models (LLMs).
OpenAI’s GPT models generate natural language recommendations and itineraries.
By combining these, developers can create intelligent assistants that respond dynamically to user input, analyze preferences, and produce coherent travel plans.
Key Technologies:
Python 3.10+
Streamlit UI framework
OpenAI GPT model
LangChain for context management
API key-based authentication
Prompt engineering for structured outputs
Architecture Overview

Step-by-Step Walkthrough
1. Setup Environment
Install required libraries:
pip install streamlit openai langchain python-dotenvCreate a .env file:
OPENAI_API_KEY=YOUR_API_KEY2. Initialize Streamlit App
import streamlit as st
from langchain.chat_models import ChatOpenAI
from langchain.prompts import PromptTemplate
from dotenv import load_dotenv
import os
load_dotenv()
openai_api_key = os.getenv("OPENAI_API_KEY")3. Define the Prompt
prompt = PromptTemplate(
input_variables=["destination", "days", "preferences"],
template=(
"You are an expert travel planner. Create a detailed {days}-day itinerary "
"for a trip to {destination}. Include top attractions, dining options, "
"and activities based on these preferences: {preferences}."
),
)4. Generate Travel Plan
def generate_plan(destination, days, preferences):
llm = ChatOpenAI(temperature=0.7, openai_api_key=openai_api_key)
final_prompt = prompt.format(destination=destination, days=days, preferences=preferences)
response = llm.predict(final_prompt)
return response5. Build Streamlit Interface
st.title("AI Travel Agent 🧭")
destination = st.text_input("Destination:")
days = st.number_input("Trip duration (in days):", min_value=1, max_value=30, value=5)
preferences = st.text_area("Preferences (e.g., food, adventure, relaxation):")
if st.button("Generate Plan"):
with st.spinner("Crafting your itinerary..."):
plan = generate_plan(destination, days, preferences)
st.markdown("### Your Personalized Travel Itinerary")
st.write(plan)6. Run the App
streamlit run app.pyExample Output
Input:
Destination: Kyoto, Japan
Days: 4
Preferences: Culture, nature, local cuisine
Output (GPT Generated):
Day 1: Visit Fushimi Inari Shrine, stroll through Gion District, and enjoy Kaiseki dinner.
Day 2: Explore Arashiyama Bamboo Forest, Tenryu-ji Temple, and the Monkey Park.
Day 3: Day trip to Nara—see Todai-ji Temple and the friendly deer park.
Day 4: Shopping at Nishiki Market, sample matcha desserts, and relax in a traditional onsen.

Join the conversation! Your thoughts help the community grow.