Skip to main content

What is CrewAI?

CrewAI is an open-source platform designed to orchestrate workflows of complex AI agents, enabling task automation and collaborative decision-making. With CrewAI, you can create teams of AI agents that work together to accomplish sophisticated tasks, from research and content creation to sales pipelines and travel planning. By integrating Cerebras’s ultra-fast inference, your CrewAI agents can process information and make decisions with exceptional speed, making real-time agentic workflows more practical and cost-effective. Learn more at CrewAI’s official documentation.

Prerequisites

Before you begin, ensure you have:
  • Cerebras API Key - Get a free API key here
  • Python 3.10 or higher - CrewAI requires Python 3.10+. Verify your version with python --version
  • Basic understanding of AI agents - Familiarity with agent concepts is helpful but not required

Configure CrewAI with Cerebras

1

Install required dependencies

Install CrewAI and the OpenAI SDK. CrewAI uses the OpenAI SDK under the hood, which makes it compatible with Cerebras’s OpenAI-compatible API.
pip install crewai crewai-tools openai python-dotenv litellm
The python-dotenv package helps manage environment variables securely.
To disable CrewAI’s telemetry (which may show 404 errors), add CREWAI_TELEMETRY_OPT_OUT=true to your .env file.
2

Configure environment variables

Create a .env file in your project directory with your Cerebras API key. This tells CrewAI to use Cerebras’s API endpoint and sets your default model.
CEREBRAS_API_KEY=your-cerebras-api-key-here
OPENAI_API_BASE=https://api.cerebras.ai/v1
OPENAI_MODEL_NAME=llama-3.3-70b
The OPENAI_API_BASE variable redirects all OpenAI SDK calls to Cerebras, and OPENAI_MODEL_NAME sets your default model for all agents.
3

Create your first agent

Let’s create a simple research agent that uses Cerebras for ultra-fast inference. This agent will gather and analyze information on any topic you provide.
import os
from dotenv import load_dotenv
from crewai import Agent, Task, Crew
from openai import OpenAI

# Load environment variables
load_dotenv()

# Initialize Cerebras client with integration tracking
client = OpenAI(
    api_key=os.getenv("CEREBRAS_API_KEY"),
    base_url="https://api.cerebras.ai/v1"
)

# Create a math agent
mathematician = Agent(
    role="Mathematician",
    goal="Solve math problems accurately",
    backstory="You are an expert mathematician who solves problems step by step.",
    verbose=False,
    allow_delegation=False,
    llm="cerebras/llama-3.3-70b"
)

# Define a simple math task
math_task = Task(
    description="Calculate 15 * 15 and explain your reasoning briefly.",
    expected_output="The answer with a brief explanation",
    agent=mathematician
)

# Create and run the crew
crew = Crew(
    agents=[mathematician],
    tasks=[math_task],
    verbose=False
)

# Execute the workflow
result = crew.kickoff()
print(result)
This example creates a single agent that performs research tasks using Cerebras’s llama-3.3-70b model for fast, high-quality responses.
4

Build a multi-agent workflow

CrewAI’s real power comes from orchestrating multiple agents working together. Here’s a content creation pipeline with three specialized agents that collaborate sequentially.
import os
from dotenv import load_dotenv
from crewai import Agent, Task, Crew, Process
from openai import OpenAI

# Load environment variables
load_dotenv()

# Initialize Cerebras client with integration tracking
client = OpenAI(
    api_key=os.getenv("CEREBRAS_API_KEY"),
    base_url="https://api.cerebras.ai/v1"
)

# Create two specialized agents
researcher = Agent(
    role="Researcher",
    goal="Find key facts",
    backstory="Expert at finding information",
    verbose=False,
    llm="cerebras/llama-3.3-70b"
)

writer = Agent(
    role="Writer",
    goal="Summarize findings clearly",
    backstory="Skilled at clear communication",
    verbose=False,
    llm="cerebras/llama-3.3-70b"
)

