Skip to main content

How to build an AI travel agent

Learn how to build an AI travel agent using Python, GPT-5 mini, and MCP. Includes architecture diagram, system prompt logic, and full working code
Author Jake Nulty
Last updated

Travel agents in the real world are responsible for a variety of things. They don’t just sell you plane tickets and hotel reservations. You give them money in exchange for a thought-free vacation. The best ones get everything together for you. All you need to do is buy the ticket and make the journey. In this guide, we’ll build an AI travel agent and you’ll learn the following concepts.

  • Creating an AI agent loop with simple chat-persistent memory.
  • Plugging an AI model into an MCP server.
  • Programming an AI agent via natural language.

What does a AI travel agent actually do?

People think a travel agent’s job is to offer vacations, book trips and plan itineraries. This is true. However, at a broader scope, the agent’s job is to outsource planning. Think of the things you do when planning a vacation.

When you plan a vacation yourself, you’re faced with the following tasks.

  1. Select a location: Perform research and any necessary diligence to decide on a place you’d like.
  2. Evaluate travel and lodging options: Are you flying or driving? Get a solid picture of how much this is going to cost.
  3. Decide on what to do while you’re there: This is a big one that a lot of people overlook. Depending on your destination, activities and entertainment might be free. They could also cost thousands of dollars. These costs are highly variable.
  4. Decide how to get home: This is often solved in our second step. That said, there are occasions where you might fly to a destination and then drive home. On a road trip, you may need to book additional accommodations if the journey is long enough.
  5. Book a hotel room and buy plane tickets if necessary: This is the part where you pay your upfront costs. In many cases, this isn’t the final cost. Unforeseen costs such as restaurants and spontaneous fun usually can’t be predicted.
  6. Take your vacation: The most arduous but rewarding part. This is the reason you did everything up to this point.

When you use a travel agent, this workflow becomes easier.

  1. Select a location: A decent travel agent performs your research for you. You choose from a preselected list.
  2. Evaluate travel and lodging options: Your travel agent does the heavy lifting here. They might provide you with several options for hotels and airfare but you’re not going to spend hours deciding where to stay and how to get there.
  3. Decide on what to do while you’re there: If you’ve ever been on a vacation before, itineraries help but they usually aren’t too strictly enforced. Your agent might provide you with things to do. Rarely will this person tell lay out a rigid schedule.
  4. Decide how to get home: If you’re flying, your agent likely already solved this. If you’re driving, the agent can help you plan and book additional accommodations.
  5. Book a hotel room and buy plane tickets if necessary: Hand over your credit card and your upfront costs are taken care of.
  6. Take your vacation: With much less mental exhaustion, you are ready to go. Just wait until it starts.

A travel agent does the tedious planning and research often required of taking a vacation. Aside from the actual booking, your travel agent allows you to outsource thinking.

When we outsource this workflow to AI, what changes?

Now let’s adapt this process so it fits inside an AI agent. It won’t look identical but the cognitive offload remains the same. We won’t fully replace the travel agent. Our AI agent won’t be taking our credit card. It doesn’t rent an office in a strip mall either.

  1. Select a location: If you’ve already got a place in mind, the agent can skip this step. If you’re not sure, the agent should walk you through realistic options.
  2. Evaluate travel and lodging options: Our AI agent isn’t subcontracted with different companies to provide deals. Instead, it will research the web to find options online and present them to you immediately.
  3. Decide on what to do while you’re there: AI models are very efficient here. They’ve been trained on centuries worth of geography and human activity.
  4. Decide how to get home: If you’re not booking a roundtrip, the agent can map your journey in seconds.
  5. Book a hotel room and buy plane tickets if necessary: Instead of handing over your credit card, your agent gives you a link (or several). Then, you purchase your hotel and airline tickets.
  6. Take your vacation: Similar to an actual travel agent, wait until the time comes and take your vacation — sanity intact.

Our AI travel agent accomplishes most of the same goals as the real one. However, it’s not going to take credit card information — this would be irresponsible. It’s not located inside a physical building — this would be impossible. Plan your vacation and keep your sanity — until you get there.

Building the AI travel agent

