What is CrewAI?
CrewAI is an open-source Python framework for orchestrating role-playing, autonomous AI agents. Instead of asking one LLM to do everything, you compose a "crew" of specialized agents — each with its own role, goals, and tools — that collaborate to complete a complex task.
Think of it like running a small team: a researcher gathers information, a writer drafts an article, an editor polishes it. Each agent does what it's good at, and the framework handles the handoffs.
How a crew actually runs
At runtime CrewAI treats your agents as callable workers, your tasks as typed prompts with acceptance criteria, and your crew as the scheduler that decides order, context handoff, and retries. A process (usually sequential) fixes the execution graph so you are not hand-writing state machines for every pipeline. Tools attach per agent, so each worker only sees the integrations it needs, which keeps tool-choice errors lower than dumping every capability into one mega-prompt.
Under the hood CrewAI leans on the same LLM and tool ecosystem you may already know from LangChain: you configure providers and keys once, then focus on roles, goals, and task contracts. That split is why teams adopt it for repeatable "human org chart" workflows—research, drafting, QA, triage—where the hard part is crisp handoffs, not exotic graph topology. When you need decorator-driven branching, fan-in, or long-lived state machines, CrewAI Flows layer on top; this series starts with crews so the mental model stays small.
The next pages cover core concepts in depth and walk through a full runnable crew on the first crew lesson; use installation and setup if you still need a virtualenv and API keys.
Runnable preview
These snippets are intentionally short so you can see the whole shape before you copy a longer script later in the series. They assume crewai is installed and your provider credentials are loaded (for example via python-dotenv).
Single-agent crew (copy-paste runnable)
from crewai import Agent, Task, Crew, Process
researcher = Agent(
role="Research Analyst",
goal="Collect verifiable facts about {topic}",
backstory="You prefer citations and short bullets over prose.",
verbose=True,
)
brief = Task(
description="List five factual bullets about {topic} with a one-line source hint each.",
expected_output="Markdown bullet list with five entries.",
agent=researcher,
)
crew = Crew(
agents=[researcher],
tasks=[brief],
process=Process.sequential,
verbose=True,
)
result = crew.kickoff(inputs={"topic": "retrieval-augmented generation"})
print(result)
Two agents with task context (still one file)
from crewai import Agent, Task, Crew, Process
researcher = Agent(
role="Research Analyst",
goal="Capture five crisp facts about {topic}",
backstory="You trade depth for clarity and never exceed five bullets.",
verbose=True,
allow_delegation=False,
)
writer = Agent(
role="Tech Writer",
goal="Turn notes into a 120-word paragraph about {topic}",
backstory="You write for busy engineering leads. No hype.",
verbose=True,
allow_delegation=False,
)
research_task = Task(
description="Research {topic}. Output five bullets with a short source hint per bullet.",
expected_output="Markdown bullet list.",
agent=researcher,
)
writing_task = Task(
description="Using the research bullets, write one tight paragraph (~120 words) on {topic}.",
expected_output="Plain paragraph prose.",
agent=writer,
context=[research_task],
)
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
process=Process.sequential,
verbose=True,
)
print(crew.kickoff(inputs={"topic": "vector databases"}))
Expand this pattern with a second agent and a dependent task in Your First Crew; add tools and memory once the baseline run is stable.
Why Multi-Agent Systems Matter
Single-agent LLM apps hit a ceiling fast. Multi-agent systems break through it for three reasons:
🎯 Specialization beats generalization
A focused researcher prompt outperforms a "do everything" prompt. Splitting roles lets each agent excel at one thing.
🧩 Decomposition = better quality
Complex tasks split into smaller sub-tasks produce more reliable, reviewable outputs than one giant chain-of-thought.
🛠️ Tool-use becomes manageable
Each agent owns a small toolset. No more 30-tool prompts where the model picks the wrong one.
CrewAI vs LangChain vs AutoGen
CrewAI lives in a crowded space. Here's where it fits:
LangChain / LangGraph
Strength: Massive ecosystem, fine-grained graph control, huge tool library.
Weakness: Steep learning curve. Boilerplate-heavy. Multi-agent feels bolted on.
✓ Best for: Custom workflows where you want to wire every edge yourself.
AutoGen (Microsoft)
Strength: Strong conversational multi-agent patterns. Good for chat-style coordination.
Weakness: Less opinionated. Heavier setup for simple sequential pipelines.
✓ Best for: Research-style agent dialogues, code-execution loops.
CrewAI ⭐ Role-First, Opinionated
Strength: Dead-simple mental model (Agents + Tasks + Crew). Production-ready defaults. Fast prototyping.
Weakness: Less flexible than raw LangGraph for highly custom flows.
✓ Best for: Role-based pipelines (research, content, support, ops) you want shipping in days, not months.
💡 Pro tip: CrewAI is built on top of LangChain — so you get its tool ecosystem for free, with a much cleaner agent abstraction on top.
Real-World Use Cases
Research & Analysis Crews
Researcher gathers sources, analyst synthesizes, writer produces a brief. Replace hours of manual work.
Content Factories
Topic researcher → outliner → writer → SEO editor. Scale long-form content without sacrificing quality.
Customer Support Triage
Classifier routes the ticket, KB-search agent finds answers, drafter composes a response, escalator hands off when stuck.
Sales SDR Automation
Lead-researcher profiles prospects, copywriter drafts personalized outreach, scheduler proposes meeting slots.
Code Review & PR Bots
Reader summarizes the diff, security agent scans for vulns, style agent flags conventions, reviewer posts the comment.
Prerequisites
- Python 3.10+ and basic Python knowledge (functions, classes, virtual envs)
- Familiarity with calling an LLM API (OpenAI, Anthropic, or any local model) — our AI Agents tutorial covers the fundamentals
- Comfort reading a stack trace and editing a YAML/JSON config
- For hands-on examples: an OpenAI API key, or Ollama running locally
Note: Pages 1–4 are intro + setup. From Page 5 onward you'll be writing real CrewAI code, so make sure your environment is ready.
What you will learn
- The CrewAI mental model: Agents, Tasks, Crews, Tools, and Processes
- How to define agents with strong roles, goals, and backstories that actually steer behavior
- Building tasks with clear descriptions, expected outputs, and context passing
- Using built-in tools (web search, scraping, file I/O) and writing custom
@toolfunctions - Sequential vs Hierarchical processes — and when to use each
- Memory: short-term, long-term, and entity-level persistence across runs
- Production patterns: deployment, observability, debugging, cost control
- Five real-world crews you can adapt for your own projects
Series overview
Introduction ← You are here
What CrewAI is, why multi-agent matters, comparisons, and series roadmap.
Core Concepts
Agents, Tasks, Crews, Tools, and Processes — the building blocks of any CrewAI app.
Installation & Setup
Install CrewAI, configure environment variables, and verify your setup with a hello world.
Your First Crew
Build a working two-agent crew end to end. Researcher + writer collaborating on a topic.
Defining Agents
Roles, goals, backstories, verbose mode, allow_delegation, max_iter, and agent personalities.
Creating Tasks
Task descriptions, expected outputs, context passing, async execution, and output formats.
When Should You Use CrewAI?
Reach for CrewAI when you have:
Skip CrewAI if: You have a single-step prompt (just call the LLM directly), need ultra-low-latency single-agent inference, or require a fully deterministic non-LLM workflow engine.
What You'll Learn in This Tutorial
📚 Part 1: Foundations (Pages 1-4)
Concepts, installation, and your first working crew.
🔨 Part 2: Building Blocks (Pages 5-8)
Agents, tasks, tools, and process types in depth.
🧠 Part 3: Coordination (Pages 9-11)
Memory, multi-agent collaboration, and LLM provider integration.
🚀 Part 4: Production (Pages 12-14)
Deployment, debugging, observability, and pitfalls to avoid.
⭐ Part 5: Real Crews (Page 15)
Five complete reference implementations you can fork.
CrewAI introduction FAQ
What is CrewAI used for?
CrewAI is a Python framework for building multi-agent workflows: you define specialized agents, tasks, and a crew process so LLM workers collaborate on research, writing, coding, or operations instead of one monolithic prompt.
Is CrewAI free and open source?
Yes. CrewAI is open source under a permissive license with a free self-hosted path; hosted or enterprise offerings may add paid features, but local development and most library capabilities are available without a subscription.
How does CrewAI differ from LangGraph?
CrewAI optimizes for role-shaped crews, handoffs, and batteries-included agent ergonomics, while LangGraph centers arbitrary state machines and graph edges. Choose CrewAI when your problem maps to agents and tasks; choose LangGraph when you need maximal control over graph topology.
Can I run CrewAI with OpenAI and Anthropic models?
Yes. CrewAI integrates with common LLM providers through the same ecosystem patterns you use elsewhere: configure API keys, pick models per agent, and route cheaper models to simple tasks while reserving frontier models for complex reasoning.
Where should I start after this introduction?
Follow the series in order: core concepts, installation, then your first crew. Skim the CrewAI tool review on DevShelfHub if you want a product-level comparison before you commit engineering time.