are the discuss of the city. We see them in every single place, even getting used for the best of duties on our telephones. They’re handy, quick, and just about dependable, and assist us navigate day-to-day life. In order for you a simple clarification of a scientific idea, you ask ChatGPT. You desire a information to your choosy toddler’s food regimen plan, so that you ask AI. Even the duty of planning your full journey tour could be delegated to AI. And, that is precisely what we’re going to do on this tutorial (keep tuned!).
We find out about AI Brokers, however what if we will construct and use totally different AI Brokers for various roles in a much bigger venture? That is the place the multi-agent system idea comes into play. As AI functions change into extra superior, we’re shifting from single AI fashions that reply easy questions and do simple duties to programs the place a number of AI brokers work collectively to unravel complicated issues. A Multi-Agent System (MAS) is an idea the place a number of AI brokers collaborate with one another to meet a much bigger purpose. Every of those has a selected function resulting in the final word purpose, and so they accomplish it with mutual collaboration.
A Multi-Agent Journey Planning System
On this venture, we will likely be constructing a Multi-Agent Journey Planning System. So mainly, what we can have is that as a substitute of only one AI Agent who will plan our travels, we can have a workforce of AI brokers, every with one particular function, and they’ll work with each other to make the proper journey plan for us!
We are able to consider a Multi-Agent Journey Planning System like an actual journey company. As a substitute of a single particular person dealing with all the pieces, totally different consultants will likely be dealing with totally different duties as per their experience and work collectively. For our AI Journey Planner, we can have the next brokers:

- Journey Analysis Agent: This agent will carry out the analysis duties. It would discover the vacation spot the place the consumer desires to go and discover points of interest, hidden locations, native experiences, journey ideas, and so on. It would gather the fundamental info wanted to plan the journey.
- Exercise Planning Agent: This agent will plan actions based mostly on the analysis of the Analysis Agent. Will probably be the one to determine which place to go to, when to go to, what actions to do, and find out how to set up the entire journey!
- Finances Agent: This agent is liable for correct budgeting. It would analyze the plan shared by the Exercise Planning Agent and share the anticipated prices, inexpensive choices, money-saving ideas, and assist customise the journey to the consumer’s funds.
- Remaining Journey Assistant: Lastly, the ultimate journey assistant will mix the output from all three brokers: the analysis, actions plan, and funds, and create a easy personalised journey itinerary!
That is what the overall workflow of the entire venture will seem like:

We’ll construct this venture in Python, utilizing PyCharm IDE. That is an intermediate-level Python venture that requires a fundamental understanding of AI Brokers in Python, in addition to a preliminary information of Object-Oriented Programming, as we will likely be creating courses. If you’re new to Python and Agentic AI, you’ll be able to entry my beginner-friendly AI Agent tutorial from the next hyperlink:
The Final Rookies’ Information to Constructing an AI Agent in Python
If you wish to study Python OOP, you’ll be able to learn the next articles the place I’ve created a Espresso Machine in Python, after which, within the subsequent tutorial, used the idea of OOP to optimize the code:
Implementing the Espresso Machine in Python
Implementing the Espresso Machine Venture in Python Utilizing Object-Oriented Programming
All these articles offers you a fundamental understanding of Python code, and can in flip provide help to perceive the code that comes beneath this fascinating venture. Allow us to begin coding the venture!
Creating the Venture
The very first thing is creating the venture folder in PyCharm (or IDE of your alternative) and naming the venture “Multi Agent System” (or something of your alternative).

Putting in and Importing the Python Packages
As soon as the venture folder is created, go on and create a “primary.py” file the place we are going to do our coding. Within the terminal, set up OpenAI after which import it into your coding file.
pip set up openai

