CrewAI Setup Guide: Make Multiple AI Agents Work Together on One Task
Why use one AI when you can use a whole team? CrewAI lets you create multiple specialized agents (like a Researcher, a Writer, and an Editor) that talk to each other to complete complex tasks. Here is the ultimate setup guide.
The Multi-Agent Revolution
If you've played with ChatGPT or local models, you know they are incredibly smart but easily distracted. If you give a single AI prompt a massive task—like "Research the state of AI in 2026, write a comprehensive 2000-word blog post, and then proofread it"—it usually fails. It gets lazy, skips steps, or hallucinates.
Why? Because human companies aren't built on one person doing everything. We have specialized roles. You have a Researcher, a Writer, and an Editor.
This is exactly what CrewAI does. It is a cutting-edge Python framework that allows you to spin up multiple "Agents", give them specific "Tasks", and have them pass information between each other until the final goal is achieved. It is literally like running a tiny software company on your laptop.
Step 1: Installing CrewAI
To get started, we need Python installed. We'll install the main CrewAI library, plus the built-in tools package which gives our agents the ability to search the web and read files.
pip install crewai crewai[tools] langchain-openaiYou also need an API key. For multi-agent systems, I highly recommend using OpenAI's GPT-4o or Anthropic's Claude 3.5 Sonnet, because the agents need strong reasoning skills to talk to each other. Export your API key in your terminal:
export OPENAI_API_KEY="sk-proj-..."Step 2: Defining Your Agents
Let's build a "Content Creation Crew". We need two people: A Senior Tech Researcher, and an Expert Tech Writer.
Create a file called main.py. We define agents by giving them a role, a goal, and a backstory. The backstory is crucial—it's the system prompt that dictates the agent's personality and expertise.
from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool
# Give our researcher a search engine tool
search_tool = SerperDevTool()
researcher = Agent(
role='Senior Tech Researcher',
goal='Uncover the latest trends in Agentic AI',
backstory="You are a veteran tech analyst at a top-tier research firm. You excel at finding obscure, cutting-edge AI repositories on GitHub and explaining their impact.",
verbose=True,
allow_delegation=False,
tools=[search_tool]
)
writer = Agent(
role='Expert Tech Writer',
goal='Write an engaging, human-sounding blog post based on research',
backstory="You are a renowned tech journalist. You write in a conversational, witty tone. You never use corporate jargon or AI cliches like 'in the rapidly evolving landscape'.",
verbose=True,
allow_delegation=False
)Step 3: Assigning Tasks
Agents are useless without work to do. We create Tasks and assign them to specific agents. Notice how we use the expected_output parameter. This forces the agent to return data in a specific format before handing it off.
research_task = Task(
description="Search the web for the top 3 new multi-agent AI frameworks released this month. Summarize their core features.",
expected_output="A bulleted list of 3 frameworks with a 2-paragraph summary for each.",
agent=researcher
)
writing_task = Task(
description="Take the research provided and write a 1000-word blog post. Use markdown formatting. Add a catchy title.",
expected_output="A full markdown-formatted blog post.",
agent=writer
)Step 4: Assembling the Crew
Now, we put the agents and tasks together in a Crew. We set the process to sequential, meaning the Researcher will do its job first, and automatically pass its output directly into the Writer's brain.
tech_crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
process=Process.sequential
)
# Start the execution!
result = tech_crew.kickoff()
print("######################")
print(result)Watching Them Work
When you run python main.py, you will see the terminal light up with their internal monologues.
First, the Researcher wakes up. You will see it format a search query, realize the results aren't good enough, format a new search query, find the information, and compile the notes.
Then, the Writer takes over. It reads the notes and begins drafting the article according to its "witty journalist" persona.
The final output will print to your screen. Because the workload was split, the final article will be significantly better, more factually accurate, and better formatted than if you had just asked ChatGPT to do the whole thing in one prompt.
Why CrewAI is the Future
CrewAI bridges the gap between simple chat bots and complex enterprise orchestration. You can easily add a "QA Engineer" agent to review the Writer's work and force the Writer to rewrite it if it finds grammar mistakes. You can add a "Manager" agent that delegates tasks dynamically.
As models get cheaper and faster, running a team of 5 AI agents to solve your coding or marketing problems will become the standard workflow. Get ahead of the curve and start building your crew today.
FAQ
Does CrewAI cost a lot of money to run?
Because multiple agents are passing context back and forth, token usage is higher than a single prompt. A single run of a complex crew might cost $0.05 to $0.15 on GPT-4o. You can mitigate this by using local models via Ollama.
Can I use local open-source models with CrewAI?
Yes! CrewAI integrates seamlessly with LangChain, which means you can pass it an Ollama LLM endpoint. Just keep in mind that multi-agent routing requires very smart models; small 8B models often get confused during task handoffs.
How does it compare to AutoGPT?
AutoGPT is a single agent trying to do everything, which often leads to infinite loops. CrewAI is heavily structured—agents have very specific roles and boundaries, making it far more reliable for actual production work.
Explore RuView on GitHub
Browse the Rust engine, ESP32 firmware and examples.