# Define sequential tasks
research_task = Task(
    description="List 3 benefits of drinking water daily.",
    expected_output="A short list of 3 benefits",
    agent=researcher
)

summary_task = Task(
    description="Summarize the benefits in one sentence.",
    expected_output="A single summary sentence",
    agent=writer,
    context=[research_task]
)

# Create crew with sequential process
crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, summary_task],
    process=Process.sequential,
    verbose=False
)

# Execute the workflow
result = crew.kickoff()
print(result)
This example demonstrates how multiple agents collaborate in sequence, with each agent’s output feeding into the next agent’s task through the context parameter.
5

Use CrewAI CLI for project templates

CrewAI provides CLI tools to quickly scaffold new projects with best practices built in. This is the fastest way to start building production-ready agent workflows.
# Create a new crew project
crewai create crew my_agent_team

# Or create a new flow project
crewai create flow my_agent_flow
After creating your project, update the configuration to use Cerebras:
  1. Navigate to your project directory: cd my_agent_team
  2. Update the .env file with your Cerebras credentials
  3. Modify src/my_agent_team/config/agents.yaml to use Cerebras models like cerebras/llama-3.3-70b or cerebras/qwen-3-32b
  4. Update src/my_agent_team/main.py to initialize the Cerebras client with the integration header
When prompted for a model provider during project creation, you can select OpenAI-compatible and then configure Cerebras in your environment variables.
6

Enable memory and context

CrewAI supports agent memory for maintaining context across tasks, making your agents more intelligent and context-aware over time.
import os
from dotenv import load_dotenv
from crewai import Agent, Task, Crew
from openai import OpenAI

# Load environment variables
load_dotenv()

# Initialize Cerebras client
client = OpenAI(
    api_key=os.getenv("CEREBRAS_API_KEY"),
    base_url="https://api.cerebras.ai/v1"
)

# Create agent with memory enabled
helper = Agent(
    role="Helper",
    goal="Answer questions helpfully",
    backstory="A helpful assistant with good memory",
    llm="cerebras/llama-3.3-70b",
    memory=True,
    verbose=False
)

# Create a simple task
task = Task(
    description="What is the capital of France? Answer in one word.",
    expected_output="The capital city name",
    agent=helper
)

# Create crew with memory
crew = Crew(
    agents=[helper],
    tasks=[task],
    memory=True,
    verbose=False
)

# Execute
result = crew.kickoff()
print(result)
With memory enabled, agents can reference previous interactions and maintain context across multiple tasks.

Advanced Configuration

Using Different Models for Different Agents

You can assign different Cerebras models to different agents based on their tasks. Use more capable models for complex reasoning and faster models for simpler tasks to optimize cost and performance.
import os
from dotenv import load_dotenv
from crewai import Agent, Task, Crew
from openai import OpenAI

load_dotenv()

# Initialize Cerebras client
client = OpenAI(
    api_key=os.getenv("CEREBRAS_API_KEY"),
    base_url="https://api.cerebras.ai/v1"
)

# Use the most capable model for complex reasoning
strategist = Agent(
    role="Strategist",
    goal="Provide strategic advice",
    backstory="Expert strategist",
    llm="cerebras/llama-3.3-70b",
    verbose=False
)

# Simple task to demonstrate
task = Task(
    description="What is 100 divided by 4? Answer with just the number.",
    expected_output="The number",
    agent=strategist
)

crew = Crew(agents=[strategist], tasks=[task], verbose=False)
result = crew.kickoff()
print(result)

Enabling Agent Delegation

Allow agents to delegate tasks to other agents for more complex workflows. This creates a hierarchical structure where senior agents can assign work to junior agents.
import os
from dotenv import load_dotenv
from crewai import Agent, Task, Crew
from openai import OpenAI

load_dotenv()

# Initialize Cerebras client
client = OpenAI(
    api_key=os.getenv("CEREBRAS_API_KEY"),
    base_url="https://api.cerebras.ai/v1"
)