from openai import OpenAI
Connecting Python With the AI Mannequin
To ensure that our program to speak with OpenAI and course of the code, we have to join it to the AI platform. In our case, we are going to use OpenRouter.ai and add its URL. We may also add the API Key to our code, saving it within the api_key variable. This API key will give our program the required permission to make use of AI fashions. We’ll create a consumer that can talk with the AI mannequin utilizing the API key we created:
consumer = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key="YOUR API KEY"
)
When you create an API key in OpenRouter.ai, don’t share the important thing with anybody. Simply add it within the place of “YOUR API KEY”.
Creating the Agent Class
Now comes the a part of coding the AI brokers. Since we’re not creating only one or two brokers, we is not going to be straight coding. Reasonably, we are going to use the idea of OOP, and create a category (or a blueprint in simple phrases) of the agent class, after which use this blueprint to create every particular person agent forward. The agent will retailer the identify which identifies the agent, and the function, that tells AI how the agent ought to behave. Moreover, we may also create a perform run that can give our AI brokers the power to work, that’s, to ship duties to the AI mannequin.
class Agent:
def __init__(self, identify, function):
self.identify = identify
self.function = function
def run(self, process):
print(f"{self.identify} is working...")
response = consumer.chat.completions.create(
mannequin="gpt-4.1-mini",
messages=[
{
"role": "system",
"content": self.role
},
{
"role": "user",
"content": task
}
],
max_tokens=1200
)
return response.decisions[0].message.content material
The code above will ship the next two issues to the AI mannequin (which we now have additionally specified):
- The respective agent’s job/function
- The Consumer message taken as enter from the consumer (as you will notice later)
We’ll get the AI Response returned from this code block with the next code return response.decisions[0].message.content material. This return assertion will extract the reply generated by the agent (for those who discover it obscure this code, confer with my AI Agent newbie information article linked originally of this text).
Creating Agent Objects
Now that our agent class is created, we are going to use this blueprint to create our particular person AI brokers. The next code makes use of the OOP idea to create agent objects, particularly:
- Analysis Agent
- Exercise Agent
- Finances Agent
- Remaining Agent
research_agent = Agent(
"Analysis Agent",
"""
You're an knowledgeable journey researcher.
Your job:
- Discover standard points of interest
- Discover hidden gems
- Recommend native experiences
- Suggest finest locations
"""
)
activity_agent = Agent(
"Exercise Planner Agent",
"""
You're a skilled journey planner.
Your job:
- Create day by day actions
- Plan sightseeing
- Suggest meals experiences
- Manage actions logically
"""
)
budget_agent = Agent(
"Finances Agent",
"""
You're a journey funds knowledgeable.
Calculate:
- Estimated flight price
- Visa necessities
- Visa charges if wanted
- Lodge price
- Meals bills
- Transport price
- Exercise prices
Create an approximate complete journey funds.
Preserve response brief.
"""
)
final_agent = Agent(
"Remaining Journey Assistant",
"""
You're a skilled journey planner.
Create the ultimate itinerary.
Embody:
1. Quick journey overview
2. Visa info
3. Estimated flight price
4. Day-wise plan
5. Meals recommendations
6. Complete estimated funds
Preserve all the pieces beneath 700 phrases.
"""
)
This code will create particular person AI brokers with particular roles as talked about within the code. The function tells the AI mannequin the way it ought to behave and what process it ought to give attention to.
Consumer Enter
The following process is to get the enter from the consumer. We’ll ask the consumer the next questions:
- The place are they flying from
- There they’re flying to
- Variety of days of the journey
- Variety of vacationers
- Pursuits
#Get Consumer Journey Particulars
starting_location = enter(
"The place are you flying from? "
)
vacation spot = enter(
"The place do you need to journey? "
)
days = enter(
"What number of days is your journey? "
)
vacationers = enter(
"What number of vacationers? "
)
funds = enter(
"What's your funds? (low/medium/excessive) "
)
pursuits = enter(
"What are your pursuits? "
)
Creating the Consumer Request
After amassing info from the consumer via the enter statements, we mix all the pieces right into a single immediate and cross it over to the AI brokers.
# Create request for AI brokers
user_request = f"""
Create a journey plan with these particulars:
Flying From:
{starting_location}
Vacation spot:
{vacation spot}
Journey Length:
{days} days
Variety of Vacationers:
{vacationers}
Finances Stage:
{funds}
Pursuits:
{pursuits}
Embody:
- Visa necessities
- Estimated flight price
- Locations to go to
- Actions
- Meals suggestions
- Complete estimated funds
"""
print("nCreating your AI journey plan...n")
Whereas the AI is working within the backend, we are going to print the assertion “Creating your AI journey plan”, so the consumer is aware of that the method is working and the brokers have began working.
Multi-Agent Workflow
Now that we now have created the consumer request, by giving all of it the main points we now have taken from the consumer, allow us to now get the multi-agent system working. Every agent completes one process and passes its outcome to the following agent.
The consumer’s journey particulars are first despatched to the Analysis Agent. This agent asks the AI mannequin to search out one of the best locations to go to, native experiences, and journey info. The result’s saved in analysis. The analysis output turns into the enter for the Exercise Agent. It converts journey info into day by day actions, sightseeing plans, and meals concepts. The result’s saved in actions. Then comes the Finances Agent who receives the deliberate actions and estimates the prices of flights, visas, accommodations, transport, and so on. The result’s saved in funds. The Remaining Journey Agent receives info from the entire earlier brokers and combines all the pieces into one full journey itinerary, which is then output to the consumer.
#Multi-Agent Workflow
#Agent 1 researches vacation spot
analysis = research_agent.run(
user_request
)
print("n--- Analysis Accomplished ---")
#Agent 2 creates actions
actions = activity_agent.run(
analysis
)
print("n--- Actions Deliberate ---")
#Agent 3 calculates funds
funds = budget_agent.run(
actions
)
print("n--- Finances Created ---")
#Agent 4 creates ultimate itinerary
final_plan = final_agent.run(
f"""
Analysis:
{analysis}
Actions:
{actions}
Finances:
{funds}
Create ultimate journey plan.
"""
)
print("n==========================")
print(" FINAL TRAVEL PLAN")
print("==========================n")
print(final_plan)
Operating the Code
By working the code, you’ll be able to see this system asking for consumer enter. You possibly can add your particular particulars, answering the questions. It’s based mostly on these solutions that the AI brokers workforce will make your journey itinerary.