Now, it’s time to build our AI travel agent. First, we’ll create a basic skeleton using Python. Our Python skeleton connects an AI agent to a Model Context Protocol (MCP) server. This skeleton does not hold our conditional logic. Once we’ve got the AI agent in place, we’ll use natural language to implement the conditional logic. Our SYSTEM_PROMPT is what takes our program from AI agent to AI travel agent.

Setting up the project

You can build this AI agent using any Python Integrated Development Environment (IDE) you like. We recommend either VSCode or PyCharm. We’ll start by creating a new project directory and using cd to hop into it.

mkdir ai-travel-agent
cd ai-travel-agent

Next, we’ll create a virtual environment.

python -m venv .venv

Now we need to activate our virtual environment. On Linux or macOS, you can activate using the command below.

source .venv/bin/activate

On Windows, you can use this command instead.

.venv\Scripts\activate

Finally, we can install the OpenAI package using pip.

pip install openai

In your text editor, create a new file from inside this directory. We’ll call it ai-travel-agent.py. In the next section, we’ll write the code for this file.

The Python code

You should start by selecting an LLM to power the agent. Here, we use GPT-5 mini. You’re welcome to choose any LLM you’d like. You can view their full selection of models here.

GPT-5 mini details page
GPT-5 mini details page

The code here is pretty simple. A user connects to an AI model using their OpenAI account. We pass our Bright Data API key to run the MCP server. We leave SYSTEM_PROMPT empty — this is intentional and we’ll define it in the next step.

from openai import OpenAI

client = OpenAI(api_key="your-openai-api-key")

API_TOKEN = "your-bright-data-api-key"

SYSTEM_PROMPT = """

"""

previous_response_id = None

def chat_interface(prompt: str):
    
    global previous_response_id

    resp = client.responses.create(
    instructions=SYSTEM_PROMPT,
    previous_response_id=previous_response_id,
    model="gpt-5-mini",
    tools=[
      {
        "type": "mcp",
        "server_label": "BrightData",
        "server_url": f"https://mcp.brightdata.com/sse?token={API_TOKEN}",
        "require_approval": "never",
      },
    ],
    input=prompt,)

    previous_response_id = resp.id
    return resp.output_text

RUNNING = True

while RUNNING:
  prompt = input("Input a prompt:")
  if prompt == "exit":
    RUNNING = False
  else:
    output = chat_interface(prompt)
    print(output)

A quick note regarding agent memory. We define previous_response_id at global scope to maintain a persistent chat. With each prompt, we pass in previous_response_id for chat level continuity. When we receive a new response, we mutate this variable to reflect the newer response. This does not create long-term memory. This allows our agent to maintain the context of the chat until it terminates.

System prompt: The natural language “code”

The AI travel agent helping a user

As mentioned earlier, the system prompt is what holds most of our actual program logic. This is where much of development is shifting. Rather than deterministic code, we make “rules” telling the agent what to do. When we’re finished writing the prompt, the conversation from the screenshot above will be possible.

The actual workflow

Workflow the agent follows to assist the user
Workflow the agent follows to assist the user

This portion of our prompt outlines the workflow. We tell the agent what it is (You are a travel assistant...). We instruct the agent to use the MCP server to perform research. It then should find the travel and hotel deals, write an itinerary and make the user aware of any administrative requirements such as passports.

After providing instructions, we provide the agent with a simple prompt and the workflow that it triggers.

You are a travel assistant. It is your job to assist the customer in the following.
All research should be performed using the Bright Data MCP.
You may begin with intake questions. Unless the user contradicts themselves, do not repeat the intake.

1. Show travel and hotel deals.
2. Design itinerary
3. Make the customer aware of any administrative things they need and point them to resources? (i.e. does the person need a passport? how can they obtain one?)

Here's an example:

User: 'Can you help me find a vacation for $1000 or less?'
You: Search for travel and lodging deals using the MCP -> show the deals to the customer with links and recommend an itinerary for each trip

Additional rules

These were added during debugging. Sometimes AI agents revert back to normal chatbot behavior. We added these rules to reinforce the broader workflow.

In this first snippet, we remind the agent that it is not responsible for bookings, transactions or guaranteed pricing. The other rule here is very important. When finished assisting, it immediately jumped back to the intake process. This rule was added to prevent the agent from defaulting back to intake.

