LLM-powered travel planning assistant that combines OpenAI chat models with multiple SerpApi tools (Google Flights, Google Hotels, Google Maps/Local). The agent reasons about user constraints (budget, luxury, flexible dates, etc.), asks clarifying questions, runs searches concurrently, and returns a well-cited answer. It includes an interactive CLI chat for discovery and planning, plus a Python class for programmatic use.
- Context-aware reasoning about constraints (budget, luxury, season)
- Multi-tool integration via SerpApi (Flights, Hotels, Maps, Web search)
- Chat-based CLI for discovery & exploration
- Footnote-style citations with source links (tools return structured JSON with URLs to support citations)
- JSON trace output for debugging or auditing
- Python 3.9+
- Environment variables:
OPENAI_API_KEY
SERPAPI_API_KEY
git clone https://github.com/your-org/travel-planning-agent
cd travel-planning-agent
pip install -r requirements.txt
Export in your shell (recommended):
export OPENAI_API_KEY="sk-..."
export SERPAPI_API_KEY="..."
Or create a .env
file and source it in your shell before running:
source .env
python travel_planning_agent.py
python travel_planning_agent.py -q "Plan a 5-day luxury trip to Paris in July."
python travel_planning_agent.py -q "Find cheap flights to Tokyo in May" --debug
-q, --query
: Initial travel query (if omitted → chat mode)-m, --model
: Model (default:gpt-4o
, choices:gpt-4o
,gpt-4o-mini
)-n, --topn
: Number of results per search (default: 10)-o, --outfile
: Write full JSON trace to file-d, --debug
: Enable debug logs
- Interprets ambiguous dates as future travel:
- If the current date is past a mentioned month (e.g., today is August and user says "in May"), assume next year's May.
- For vague phrasing like "mid-May", probe multiple nearby dates (e.g., 13–17 May) rather than a single exact day.
- Assumes reasonable defaults when details are missing (and surfaces them):
- Economy cabin, up to 1 stop, 2 adults, flexible +/- 3 days; adjust if tone/budget suggests otherwise.
- Infers defaults based on query tone:
- "Luxury" → business/first flights, 5-star hotels
- "$500 budget" → economy flights, value hotels
- Asks clarifying questions if info missing (dates, origin, budget) and provides multiple options when uncertain
- Outputs a concise, actionable plan with links & footnote-style citations
- Flights tool requires IATA airport codes:
- The
search_flights
tool expects 3-letter IATA codes fordeparture
anddestination
(e.g.,WAW
,HAM
). - The agent should first call
search_web
to find/verify the IATA codes (e.g., search: "Warsaw IATA code", "Hamburg IATA code"), then callsearch_flights
with those codes. - If non-IATA inputs are provided, the tool returns a structured error indicating that IATA codes are required.
- The
- Hotels and Places tools accept free-text destination queries (cities, neighborhoods) as before.
travel-planning-agent/
├─ travel_planning_agent.py # CLI entrypoint + TravelAgent class
├─ requirements.txt
├─ README.md
└─ LICENSE
- Budget trip:
I want a $500 budget trip to Mexico City in November
- Discovery:
I want a summer beach vacation
- Luxury honeymoon:
Plan a luxury honeymoon in Bali in December