"C:UsersMahnoor JavedPycharmProjectsMulti Agent System.venvScriptspython.exe" "C:UsersMahnoor JavedPycharmProjectsMulti Agent Systemmain.py"
The place are you flying from? islamabad
The place do you need to journey? istanbul
What number of days is your journey? 3
What number of vacationers? 4
What's your funds? (low/medium/excessive) $4k
What are your pursuits? child frinedly
Creating your AI journey plan...
Analysis Agent is working...
--- Analysis Accomplished ---
Exercise Planner Agent is working...
--- Actions Deliberate ---
Finances Agent is working...
--- Finances Created ---
Remaining Journey Assistant is working...
==========================
FINAL TRAVEL PLAN
==========================
### 3-Day Household-Pleasant Itinerary: Islamabad to Istanbul
---
#### Journey Overview
Uncover Istanbul’s fascinating mix of historical past, tradition, and family-friendly enjoyable on this 3-day journey from Islamabad. Discover iconic landmarks like Hagia Sophia and Topkapi Palace, dive into interactive experiences at Istanbul Aquarium and KidZania, and unwind in lovely parks and bustling bazaars. This itinerary balances cultural discovery with participating actions excellent for youths, guaranteeing recollections for your complete household.
---
#### Visa Data
- **For Pakistani Residents:** Turkish e-Visa required
- **Utility:** Apply on-line earlier than journey at [e-Visa Turkey official website]
- **Price:** Approx. $50 per particular person
- **Processing time:** Often 24-48 hours
- **Tip:** Carry a printout or e-copy of the e-Visa throughout journey.
---
#### Estimated Flight Price
- **Route:** Islamabad (ISB) – Istanbul (IST) round-trip
- **Price:** $350 - $450 per particular person in economic system class
- **For 4 vacationers:** Approx. $1,400 - $1,800 complete
- **Tip:** E book 2-3 months prematurely to safe higher offers.
---
### Day-wise Itinerary
**Day 1: Historic and Iconic Sights**
- **Morning:**
- Arrive Istanbul, switch and check-in at a family-friendly lodge close to Sultanahmet.
- Go to **Hagia Sophia**, immersing within the grandeur of this iconic monument.
- Stroll to **Topkapi Palace**, exploring expansive gardens and kid-friendly areas.
- **Afternoon:**
- Loosen up and play at **Sultanahmet Sq.**; youngsters take pleasure in ample open area.
- Hop on the nostalgic **Sultanahmet tram** for an enthralling experience across the historic district.
- **Night:**
- Take pleasure in a **Bosphorus dinner cruise** that includes household leisure and child actions alongside scrumptious Turkish delicacies.
---
**Day 2: Interactive Enjoyable and Exploration**
- **Morning:**
- Go to **Istanbul Aquarium (Florya)** to see numerous marine life, contact swimming pools, and themed zones.
- Lunch at aquarium’s family-friendly café or close by **Discussion board Istanbul Mall**.
- **Afternoon:**
- Work together and play at **KidZania Istanbul** contained in the mall the place kids role-play professions and be taught via enjoyable.
- Take pleasure in mall playgrounds and snack breaks.
- **Night:**
- Strive well-known **Maraş dondurma** (Turkish ice cream) with entertaining vendor exhibits.
- Leisurely mall or park stroll earlier than returning to lodge.
---
**Day 3: Parks, Museums, Markets & Native Flavors**
- **Morning:**
- Picnic and playtime at **Gülhane Park** with pony rides for youngsters.
- Discover the **Rahmi M. Koç Museum** that includes interactive reveals together with automobiles, toys, and a submarine.
- **Afternoon:**
- Quick go to to the **Grand Bazaar** specializing in kid-friendly memento outlets.
- Pattern native avenue meals: **simit** (sesame bagels) and **gözleme** (savory crepes).
- **Night:**
- Dinner at **Çiya Sofrası** for delicate conventional dishes or strive **Saray Muhallebicisi** for genuine Turkish desserts like sütlaç (rice pudding).
---
### Meals Strategies
- **Çiya Sofrası (Kadıköy):** Genuine Turkish with kid-friendly choices
- **Saray Muhallebicisi:** Conventional desserts excellent for household treats
- **Midpoint/Cookshop:** Informal eating with worldwide and native menus appropriate for youngsters
- **Road Meals:** Strive simit, lahmacun (Turkish pizza), and borek pastries at native distributors
---
### Estimated Finances (4 Individuals)
| Class | Estimated Price (USD) |
|---------------------------|-------------------------------|
| Flights (Spherical-trip) | $1,400 - $1,800 |
| Visa Charges | $200 |
| Lodging (3 nights) | $600 - $800 |
| Meals | $300 - $400 |
| Transport (Istanbulkart, taxis) | $100 |
| Entrance Charges & Actions| $300 |
| Miscellaneous | $200 |
| **Complete Estimate** | **~$3,100 - $3,800** |
*Word: Finances can range relying on lodge alternative and eating preferences.*
---
### Further Ideas
- E book tickets on-line prematurely for standard points of interest to skip queues.
- Buy an **Istanbulkart** for handy and discounted journey on public transport.
- Pack snug sneakers and solar safety for youngsters.
- Go for lodging with household facilities and shut proximity to tram or metro stations in Sultanahmet or Beyoğlu districts.
- Many eating places present youngsters’ menus and excessive chairs—ask beforehand.
---
Would you want personalised lodge suggestions and assist with reserving flights? Additionally, I can help you with native transport particulars or restaurant reservations. Simply let me know!
Course of completed with exit code 0
The above is the output of the code. You possibly can see how personalised the journey itinerary is!
Conclusion
On this venture, we now have efficiently used our information of constructing AI brokers in Python to construct one thing that’s sensible and has real-life functions. That is how real-world issues are: we have already got a system working, however we have to optimize it and make it extra environment friendly, and these could be simply achieved by implementing some fundamental ideas.
We may have constructed this journey planner utilizing a single AI agent and requested it to deal with all the pieces. Nevertheless, by making a multi-agent system, we divided the work amongst specialised brokers, every specializing in one particular process. This method makes the system extra organized, environment friendly, and nearer to how real-world groups clear up issues. As a substitute of 1 AI making an attempt to do all the pieces, a number of AI brokers collaborate to create a greater and extra personalised outcome for the consumer.
By including reminiscence, exterior instruments, APIs, and real-time information, these brokers can change into much more highly effective and clear up complicated real-world issues; a venture for subsequent time!