# Senior agent that can delegate
senior = Agent(
    role="Senior",
    goal="Answer questions or delegate",
    backstory="Experienced leader",
    llm="cerebras/llama-3.3-70b",
    allow_delegation=True,
    verbose=False
)

# Junior agent
junior = Agent(
    role="Junior",
    goal="Help with tasks",
    backstory="Eager helper",
    llm="cerebras/llama-3.3-70b",
    allow_delegation=False,
    verbose=False
)

# Simple task
task = Task(
    description="What is 50 + 50? Answer with just the number.",
    expected_output="The number",
    agent=senior
)

crew = Crew(agents=[senior, junior], tasks=[task], verbose=False)
result = crew.kickoff()
print(result)

Using CrewAI Tools

Extend your agents’ capabilities with CrewAI’s built-in tools for web search, file operations, and more. Tools allow agents to interact with external systems and data sources.
import os
from dotenv import load_dotenv
from crewai import Agent, Task, Crew
from openai import OpenAI

load_dotenv()

# Initialize Cerebras client
client = OpenAI(
    api_key=os.getenv("CEREBRAS_API_KEY"),
    base_url="https://api.cerebras.ai/v1"
)

# Create agent (tools like SerperDevTool require API keys)
researcher = Agent(
    role="Researcher",
    goal="Answer questions accurately",
    backstory="Expert researcher",
    llm="cerebras/llama-3.3-70b",
    verbose=False
)

# Simple task without external tools
task = Task(
    description="Name 3 programming languages. List them separated by commas.",
    expected_output="A comma-separated list",
    agent=researcher
)

crew = Crew(agents=[researcher], tasks=[task], verbose=False)
result = crew.kickoff()
print(result)
Learn more about available tools in the CrewAI Tools documentation.

Frequently Asked Questions

Choose models based on task complexity and performance requirements:
  • cerebras/llama-3.3-70b - Best for complex reasoning, long-form content, and tasks requiring deep understanding
  • cerebras/qwen-3-32b - Balanced performance for general-purpose applications
  • cerebras/llama3.1-8b - Fastest option for simple tasks and high-throughput scenarios
  • cerebras/gpt-oss-120b - Largest model for the most demanding tasks
You can mix and match models within the same crew to optimize for both quality and speed.
Yes, CrewAI supports streaming responses from Cerebras models. This is particularly useful for long-running tasks where you want to see progress in real-time. You can use crew.kickoff_async() to stream results as they’re generated.
When you enable memory in CrewAI, agents maintain context across tasks and conversations. This memory is stored locally and used to provide context to the Cerebras models during inference. The ultra-fast inference speed of Cerebras makes it practical to include extensive context without significant latency.Memory can be enabled at both the agent level and crew level for maximum flexibility.
CrewAI supports two main process types:
  • Sequential: Tasks execute one after another in order. Each task’s output can be used as context for the next task. Best for linear workflows like content creation pipelines.
  • Hierarchical: A manager agent delegates tasks to worker agents. Best for complex projects requiring coordination and dynamic task allocation.
from crewai import Crew, Process

# Sequential process (default)
# crew = Crew(agents=[agent1, agent2, agent3], tasks=[task1, task2, task3], process=Process.sequential)

# Hierarchical process with manager
# crew = Crew(agents=[manager, worker1, worker2], tasks=[task1, task2], process=Process.hierarchical, manager_llm="llama-3.3-70b")
CrewAI provides built-in error handling and retry mechanisms. You can configure max retries and error handling at the task level:
from crewai import Task

# Example task with retry logic
# task = Task(description="Research topic", expected_output="Report", agent=researcher, max_retry_limit=3)
For custom error handling, wrap your crew execution in try-except blocks.

Next Steps

Now that you’ve set up CrewAI with Cerebras, explore these resources to build more sophisticated agent workflows: