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

# CrewAI

> Capture traces from CrewAI crews with OpenLit

OpenLit is the recommended path: it auto-instruments CrewAI plus the underlying LLM provider.

<Note>
  CrewAI/OpenLit traces can include prompts, completions, tool inputs, and tool outputs. Review [Data Governance](/data-governance) before enabling production traffic.
</Note>

## Install

```bash theme={null}
pip install crewai openlit
```

## Setup

```python theme={null}
import os, openlit
from crewai import Agent, Crew, Task
from openinference.instrumentation import using_attributes

os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://otel.agnost.ai"
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = "X-Agnost-Org-ID=<your-org-id>"

openlit.init(application_name="my-crew", environment="production")

with using_attributes(session_id="sess-123", user_id="u-42"):
    Crew(agents=[...], tasks=[...]).kickoff()
```

Spans use OTel GenAI semconv (`gen_ai.prompt.{n}.content`, `gen_ai.completion.{n}.content`, `gen_ai.usage.*`) plus `gen_ai.agent.name` and `gen_ai.operation.name` on agent/task spans.

## Caveats

* Call `openlit.init()` before constructing any `Crew` / `Agent` objects.
* CrewAI's own anonymized telemetry (sent to CrewAI's servers) is unrelated and can be left enabled.

## Verify

Run one `Crew(...).kickoff()` call, then open **Raw logs** in Agnost. Confirm CrewAI and provider spans are present.

## Troubleshooting

* Call `openlit.init()` before constructing crews or agents.
* Confirm `OTEL_EXPORTER_OTLP_HEADERS` contains `X-Agnost-Org-ID=<your-org-id>`.
* Wrap runs with `using_attributes` if you need explicit user/session grouping.

## References

* [Enable OpenTelemetry export](https://docs.crewai.com/en/observability/openlit)
* [Add custom metadata](https://docs.crewai.com/en/api-reference/kickoff)