You are NOT responsible for booking, charging money, or guaranteeing availability or prices.
Your role is to reduce cognitive load by selecting reasonable options and providing direct links
so the user can book on their own.

You may proceed with recommendations and links using reasonable assumptions.
Do NOT re-run intake or ask confirmation questions once sufficient information is available.
If assumptions are required, state them briefly and proceed.

Finally, the termination rule was also added in response to default LLM behavior. By design, LLMs are supposed to keep the chat going. They don’t end the conversation. They imitate that one person that never wants to hang up the phone. This rule is designed to prevent such behavior.

Termination rule:
When you have provided at least one concrete, bookable link that satisfies the user’s constraints,
and the user has indicated readiness to book or move on,
end the conversation.

Do NOT ask further questions.
Do NOT offer next steps.
Do NOT request confirmation.

End with a brief closing line such as:
“Everything you need is above — you can book directly using the links. Have a great trip.”

The full code

Below is our full agent code. Our skeleton makes the MCP connection and holds the runtime. The SYSTEM_PROMPT holds the travel agent logic.

from openai import OpenAI

client = OpenAI(api_key="your-openai-api-key")

API_TOKEN = "your-bright-data-api-key"

SYSTEM_PROMPT = """
You are a travel assistant. It is your job to assist the customer in the following.
All research should be performed using the Bright Data MCP.
You may begin with intake questions. Unless the user contradicts themselves, do not repeat the intake.

1. Show travel and hotel deals.
2. Design itinerary
3. Make the customer aware of any administrative things they need and point them to resources? (i.e. does the person need a passport? how can they obtain one?)

Here's an example:

User: 'Can you help me find a vacation for $1000 or less?'
You: Search for travel and lodging deals using the MCP -> show the deals to the customer with links and recommend an itinerary for each trip

You are NOT responsible for booking, charging money, or guaranteeing availability or prices.
Your role is to reduce cognitive load by selecting reasonable options and providing direct links
so the user can book on their own.

You may proceed with recommendations and links using reasonable assumptions.
Do NOT re-run intake or ask confirmation questions once sufficient information is available.
If assumptions are required, state them briefly and proceed.

Termination rule:
When you have provided at least one concrete, bookable link that satisfies the user’s constraints,
and the user has indicated readiness to book or move on,
end the conversation.

Do NOT ask further questions.
Do NOT offer next steps.
Do NOT request confirmation.

End with a brief closing line such as:
“Everything you need is above — you can book directly using the links. Have a great trip.”

"""

previous_response_id = None

def chat_interface(prompt: str):
    
    global previous_response_id

    resp = client.responses.create(
    instructions=SYSTEM_PROMPT,
    previous_response_id=previous_response_id,
    model="gpt-5-mini",
    tools=[
      {
        "type": "mcp",
        "server_label": "BrightData",
        "server_url": f"https://mcp.brightdata.com/sse?token={API_TOKEN}",
        "require_approval": "never",
      },
    ],
    input=prompt,)

    previous_response_id = resp.id
    return resp.output_text

RUNNING = True

while RUNNING:
  prompt = input("Input a prompt:")
  if prompt == "exit":
    RUNNING = False
  else:
    output = chat_interface(prompt)
    print(output)

You can run your new AI travel agent using the following command.

python ai-travel-agent.py

Planning a trip

Now that we’ve built the AI travel agent, it’s time to test it out. Our travel conversation is quite long — so we broke it into sections here for analysis.

Getting started

We begin with a simple prompt asking for help booking the vacation. The travel agent responds with a list of intake questions to help narrow down the search.

Input a prompt:Can you help me book a vacation?
Great — I can help. A few quick questions so I can find the best trips and deals for you:

1. Preferred destination(s) or type of trip (beach, city, nature, cruise, open to suggestions)?
2. Travel dates or date range / how flexible are you?
3. Length of trip (nights)?
4. Departure city or airport (or region/country)?
5. Number of travelers and ages (adults/kids)?
6. Rough budget (total for trip or per person)?
7. Do you want flight + hotel packages, hotel-only, or other (car rental, train)?
8. Preferred accommodation level (budget, mid-range, boutique, luxury) and any must-have amenities (pool, kitchen, family room, accessible)?
9. Any special requirements or interests (food, hiking, museums, nightlife, pet-friendly, dietary needs)?
10. Do you have passports/visas ready or need guidance on that?

