CrewAI: Production-grade framework for orchestrating sophisticated AI agent systems. From simple automations to complex real-world applications, CrewAI provides precise control and deep customization. By fostering collaborative intelligence through flexible, production-ready architecture, CrewAI empowers agents to work together seamlessly, tackling complex business challenges with predictable, consistent results.
CrewAI Enterprise
Want to plan, build (+ no code), deploy, monitor and interare your agents: CrewAI Enterprise. Designed for complex, real-world applications, our enterprise solution offers:
- Seamless Integrations
- Scalable & Secure Deployment
- Actionable Insights
- 24/7 Support
- Why CrewAI?
- Getting Started
- Key Features
- Understanding Flows and Crews
- CrewAI vs LangGraph
- Examples
- Connecting Your Crew to a Model
- How CrewAI Compares
- Frequently Asked Questions (FAQ)
- Contribution
- Telemetry
- License
The power of AI collaboration has too much to offer.
CrewAI is a standalone framework, built from the ground up without dependencies on Langchain or other agent frameworks. It’s designed to enable AI agents to assume roles, share goals, and operate in a cohesive unit – much like a well-oiled crew. Whether you’re building a smart assistant platform, an automated customer service ensemble, or a multi-agent research team, CrewAI provides the backbone for sophisticated multi-agent interactions.
Learn CrewAI through our comprehensive courses:
- Multi AI Agent Systems with CrewAI – Master the fundamentals of multi-agent systems
- Practical Multi AI Agents and Advanced Use Cases – Deep dive into advanced implementations
CrewAI offers two powerful, complementary approaches that work seamlessly together to build sophisticated AI applications:
-
Crews: Teams of AI agents with true autonomy and agency, working together to accomplish complex tasks through role-based collaboration. Crews enable:
- Natural, autonomous decision-making between agents
- Dynamic task delegation and collaboration
- Specialized roles with defined goals and expertise
- Flexible problem-solving approaches
-
Flows: Production-ready, event-driven workflows that deliver precise control over complex automations. Flows provide:
- Fine-grained control over execution paths for real-world scenarios
- Secure, consistent state management between tasks
- Clean integration of AI agents with production Python code
- Conditional branching for complex business logic
The true power of CrewAI emerges when combining Crews and Flows. This synergy allows you to:
- Build complex, production-grade applications
- Balance autonomy with precise control
- Handle sophisticated real-world scenarios
- Maintain clean, maintainable code structure
To get started with CrewAI, follow these simple steps:
Ensure you have Python >=3.10 <3.13 installed on your system. CrewAI uses UV for dependency management and package handling, offering a seamless setup and execution experience.
First, install CrewAI:
If you want to install the ‘crewai’ package along with its optional features that include additional tools for agents, you can do so by using the following command:
pip install 'crewai[tools]'
The command above installs the basic package and also adds extra components which require more dependencies to function.
If you encounter issues during installation or usage, here are some common solutions:
-
ModuleNotFoundError: No module named ‘tiktoken’
- Install tiktoken explicitly:
pip install 'crewai[embeddings]'
- If using embedchain or other tools:
pip install 'crewai[tools]'
- Install tiktoken explicitly:
-
Failed building wheel for tiktoken
- Ensure Rust compiler is installed (see installation steps above)
- For Windows: Verify Visual C++ Build Tools are installed
- Try upgrading pip:
pip install --upgrade pip
- If issues persist, use a pre-built wheel:
pip install tiktoken --prefer-binary
To create a new CrewAI project, run the following CLI (Command Line Interface) command:
my_project/
├── .gitignore
├── pyproject.toml
├── README.md
├── .env
└── src/
└── my_project/
├── __init__.py
├── main.py
├── crew.py
├── tools/
│ ├── custom_tool.py
│ └── __init__.py
└── config/
├── agents.yaml
└── tasks.yaml
You can now start developing your crew by editing the files in the src/my_project
folder. The main.py
file is the entry point of the project, the crew.py
file is where you define your crew, the agents.yaml
file is where you define your agents, and the tasks.yaml
file is where you define your tasks.
- Modify
src/my_project/config/agents.yaml
to define your agents. - Modify
src/my_project/config/tasks.yaml
to define your tasks. - Modify
src/my_project/crew.py
to add your own logic, tools, and specific arguments. - Modify
src/my_project/main.py
to add custom inputs for your agents and tasks. - Add your environment variables into the
.env
file.
Instantiate your crew:
crewai create crew latest-ai-development
Modify the files as needed to fit your use case:
agents.yaml
return Agent(
config=self.agents_config[‘researcher’],
verbose=True,
tools=[SerperDevTool()]
)
@agent
def reporting_analyst(self) -> Agent:
return Agent(
config=self.agents_config[‘reporting_analyst’],
verbose=True
)
@task
def research_task(self) -> Task:
return Task(
config=self.tasks_config[‘research_task’],
)
@task
def reporting_task(self) -> Task:
return Task(
config=self.tasks_config[‘reporting_task’],
output_file=’report.md’
)
@crew
def crew(self) -> Crew:
“””Creates the LatestAiDevelopment crew”””
return Crew(
agents=self.agents, # Automatically created by the @agent decorator
tasks=self.tasks, # Automatically created by the @task decorator
process=Process.sequential,
verbose=True,
)” dir=”auto”>
# src/my_project/crew.py from crewai import Agent, Crew, Process, Task from crewai.project import CrewBase, agent, crew, task from crewai_tools import SerperDevTool @CrewBase class LatestAiDevelopmentCrew(): """LatestAiDevelopment crew""" @agent def researcher(self) -> Agent: return Agent( config=self.agents_config['researcher'], verbose=True, tools=[SerperDevTool()] ) @agent def reporting_analyst(self) -> Agent: return Agent( config=self.agents_config['reporting_analyst'], verbose=True ) @task def research_task(self) -> Task: return Task( config=self.tasks_config['research_task'], ) @task def reporting_task(self) -> Task: return Task( config=self.tasks_config['reporting_task'], output_file='report.md' ) @crew def crew(self) -> Crew: """Creates the LatestAiDevelopment crew""" return Crew( agents=self.agents, # Automatically created by the @agent decorator tasks=self.tasks, # Automatically created by the @task decorator process=Process.sequential, verbose=True, )
main.py
#!/usr/bin/env python # src/my_project/main.py import sys from latest_ai_development.crew import LatestAiDevelopmentCrew def run(): """ Run the crew. """ inputs = { 'topic': 'AI Agents' } LatestAiDevelopmentCrew().crew().kickoff(inputs=inputs)
Before running your crew, make sure you have the following keys set as environment variables in your .env
file:
- An OpenAI API key (or other LLM API key):
OPENAI_API_KEY=sk-...
- A Serper.dev API key:
SERPER_API_KEY=YOUR_KEY_HERE
Lock the dependencies and install them by using the CLI command but first, navigate to your project directory:
cd my_project
crewai install (Optional)
To run your crew, execute the following command in the root of your project:
or
python src/my_project/main.py
If an error happens due to the usage of poetry, please run the following command to update your crewai package:
You should see the output in the console and the report.md
file should be created in the root of your project with the full final report.
In addition to the sequential process, you can use the hierarchical process, which automatically assigns a manager to the defined crew to properly coordinate the planning and execution of tasks through delegation and validation of results. See more about the processes here.
Note: CrewAI is a standalone framework built from the ground up, without dependencies on Langchain or other agent frameworks.
- Deep Customization: Build sophisticated agents with full control over the system – from overriding inner prompts to accessing low-level APIs. Customize roles, goals, tools, and behaviors while maintaining clean abstractions.
- Autonomous Inter-Agent Delegation: Agents can autonomously delegate tasks and inquire amongst themselves, enabling complex problem-solving in real-world scenarios.
- Flexible Task Management: Define and customize tasks with granular control, from simple operations to complex multi-step processes.
- Production-Grade Architecture: Support for both high-level abstractions and low-level customization, with robust error handling and state management.
- Predictable Results: Ensure consistent, accurate outputs through programmatic guardrails, agent training capabilities, and flow-based execution control. See our documentation on guardrails for implementation details.
- Model Flexibility: Run your crew using OpenAI or open source models with production-ready integrations. See Connect CrewAI to LLMs for detailed configuration options.
- Event-Driven Flows: Build complex, real-world workflows with precise control over execution paths, state management, and conditional logic.
- Process Orchestration: Achieve any workflow pattern through flows – from simple sequential and hierarchical processes to complex, custom orchestration patterns with conditional branching and parallel execution.
You can test different real life examples of AI crews in the CrewAI-examples repo:
Check out code for this example or watch a video below:
Check out code for this example or watch a video below:
Check out code for this example or watch a video below:
CrewAI’s power truly shines when combining Crews with Flows to create sophisticated automation pipelines. Here’s how you can orchestrate multiple Crews within a Flow:
return “high_confidence”
elif self.state.confidence > 0.5:
return “medium_confidence”
return “low_confidence”
@listen(“high_confidence”)
def execute_strategy(self):
# Demonstrate complex decision making
strategy_crew = Crew(
agents=[
Agent(role=”Strategy Expert”,
goal=”Develop optimal market strategy”)
],
tasks=[
Task(description=”Create detailed strategy based on analysis”,
expected_output=”Step-by-step action plan”)
]
)
return strategy_crew.kickoff()
@listen(“medium_confidence”, “low_confidence”)
def request_additional_analysis(self):
self.state.recommendations.append(“Gather more data”)
return “Additional analysis required”” dir=”auto”>
from crewai.flow.flow import Flow, listen, start, router from crewai import Crew, Agent, Task from pydantic import BaseModel # Define structured state for precise control class MarketState(BaseModel): sentiment: str = "neutral" confidence: float = 0.0 recommendations: list = [] class AdvancedAnalysisFlow(Flow[MarketState]): @start() def fetch_market_data(self): # Demonstrate low-level control with structured state self.state.sentiment = "analyzing" return {"sector": "tech", "timeframe": "1W"} # These parameters match the task description template @listen(fetch_market_data) def analyze_with_crew(self, market_data): # Show crew agency through specialized roles