CrewAI is the easiest way to build a team of AI agents that work together — a researcher that searches, a writer that drafts, an editor that polishes. It’s a lean Python framework (independent of LangChain) and in 2026 it’s one of the most popular multi-agent frameworks in production, with its 1.x line stable since late 2025. This tutorial builds a working three-agent content crew from scratch.
📋 In This Tutorial
Core Concepts

Four building blocks: an Agent has a role, goal and backstory (this shapes its behavior more than you’d think); a Task is a unit of work assigned to an agent; Tools give agents abilities (search, files, code); and the Crew wires it together with a process — sequential (pipeline) or hierarchical (a manager agent delegates).
Install & Setup
pip install crewai crewai-tools
export ANTHROPIC_API_KEY="sk-ant-..."
export SERPER_API_KEY="..." # free tier at serper.dev for web searchDefine Your Agents
from crewai import Agent, Task, Crew, Process, LLM
from crewai_tools import SerperDevTool
llm = LLM(model="anthropic/claude-sonnet-5", temperature=0.3)
search = SerperDevTool()
researcher = Agent(
role="AI News Researcher",
goal="Find accurate, current facts about {topic}",
backstory="A meticulous tech journalist who always verifies claims from multiple sources.",
tools=[search], llm=llm, verbose=True,
)
writer = Agent(
role="Tech Blog Writer",
goal="Write a clear, engaging 600-word article about {topic}",
backstory="A developer-turned-writer who explains complex topics simply without dumbing them down.",
llm=llm,
)
editor = Agent(
role="Editor",
goal="Polish the draft: fix flow, cut fluff, verify claims match research",
backstory="A ruthless editor who deletes every sentence that doesn't earn its place.",
llm=llm,
)Define Tasks
research_task = Task(
description="Research {topic}. Collect 5-7 key facts with dates and numbers.",
expected_output="A bullet list of verified facts with source URLs.",
agent=researcher,
)
write_task = Task(
description="Using the research, write a 600-word blog article about {topic}.",
expected_output="A structured article with headline, intro, 3 sections, conclusion.",
agent=writer, context=[research_task],
)
edit_task = Task(
description="Edit the draft for clarity and accuracy against the research.",
expected_output="The final publication-ready article.",
agent=editor, context=[research_task, write_task],
)Assemble and Run
crew = Crew(
agents=[researcher, writer, editor],
tasks=[research_task, write_task, edit_task],
process=Process.sequential,
)
result = crew.kickoff(inputs={"topic": "open-weight LLMs in 2026"})
print(result.raw)That’s a complete multi-agent pipeline: the researcher searches the web, the writer drafts from the research, the editor polishes with both as context.
Crews vs Flows
CrewAI also ships Flows — event-driven, precise orchestration where you control each step programmatically (with state, branching, and human checkpoints). Rule of thumb: use a Crew when you want autonomous collaboration; use a Flow when the sequence must be deterministic (billing pipelines, approval chains), and embed crews inside flows for the creative middle parts.
Production Tips
⚠️ Learn From Everyone’s Mistakes
- Backstories matter — they’re not decoration; specific personas measurably change output quality.
- Set
max_iterand timeouts — agent loops can spiral; bound them. - expected_output is your contract — vague expectations produce vague results.
- Watch token costs — three agents with search can burn 50k+ tokens per run; use a value-tier model (Sonnet/Haiku) unless quality demands more.
Sources & further reading: CrewAI docs · GitHub · Serper (search API). Tested on the CrewAI 1.x line (current: 1.14).





Leave a reply
Your email address will not be published. Required fields are marked *