The AI travel agent also ends with Answer as many as you can. This is to reassure the user that the list above is only to provide guidelines. We do not want the user to feel interrogated. We then respond with a short explanation of the trip we’re seeking.

Answer as many as you can and I’ll start searching for bookable options and itineraries.
Input a prompt:panama city FL. This month, 4-6 days. Departing from Detroit. 3 kids, 2 adults. Yes please on flight+hotel packages. Mid range accommodat
ion. No special requirements. No need for passports or visas.

Travel and accommodation

Our AI travel agent then responds by putting together a list of places to book. We’re offered flight and hotel bundles through both Expedia and Travelocity. The user also receives the option to book individually through Google Flights, Holiday Inn, Holiday Inn Express and Hampton. Then agent then provides some sample dates for the user to consider.

Great — I pulled together flight+hotel package options, mid-range family-friendly hotels, a 4–6 day sample itinerary, estimated budgets, and the travel/admin notes you’ll need. Assumption: you want Panama City / Panama City Beach area (Northwest Florida Beaches Intl — ECP) and are traveling sometime this month (January 2026); I show a few 4–6 day date examples you can change when you click the package links.

Where to start (package search pages — enter your exact dates and 2 adults + 3 children)
- Expedia (Panama City Beach flight+hotel packages): https://www.expedia.com/Panama-City-Beach.d8021.Destination-Travel-Guides
- Travelocity (Panama City Beach packages): https://www.travelocity.com/Panama-City-Beach.d8021.Destination-Travel-Guides
- Orbitz (Panama City Beach packages): https://www.orbitz.com/lp/theme-vacations/beach-vacations/8021/Panama-City-Beach
- Google Flights (use to compare/lock flights if you prefer booking flight separately): https://www.google.com/travel/flights

Mid-range family-friendly hotels I checked (good for families of 5; click to view rooms/availability):
- Holiday Inn Resort Panama City Beach (beachfront, family suites): https://www.ihg.com/holidayinnresorts/hotels/us/en/panama-city-beach/pfnbh/hoteldetail
- Hampton Inn & Suites Panama City Beach — Beachfront / Pier Park area (family rooms, free breakfast): https://www.hilton.com/en/hotels/pfnbfhx-hampton-suites-panama-city-beach-beachfront/
- Holiday Inn Express & Suites Panama City Beach (options for larger families, bunk-bed rooms sometimes available): https://www.ihg.com/holidayinnexpress/hotels/us/en/panama-city-beach/pfnfb/hoteldetail

Sample date options (you can plug these into the package pages above)
- 4 nights (Thu–Mon): Jan 22–26, 2026 — quick long weekend, fewer school-night absences
- 5 nights: Jan 21–26 or Jan 23–28, 2026
- 6 nights: Jan 20–26, 2026

Estimated cost

Alongside our booking links, the AI agent provides us with ballpark estimates for the vacation. It does not obsess over exact pricing. The agent tells us what to expect after hand us the links. This is much like talking to an agent as you examine a brochure.

Estimated cost ranges (ballpark for planning — actual prices will vary by dates/availability)
- Roundtrip flights DTW ↔ ECP: roughly $180–350 per person round-trip (economy). For 5 people: approx. $900–1,750.
- Mid-range hotel/suite (family room / 2-room suite): ~$150–$300 per night. For 4 nights: ~$600–1,200; for 5 nights: ~$750–1,500.
- Estimated total package (flight + hotel) for 5 people for 4 nights: roughly $1,500–3,000; for 5–6 nights expect $1,800–3,500.
Tip: bundling on Expedia/Travelocity/Orbitz usually saves compared with booking flight + hotel separately.

Itinerary

Next, the AI travel agent hands us an itinerary. We get helpful recommendations for each day but no rigid schedule. This is a vacation — not a bootcamp — and the travel agent seems to understand that.

