AI Agents are the talk of the spot. We see them all over, also being utilized for the simplest of jobs on our phones. They are convenient, fast, and quite reliable, and assist us browse daily. If you desire a basic explanation of a scientific concept, you ask ChatGPT. You desire a guide for your picky toddler’s dish strategy, so you ask AI. Even the task of planning your complete traveling tour can be delegated to AI. And, this is exactly what we are going to do in this tutorial (keep tuned!).
We know about AI Agents, but what if we can develop and utilize various AI Agents for various roles in a larger project? This is where the multi-agent system principle comes into play. As AI applications become more advanced, we are relocating from single AI designs that address easy concerns and do simple tasks to systems where several AI agents collaborate to resolve complicated issues. A Multi-Agent System (MAS) is an idea where multiple AI agents work with each other to fulfill a larger objective. Each of these has a particular role leading to the utmost goal, and they complete it with shared cooperation.
A Multi-Agent Travel Planning System
In this project, we will be building a Multi-Agent Travel Planning System. So generally, what we will have is that instead of just one AI Agent who will plan our travels, we will have a group of AI agents, each with one particular function, and they will interact with one another to make the ideal travel plan for us!
We can think about a Multi-Agent Travel Planning System like a genuine travel firm. Instead of a single person managing everything, different experts will be handling different jobs as per their proficiency and work together. For our AI Travel Planner, we will have the following agents:
AI Agents in our Project (Image by Author)
Travel Research Agent: This agent will carry out the research jobs. It will explore the location where the client wants to go and discover attractions, concealed locations, regional experiences, travel ideas, and so on. It will gather the standard info needed to plan the trip.
Activity Planning Agent: This agent will prepare activities based upon the research study of the Research Agent. It will be the one to choose which place to visit, when to check out, what activities to do, and the best ways to organize the entire journey!
Budget Agent: This agent is responsible for correct budgeting. It will evaluate the strategy shared by the Activity Planning Agent and share the expected costs, affordable alternatives, money-saving pointers, and assistance customize the journey to the customer’s spending plan.
Final Travel Assistant: Finally, the last travel assistant will integrate the output from all three agents: the research, activities plan, and budget plan, and produce a basic personalized travel plan!
This is what the general workflow of the whole project will look like:
Project Workflow (Image by Author)
We will construct this project in Python, utilizing PyCharm IDE. This is an intermediate-level Python project that needs a basic understanding of AI Agents in Python, as well as a primary understanding of Object-Oriented Programming, as we will be creating classes. If you are new to Python and Agentic AI, you can access my beginner-friendly AI Agent tutorial from the following link:
The Ultimate Beginners’ Guide to Building an AI Agent in Python
If you want to learn more about Python OOP, you can check out the following posts where I have actually produced a Coffee Machine in Python, and after that, in the next tutorial, utilized the idea of OOP to enhance the code:
Implementing the Coffee Machine in Python
Implementing the Coffee Machine Project in Python Using Object-Oriented Programming
All these posts will offer you a fundamental understanding of Python code, and will in turn help you understand the code that falls under this interesting project. Let us begin coding the project!
Creating the Project
The first thing is producing the job folder in PyCharm (or IDE of your option) and calling the project “Multi Agent System” (or anything of your choice).
Creating the Project (Image by Author)
Installing and Importing the Python Packages
When the task folder is created, go on and create a “main.py” file where we will do our coding. In the terminal, set up OpenAI and after that import it into your coding file.
pip install openai
Creating Folder, Python file, Installing and Importing OpenAI (Image by Author)
from openai import OpenAI
Connecting Python With the AI Model
In order for our program to interact with OpenAI and process the code, we need to connect it to the AI platform. In our case, we will use OpenRouter.ai and add its URL. We will also include the API Key to our code, saving it in the api_key variable. This API key will offer our program the required authorization to utilize AI models. We will produce a client that will communicate with the AI model utilizing the API key we produced:
client = OpenAI(
base_url="
api_key="YOUR API KEY"
)
Once you create an API key in OpenRouter.ai, do not share the key with anybody. Just add it in the location of “YOUR API KEY”.
Creating the Agent Class
Now comes the part of coding the AI agents. Given that we are not developing simply one or two agents, we will not be directly coding. Rather, we will utilize the concept of OOP, and develop a class (or a blueprint in easy words) of the agent category, then use this plan to produce each private agent ahead. The agent will save the name which identifies the agent, and the function, that informs AI how the agent must act. Additionally, we will also develop a function run that will offer our AI agents the capability to work, that is, to send tasks to the AI design.
class Agent:
def __init__(self,
class Agent:
def __init__(self, name, role):
self.name = name
self.role = role
def run(self, task):
print(f"{self.name} is working...")
response = client.chat.completions.create(
model="gpt-4.1-mini",
messages=[
{
"role": "system",
"content": self.role
},
{
"role": "user",
"content": task
}
],
max_tokens=1200
)
return response.choices[0].message.content
The snippet above transmits the following two pieces of information to the AI model (which we have also specified):
The specific role or job assigned to each agent
The user message captured as input (more on this shortly)
The AI generated response will be retrieved from this section using the statement return response.choices[0].message.content. That return command pulls out the reply produced by the agent (if this part seems confusing, check out the introductory AI Agent guide linked at the top of this page).
Building Agent Instances
With our agent class ready, we can now use this template to construct specific AI agents. The code below applies OOP principles to instantiate the following agent objects:
Research Agent
Activity Agent
Budget Agent
Final Agent
research_agent = Agent(
"Research Agent",
"""
You are an expert travel researcher.
Your job:
- Find popular attractions
- Find hidden gems
- Suggest local experiences
- Recommend best places
"""
)
activity_agent = Agent(
"Activity Planner Agent",
"""
You are a professional travel planner.
Your job:
- Create daily activities
- Plan sightseeing
- Recommend food experiences
- Organize activities logically
"""
)
budget_agent = Agent(
"Budget Agent",
"""
You are a travel budget expert.
Calculate:
- Estimated flight cost
- Visa requirements
- Visa fees if needed
- Hotel cost
- Food expenses
- Transport cost
- Activity costs
Create an approximate total trip budget.
Keep response short.
"""
)
final_agent = Agent(
"Final Travel Assistant",
"""
You are a professional travel planner.
Create the final itinerary.
Include:
1. Short trip overview
2. Visa information
3. Estimated flight cost
4. Day-wise plan
5. Food suggestions
6. Total estimated budget
Keep everything under 700 words.
"""
)
This block generates individual AI agents with distinct roles spelled out in the code. The role definition instructs the AI on its expected behavior and the particular area it should concentrate on.
Capturing User Input
The next step involves gathering input from the user. We pose the following questions to the user:
What is your departure city?
Where is your destination?
How long is the trip in days?
How many people are traveling?
What are your interests?
#Get User Travel Details
starting_location = input(
"Where are you flying from? "
)
destination = input(
"Where do you want to travel? "
)
days = input(
"How many days is your trip? "
)
travelers = input(
"How many travelers? "
)
budget = input(
"What is your budget? (low/medium/high) "
)
interests = input(
"What are your interests? "
)
Formulating the User Request
Once we gather all the information from the user through the input prompts, we merge everything into one unified prompt and send it to the AI agents.
# Create request for AI agents
user_request = f"""
Create a travel plan with these details:
Flying From:
{starting_location}
Destination:
{destination}
Trip Duration:
{days} days
Number of Travelers:
{travelers}
Budget Level:
{budget}
Interests:
{interests}
Include:
- Visa requirements
- Estimated flight cost
- Places to visit
- Activities
- Food recommendations
- Total estimated budget
"""
print("nCreating your AI travel plan...n")
When the AI is processing in the background, the message "Creating your AI travel plan..." will be displayed to let the user know the system is operating and the agents have begun their tasks.
Multi-Agent Workflow
With the user request prepared and all collected details included, we can now initiate the multi-agent system. Each agent tackles one specific task and forwards its outcome to the next agent in the chain.
The travel details from the user are initially forwarded to the Research Agent. This agent prompts the AI model to discover the top attractions, local experiences, and relevant travel information. The findings are stored in research. The research findings then serve as input for the Activity Agent. This agent transforms the travel data into a structured daily schedule, sightseeing itinerary, and food suggestions. The results are kept in activities. Following that, the Budget Agent takes the planned activities and calculates approximate costs for flights, visas, accommodation, transportation, and other expenses. The outcome is saved in budget. Finally, the Final Travel Agent gathers the outputs from all preceding agents and merges them into a comprehensive travel itinerary, which is then presented to the user.
#Multi-Agent Workflow
#Agent 1 researches destination
research = research_agent.run(
user_request
)
print("n--- Research Completed ---")
#Agent 2 creates activities
activities = activity_agent.run(
research
)
print("n--- Activities Planned ---")
#Agent 3 calculates budget
budget = budget_agent.run(
activities
)
print("n--- Budget Created ---")
#Agent 4 creates final itinerary
final_plan = final_agent.run(
f"""
Research:
{research}
Activities:
{activities}
Budget:
{budget}
Create final travel plan.
"""
)
print("n==========================")
print(" FINAL TRAVEL PLAN")
print("==========================n")
print(final_plan)
Executing the Code
When you execute the code, the program will prompt you for input. You can supply your personalized responses to each question. Based on these inputs, the AI agent team will generate your travel itinerary.
Executing the Code (Image by Author)
"C:UsersMahnoor JavedPycharmProjectsMulti Agent System.venvScriptspython.exe" "C:UsersMahnoor JavedPycharmProjectsMulti Agent Systemmain.py"
Where are you flying from? islamabad
Where
Your Next Adventure: Istanbul
Planning a family vacation? Explore a 3-day, kid-friendly travel plan for Istanbul!
This sample itinerary from Islamabad is designed for 4 travelers with a medium budget. It balances iconic sightseeing with interactive museums and local flavors to keep everyone entertained.
3-Day Family Fun in Islamabad to Istanbul
Your Trip at a Glance
This itinerary is perfect for families, blending history, culture, and interactive fun. From the stunning architecture of the Hagia Sophia to the hands-on excitement of KidZania Istanbul, there's something for everyone to enjoy.
Important: Visa Details
Pakistani citizens will need a Turkish e-Visa. Be sure to apply online before your trip at the official e-Visa Turkey portal. The cost is around $50 per person, and it usually takes just 24-48 hours to process. Always have a printed copy or saved on your phone when you travel.
Getting There: Flight Options
A round-trip flight from Islamabad (ISB) to Istanbul (IST) will cost approximately $350 - $450 per person in economy class. For a group of four, expect to spend around $1,400 - $1,800 total. Booking 2-3 months ahead can help you find better deals and save money.
A Detailed 3-Day Itinerary
Day 1: Exploring History's Treasures
Morning: Touch down in Istanbul, check into a hotel near Sultanahmet for easy access to sights. Start your trip with visits to the majestic Hagia Sophia and Topkapi Palace, featuring impressive gardens.
Afternoon: Chill out at Sultanahmet Square, kids can run around in the open space. Enjoy a charming ride on the nostalgic tram through the historic district.
Evening: Take a Bosphorus dinner cruise with activities for the kids and delicious Turkish food for the whole family.
Day 2: Interactive Fun and Exploration
Morning: Head to Istanbul Aquarium (Florya) to explore diverse marine displays, touch pools, and themed areas. Grab lunch at the aquarium's café or the nearby Forum Istanbul Mall.
Afternoon: Let the kids explore at KidZania Istanbul, located right in the mall. It offers role-playing activities and tons of fun. While you're there, enjoy mall playgrounds and snack breaks.
Evening: Sample famous Maraş dondurma (Turkish ice cream) with live entertainment from vendors. Enjoy a relaxed evening walk around the mall or a nearby park before returning to the hotel.
Day 3: Parks, Museums, Markets & Local Flavors
Morning: Spend time at Gülhane Park with pony rides for the little ones. Then explore the Raḥmi M. Koç Museum for interactive displays featuring vehicles, toys, and even a submarine.
Afternoon: Visit the Grand Bazaar for some kid-friendly souvenir shopping. Sample local street foods like simit (sesame bagels) and gözleme (savory crepes).
Evening: For dinner, head to Çiya Sofrası for mild traditional options, or treat the family at Saray Muhallebicisi for authentic desserts like sütlaç (rice pudding).
Local Eats You Can't Miss
For authentic Turkish food with kid-friendly choices, consider Çiya Sofrası in Kadıköy. Traditional desserts are a must-try at Saray Muhallebicisi. If you're looking for casual dining with international and local options, Midpoint/Cookshop is a solid choice. For street food, try simit, lahmacun (Turkish pizza), and börek pastries from local vendors.
Budget Breakdown for 4 Travelers
Category
Estimated Cost (USD)
Flights (round-trip)
$1,400 - $1,800
Visa Fees
$200
Accommodation (3 nights)
$600 - $800
Food
$300 - $400
Transport (Istanbulkart, taxis)
$100
Entrance Fees & Activities
$300
Miscellaneous
$200
Total Estimate
$3,100 - $3,800
The final budget depends on your hotel and dining preferences.
Travel Tips
Pre-book tickets online to skip lines at major attractions.
Get an Istanbulkart for convenient and affordable travel on public transport.
Pack comfortable shoes and sun protection for the kids.
Choose family-friendly hotels in Sultanahmet or Beyoğlu districts, close to tram or metro stations.
Many restaurants have kids' menus and high chairs, just ask!
Looking for personalized hotel recommendations or help booking flights or local transport? I'm here to assist!
Process finished with exit code 0
The above is the output of the code. You can see how personalized the travel itinerary is!
Key Takeaways
This project demonstrates a practical application of AI agent technology in real-world travel planning. By leveraging multiple specialized agents, we've created a system that's both efficient and adaptable, similar to how real-world teams operate.
We chose to build a multi-agent system instead of a single agent handling everything. This approach allows for a more organized workflow and a better end-user experience. Each agent focuses on a specific task, leading to more personalized results for the traveler.
By incorporating memory, external tools, APIs, and real-time data into the system, it's poised to handle complex, real-world problems. A challenge for the future iterations to come!