> ## Documentation Index
> Fetch the complete documentation index at: https://inference-docs.cerebras.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Started with CrewAI

> Learn how to build and orchestrate multi-agent AI workflows using CrewAI with Cerebras's ultra-fast inference for real-time agentic applications.

## 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](https://docs.crewai.com/?utm_source=3pi_crewai\&utm_campaign=partner_doc).

## Prerequisites

Before you begin, ensure you have:

* **Cerebras API Key** - Get a free API key [here](https://cloud.cerebras.ai/?utm_source=3pi_crewai\&utm_campaign=partner_doc)
* **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

<Steps>
  <Step title="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.

    ```bash theme={null}
    pip install crewai crewai-tools openai python-dotenv litellm
    ```

    <Note>
      The `python-dotenv` package helps manage environment variables securely.
    </Note>

    <Tip>
      To disable CrewAI's telemetry (which may show 404 errors), add `CREWAI_TELEMETRY_OPT_OUT=true` to your `.env` file.
    </Tip>
  </Step>

  <Step title="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.

    ```bash theme={null}
    CEREBRAS_API_KEY=your-cerebras-api-key-here
    OPENAI_API_BASE=https://api.cerebras.ai/v1
    OPENAI_MODEL_NAME=gpt-oss-120b
    ```

    The `OPENAI_API_BASE` variable redirects all OpenAI SDK calls to Cerebras, and `OPENAI_MODEL_NAME` sets your default model for all agents.
  </Step>

  <Step title="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.

    ```python theme={null}
    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",
        default_headers={"X-Cerebras-3rd-Party-Integration": "crewai"}
    )

    # 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/gpt-oss-120b"
    )

    # 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 `gpt-oss-120b` model for fast, high-quality responses.
  </Step>

  <Step title="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.

    ```python theme={null}
    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",
        default_headers={"X-Cerebras-3rd-Party-Integration": "crewai"}
    )

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

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

    # 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.
  </Step>

  <Step title="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.

    ```bash theme={null}
    # 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/gpt-oss-120b` or `cerebras/zai-glm-4.7`
    4. Update `src/my_agent_team/main.py` to initialize the Cerebras client with the integration header

    <Note>
      When prompted for a model provider during project creation, you can select OpenAI-compatible and then configure Cerebras in your environment variables.
    </Note>
  </Step>

  <Step title="Enable memory and context">
    CrewAI supports agent memory for maintaining context across tasks, making your agents more intelligent and context-aware over time.

    ```python theme={null}
    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",
        default_headers={"X-Cerebras-3rd-Party-Integration": "crewai"}
    )

    # Create agent with memory enabled
    helper = Agent(
        role="Helper",
        goal="Answer questions helpfully",
        backstory="A helpful assistant with good memory",
        llm="cerebras/gpt-oss-120b",
        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.
  </Step>
</Steps>

## 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.

```python theme={null}
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",
    default_headers={"X-Cerebras-3rd-Party-Integration": "crewai"}
)

# Use the most capable model for complex reasoning
strategist = Agent(
    role="Strategist",
    goal="Provide strategic advice",
    backstory="Expert strategist",
    llm="cerebras/gpt-oss-120b",
    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.

```python theme={null}
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",
    default_headers={"X-Cerebras-3rd-Party-Integration": "crewai"}
)

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

# Junior agent
junior = Agent(
    role="Junior",
    goal="Help with tasks",
    backstory="Eager helper",
    llm="cerebras/gpt-oss-120b",
    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.

```python theme={null}
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",
    default_headers={"X-Cerebras-3rd-Party-Integration": "crewai"}
)

# Create agent (tools like SerperDevTool require API keys)
researcher = Agent(
    role="Researcher",
    goal="Answer questions accurately",
    backstory="Expert researcher",
    llm="cerebras/gpt-oss-120b",
    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](https://docs.crewai.com/core-concepts/Tools/?utm_source=3pi_crewai\&utm_campaign=partner_doc).

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="How do I choose the right Cerebras model for my agents?">
    Choose models based on task complexity and performance requirements:

    * **cerebras/gpt-oss-120b** - Largest model for the most demanding tasks
    * **cerebras/zai-glm-4.7** - Advanced 357B parameter model with strong reasoning capabilities

    You can mix and match models within the same crew to optimize for both quality and speed.
  </Accordion>

  <Accordion title="Can I use CrewAI with streaming responses?">
    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.
  </Accordion>

  <Accordion title="How does agent memory work with Cerebras?">
    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.
  </Accordion>

  <Accordion title="What's the difference between sequential and hierarchical processes?">
    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.

    ```python theme={null}
    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="gpt-oss-120b")
    ```
  </Accordion>

  <Accordion title="How do I handle errors and retries in CrewAI?">
    CrewAI provides built-in error handling and retry mechanisms. You can configure max retries and error handling at the task level:

    ```python theme={null}
    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.
  </Accordion>
</AccordionGroup>

## Next Steps

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

* **Explore examples** - Check out [CrewAI example projects on GitHub](https://github.com/joaomdmoura/crewAI-examples?utm_source=3pi_crewai\&utm_campaign=partner_doc) including sales pipelines, research assistants, and travel planners
* **Learn advanced features** - Read the [CrewAI official documentation](https://docs.crewai.com/?utm_source=3pi_crewai\&utm_campaign=partner_doc) for in-depth guides on memory, tools, and processes
* **Optimize performance** - Try different [Cerebras models](/models) to find the best balance of speed and capability for your use case
* **Join the community** - Connect with other developers in the [CrewAI Discord community](https://discord.com/invite/X4JWnZnxPb?utm_source=3pi_crewai\&utm_campaign=partner_doc) for support and inspiration
* **Extend capabilities** - Explore [CrewAI Tools](https://docs.crewai.com/core-concepts/Tools/?utm_source=3pi_crewai\&utm_campaign=partner_doc) to give your agents access to web search, file operations, and more
* **Build production apps** - Learn about [deployment best practices](https://docs.crewai.com/how-to/deployment/?utm_source=3pi_crewai\&utm_campaign=partner_doc) for taking your agents to production
* **Use the latest model `zai-glm-4.7`** - [GLM4.7 migration guide](https://inference-docs.cerebras.ai/resources/glm-47-migration?utm_source=3pi_crewai\&utm_campaign=partner_doc)
