CrewAI Tutorial: Build a Multi-Agent Workflow From Scratch
Build a working CrewAI multi-agent workflow from scratch: install the CLI, scaffold a crew, define agents and tasks, and run your first research crew.
By Galactic News Editorial · Published 2026-11-17T07:29:49+00:00 · Updated 2026-11-17T07:29:49+00:00
CrewAI Tutorial: Build a Multi-Agent Workflow From Scratch
This CrewAI tutorial builds a working multi-agent workflow from zero. You will create a two-agent research crew. One agent searches the web. The other writes a structured report. You need Python 3.10 or newer and below 3.14, plus an API key for your language model provider. The whole setup takes about 30 minutes once the keys are ready.
CrewAI tutorial: how the framework works
CrewAI is a Python framework for role-based multi-agent collaboration. It has three building blocks. An Agent is a single worker with a role, a goal, and a backstory. A Task is one assignment for an agent, with a description and an expected output. A Crew is the team: a list of agents, an ordered list of tasks, and a process that decides how the tasks run. Two processes exist. Sequential runs tasks in list order and passes each output to the next task. Hierarchical uses a manager agent to delegate tasks dynamically. Sequential is the default and the right choice for a first crew. Agents can also use tools, such as web search, and can share memory when you enable it.
Step 1: Install Python and uv
Check your Python version first. Run python3 --version in your terminal. You need Python 3.10 or newer and below 3.14. Older versions are not supported. CrewAI uses uv as its default package manager. Install uv from Astral before you install CrewAI. The official install path is uv tool install crewai. Since May 2026 the CLI ships as its own crewai-cli package. You can also install with pip using pip install crewai, or pip install 'crewai[tools]' to include the tools package. The framework is free under the MIT licence. Your model provider and any search API bill you directly.
Step 2: Scaffold your crew project
Run crewai create crew my_research_crew. The command asks for a provider, a model, and an API key, then writes them to the project's .env file. New projects are JSON-first. Each agent gets its own file in agents/*.jsonc. Tasks and crew-level settings live in crew.jsonc. If you prefer the older Python and YAML layout, with crew.py and config/agents.yaml plus config/tasks.yaml, run the same command with --classic. The scaffold also creates main.py and folders for custom tools and knowledge files. Move into the project folder with cd my_research_crew.
Step 3: Set your API keys
Open the .env file in the project root. Set your language model key, for example OPENAI_API_KEY. The default model is an OpenAI model, so the default path assumes an OpenAI key. If you use another provider, set the key that provider needs. The official tutorials also need a Serper.dev key for web search, stored as SERPER_API_KEY. Keep the .env file out of version control. Never commit API keys to a shared repository.
Step 4: Define your agents
Each agent needs three things: a role, a goal, and a backstory. The role says what the agent is. The goal says what it is trying to achieve. The backstory shapes its tone and domain expertise. Here is a researcher agent in the JSON-first format. The writer agent follows the same shape.
{
"role": "Senior Research Analyst",
"goal": "Find accurate, recent information on the assigned topic",
"backstory": "You are an experienced research analyst who checks claims against references before reporting them."
}Give the researcher a search tool so it can reach the web. Give the writer no search tool. That keeps the writer focused on turning research into a report. Set allow_delegation to false on worker agents when you want fixed task assignments. By default, delegation is on when a crew has multiple agents.
Step 5: Define your tasks
Each task needs a description, an expected output, and an assigned agent. The description says what to do. The expected output says what a finished answer looks like. Be specific here. Vague expected outputs produce vague reports. For this crew, the research task asks for a list of findings with source URLs. The writing task asks for a structured Markdown report with sections and a short summary. In sequential mode, the research output passes automatically as context into the writing task.
{
"description": "Research recent developments in multi-agent frameworks and list the key findings with source URLs.",
"expected_output": "A bullet list of findings, each with a source URL and a one-line summary.",
"agent": "researcher"
}Step 6: Assemble the crew and run it
The Crew object brings agents and tasks together and runs them. In the classic Python layout it looks like this.
from crewai import Agent, Task, Crew, Process
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, write_task],
process=Process.sequential,
verbose=True
)
result = crew.kickoff()Before the first run, install dependencies with crewai install. Then run the crew with crewai run from the project folder. Use verbose=True while you are learning. It shows each agent's reasoning and tool calls. When the run finishes, kickoff() returns the final output. Save it to a file or print it. If a task fails, read the verbose log. Most first-run failures are missing keys or a wrong model name.
Step 7: Add memory and tools
Once the basic crew works, add two upgrades. First, enable memory with memory=True on the Crew. CrewAI maintains short-term, long-term, and entity memory layers. That helps crews that run repeatedly on related topics. Second, add tools. The crewai-tools package includes search, file reading, and web scraping tools. You can also write custom tools with the @tool decorator. Give each agent only the tools it needs. Extra tools invite extra mistakes.
| Choice | Use it when | Trade-off |
|---|---|---|
| Sequential process | Tasks have a fixed order | No dynamic replanning |
| Hierarchical process | Tasks need a manager to delegate | More model calls, higher cost |
| Memory on | Crews run repeatedly | Stale memory can mislead later runs |
| JSON-first project | Starting a new crew | Less code control than Python |
| Classic YAML project | You want full Python control | More files to maintain |
Common mistakes
The most common mistake is skipping the expected output. Without it, the model guesses what good looks like. The second is giving every agent every tool. Tools are how agents make mistakes, so limit them. The third is running a hierarchical crew for a simple job. Sequential is cheaper and easier to debug. The fourth is forgetting crewai install before crewai run. Dependencies must be locked and installed first. The fifth is treating the crew as a product before it is a script. Test with one topic, read the full verbose log, and fix the prompts before you scale up.
Bottom line
A working CrewAI crew needs four things: a Python version in the supported range, the CLI installed through uv, two API keys in .env, and clear agents and tasks. Start sequential, start small, and read the verbose log. Once the two-agent research crew runs cleanly, add a third agent or a Flow for branching logic. The framework handles orchestration. Your job is writing good roles, goals, and expected outputs.