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

# CrewAI

> Auto-instrument CrewAI multi-agent collaborative workflows

Automatically capture agent roles, tasks, crew executions, and tool invocations within the CrewAI framework.

## Install

> [tab] Python
>
> ```bash theme={null}
> pip install traceroot crewai
> ```

## Set up

> [tab] Python
>
> ```python theme={null}
> import traceroot
> from traceroot import Integration
>
> traceroot.initialize(integrations=[Integration.CREWAI, Integration.OPENAI])
> ```

## Usage

Once initialized, crew and agent executions are captured automatically:

```python theme={null}
from crewai import Agent, Task, Crew

researcher = Agent(
    role="Research Analyst",
    goal="Uncover the latest developments in AI agent frameworks",
    backstory="You are an expert at identifying emerging trends in AI.",
)

writer = Agent(
    role="Tech Writer",
    goal="Craft a compelling summary of AI agent framework trends",
    backstory="You turn complex technical insights into engaging narratives.",
)

research_task = Task(
    description="Analyze the latest AI agent frameworks and summarize key trends.",
    expected_output="A concise research summary",
    agent=researcher,
)

write_task = Task(
    description="Write a short article based on the research summary.",
    expected_output="A short article on AI agent framework trends",
    agent=writer,
    context=[research_task],
)

crew = Crew(agents=[researcher, writer], tasks=[research_task, write_task])

# The entire crew execution is automatically traced
result = crew.kickoff()
```

## Verify

Run your code and confirm the trace arrives:

1. **In the traceroot UI**: Navigate to **Tracing > Traces** in [traceroot Cloud](https://app.traceroot.ai). You should see a trace with root span `Crew_<id>.kickoff`; naming the crew with `Crew(name=...)` uses that name instead.
2. **Via the CLI**: Run `traceroot traces list` to inspect your recent traces from the terminal.

## What gets captured

| Attribute | Description |
| - | - |
| Crew execution | The overarching `kickoff()` session |
| Agent roles | Each agent's role, goal, and backstory as span metadata |
| Task steps | Individual task executions with inputs and outputs |
| Tool calls | Tool invocations with input arguments and results |
| LLM calls | Raw completion requests to the provider |
| Delegation hierarchy | Manager-agent relationships and task assignments |
| Token usage | Aggregated across all LLM calls |
| Cost | Aggregated when the underlying model IDs match traceroot's pricing table |

## Limitations

* CrewAI delegates LLM generation to underlying providers (e.g., OpenAI, Anthropic). Initializing your provider integration (such as `Integration.OPENAI`) alongside CrewAI is recommended for accurate token usage and cost calculation.

## Run the example

Clone the repo and run a complete agent end-to-end.

> [card] [Python](https://github.com/traceroot-ai/traceroot/tree/main/examples/python/crewai-agent)
>
> Run the Python example

## Next steps

> [card] [Python SDK Reference](https://traceroot.ai/docs/tracing/python-sdk.md)
>
> Explore the full Python SDK reference and instrumentation options.

> [card] [Cost Tracking](https://traceroot.ai/docs/tracing/cost-tracking.md)
>
> Learn how traceroot calculates token costs and tracks model spend.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.