Skip to the content.

CrewAI

Information

CrewAI is a framework for orchestrating collaborative, role-based AI agents. It allows you to create teams of agents that work together to complete complex tasks, mimicking a human organization.

Main Functionalities and Features

Installation

Python (Universal)

CrewAI requires Python 3.10 to 3.13. It is recommended to use a virtual environment.

pip install crewai crewai-tools

macOS / Linux

Ensure you have Python installed. You may need to use pip3.

python3 -m venv .venv
source .venv/bin/activate
pip install crewai crewai-tools

Windows

Using PowerShell:

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install crewai crewai-tools

Setup for Developer

The fastest way to start a new CrewAI project is using the CLI.

  1. Create a new project:
    crewai create crew my_cool_crew
    
  2. Install dependencies:
    cd my_cool_crew
    crewai install
    
  3. Configure environment: Update the .env file with your LLM API keys:
    OPENAI_API_KEY=sk-...
    
  4. Run the crew:
    crewai run
    

Setup with Docker for Developer

Using Docker ensures a consistent environment for all team members.

docker-compose.yaml:

version: '3.8'
services:
  crew:
    image: python:3.11-slim
    volumes:
      - .:/app
    working_dir: /app
    environment:
      - OPENAI_API_KEY=${OPENAI_API_KEY}
    command: sh -c "pip install crewai crewai-tools && python main.py"

Usage, tips and tricks

Basic Code Example

from crewai import Agent, Task, Crew, Process

# Define Agents
researcher = Agent(
  role='Senior Research Analyst',
  goal='Uncover cutting-edge developments in AI',
  backstory='You are an expert at identifying emerging trends.'
)

writer = Agent(
  role='Content Strategist',
  goal='Write engaging technical articles',
  backstory='You specialize in simplifying complex AI topics.'
)

# Define Tasks
research_task = Task(description='Analyze 2024 AI trends', agent=researcher)
write_task = Task(description='Write a blog post based on research', agent=writer)

# Form the Crew
my_crew = Crew(
  agents=[researcher, writer],
  tasks=[research_task, write_task],
  process=Process.sequential
)

result = my_crew.kickoff()
print(result)

Tips

Similar Software

See also