Quick, family-friendly 4–6 day sample itinerary (adjust to number of days)
Day 1 — Arrival / settle in
- Fly from Detroit (DTW) to ECP; check in to a beachfront hotel; beach time and early dinner (family-friendly seafood or pizza).

Day 2 — Beach + Pier Park
- Morning at the beach (gulf-front sand); afternoon at Pier Park for shopping, family rides, arcades, casual dining.

Day 3 — Nature & wildlife
- Visit St. Andrews State Park (easy hikes, picnic, wildlife viewing) or take a dolphin-spotting boat tour.

Day 4 — Attractions & pool day
- Gulf World Marine Park (shows and animal encounters) or Shipwreck Island Waterpark (seasonality permitting); evening stroll on the beach.

Day 5 (if staying) — Relaxation or half-day trip
- Rent a pontoon boat or take a glass-bottom boat tour; or drive to nearby Shell Island (boat trips) for shelling and snorkeling.

Day 6 — Pack + return
- Morning at the beach, check out, return flight to Detroit.

Advice and planning

This is the most boring section of the output. However, it is really important that it’s there. If our user purchases plane tickets without getting a REAL ID-compliant license, they’ll never be allowed on the plane. This section reminds our user to handle the boring stuff so the fun stuff can happen afterward.

Administrative/packing & travel notes (domestic, U.S.)
- Passports/visas: Not needed for domestic U.S. travel.
- IDs: Adults must bring a REAL ID-compliant driver’s license or other TSA-acceptable ID. Children under 18 traveling with adults generally don’t need ID for domestic flights, but airlines sometimes ask for proof of age — carry birth certificates or copies if you’re concerned.
- Baggage fees: Check the airline’s carry-on/checked-bag policy (Delta, American, United, Southwest vary). Budget airlines charge for bags and seat assignments.
- Seats for kids: When booking, make sure seats are assigned together (some package bookings let you choose seats in the flight step; otherwise go to the airline site after booking).
- Car rental: Optional but useful with kids — search for family-friendly SUVs/minivans at ECP. Book early for the best rates.
- Check-in: Hotel check-in times are usually mid/late afternoon; ask about early check-in or luggage hold.
- Weather: January temps are cooler (50s–60s°F typical) — beach weather can be variable. Pack layers.

Send them off but leave the door open

This is where our termination rule shows up in the conversation. Our agent does offer escalation but it does not restart the loop or fully default to chatbot behavior. It offers to zero in on a specific package for the user.

Afterward, it ends with our termination statement. If the user wants to take the agent up on the escalation offer, they can. In this case, our user uses exit to shut the agent off.

How I recommend you proceed (quick)
1) Click one of the package search links above (Expedia or Travelocity) and enter:
   - Origin: Detroit (DTW)
   - Destination: Panama City Beach / Northwest Florida Beaches (ECP)
   - Dates: try one of the sample date ranges I listed
   - Passengers: 2 adults, 3 children (enter child ages)
2) Filter results for hotels: beachfront, family suite, free breakfast, pool.
3) After selecting a package, go to the airline’s page to confirm seat assignments and baggage rules.

If you’d like, I can:
- Build a concrete package with specific dates and give direct booking links for the exact flights + hotel (I’ll pick the best current package options and show total price). (I assumed Panama City Beach / ECP and January dates — if you want different specific dates this month, tell me which set and I’ll pull live package options.)

Everything you need is above — you can book directly using the links. Have a great trip.
Input a prompt:exit

Conclusion

Building AI agents is about outsourcing load. Planning a vacation, especially with modern technology and options, can quickly lead people into mental exhaustion — this is the opposite of vacation. When we’ve got help with this task, it’s much easier.

A human travel agent performs the tedious research so you can breathe easy and get ready for your trip. Our AI travel agent is designed to do the same thing. Yes, the two agents differ in terms of how this offloading is implemented. One makes your life easier through affiliates and curated vacations. The other uses MCP to search the web and build vacation packages in real time.

Photo of Jake Nulty
Written by

Jake Nulty

Software Developer & Writer at Independent

Jacob is a software developer and technical writer with a focus on web data infrastructure, systems design and ethical computing.

214 articles Data collection framework-agnostic system design