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

# Trace CrewAI with BotGauge

> Trace CrewAI crews with BotGauge in code or zero-code. Python 3.10 to 3.13, verified versions, and the OpenAI producer the extra adds.

Records CrewAI runs, plus the LLM calls CrewAI makes through the OpenAI SDK.

| | |
| - | - |
| Extra | `[crewai]` |
| Verified framework versions | crewai 1.15.22 and 1.15.28 |
| Instrumentor installed by the extra | `openinference-instrumentation-crewai 1.1.21` |
| Zero-code run | Traced |

Also verified: crewai 1.15.22 with instrumentor 1.1.18. The extra no longer installs that older instrumentor. See [supported frameworks](https://www.botgauge.com/docs/integrations/overview.md) for how verification works.

## In code

Call `tracing.init()`, attach the framework instrumentor to the provider it returns, and wrap the work in `tracing.turn()` and `tracing.agent()`.

> [!NOTE]
>
> CrewAI calls its model through the OpenAI SDK, which the CrewAI instrumentor doesn't trace. The `[crewai]` extra therefore also installs the OpenAI producer, and the install line pins the tested `openai`. CrewAI 1.15 needs Python 3.10 to 3.13 and doesn't support 3.14. Set `CREWAI_DISABLE_TELEMETRY=true` to stop CrewAI's own usage telemetry.

**1. Install**

```bash terminal theme={null}
pip install "botgauge[crewai]" crewai==1.15.28 openai==2.54.0
```

**2. Add the code**

```python app.py theme={null}
import os

from botgauge import tracing
from crewai import LLM, Agent, Crew, Task
from openinference.instrumentation.crewai import CrewAIInstrumentor
from openinference.instrumentation.openai import OpenAIInstrumentor

provider = tracing.init()
CrewAIInstrumentor().instrument(tracer_provider=provider)
OpenAIInstrumentor().instrument(tracer_provider=provider)

llm = LLM(
    model=os.environ["OPENAI_MODEL"],
    base_url=os.environ["OPENAI_BASE_URL"],
    api_key=os.environ["OPENAI_API_KEY"],
)
agent = Agent(role="Assistant", goal="Answer briefly", backstory="You answer in one sentence.",
              llm=llm)
task = Task(description="In one sentence, what is OpenTelemetry?", expected_output="One sentence",
            agent=agent)

with tracing.turn(session_id="ses_crewai"), tracing.agent("crewai-agent"):
    result = Crew(agents=[agent], tasks=[task]).kickoff()
print(result)

tracing.shutdown()
```

**3. Run**

```bash terminal theme={null}
python app.py
```

Needs `BOTGAUGE_API_KEY`, `OPENAI_MODEL`, `OPENAI_BASE_URL`, `OPENAI_API_KEY`.

## Zero-code

Leave your app unchanged and start it with `botgauge instrument`. The sample still wraps the work in `tracing.turn()` and `tracing.agent()` so spans carry session and agent ids.

> [!NOTE]
>
> CrewAI calls its model through the OpenAI SDK, which the CrewAI instrumentor doesn't trace. The `[crewai]` extra therefore also installs the OpenAI producer, and the install line pins the tested `openai`. CrewAI 1.15 needs Python 3.10 to 3.13 and doesn't support 3.14. Set `CREWAI_DISABLE_TELEMETRY=true` to stop CrewAI's own usage telemetry.

**1. Install**

```bash terminal theme={null}
pip install "botgauge[crewai]" crewai==1.15.28 openai==2.54.0
```

**2. Add the code**

```python app.py theme={null}
import os

from botgauge import tracing
from crewai import LLM, Agent, Crew, Task

llm = LLM(
    model=os.environ["OPENAI_MODEL"],
    base_url=os.environ["OPENAI_BASE_URL"],
    api_key=os.environ["OPENAI_API_KEY"],
)
agent = Agent(role="Assistant", goal="Answer briefly", backstory="You answer in one sentence.",
              llm=llm)
task = Task(description="In one sentence, what is OpenTelemetry?", expected_output="One sentence",
            agent=agent)

with tracing.turn(session_id="ses_crewai"), tracing.agent("crewai-agent"):
    result = Crew(agents=[agent], tasks=[task]).kickoff()
print(result)
```

**3. Run**

```bash terminal theme={null}
botgauge instrument python app.py
```

Needs `BOTGAUGE_API_KEY`, `OPENAI_MODEL`, `OPENAI_BASE_URL`, `OPENAI_API_KEY`.

View CrewAI spans liveWatch your CrewAI runs and underlying LLM calls appear in [BotGauge](https://cloud.botgauge.com).

[Try BotGauge →](https://cloud.botgauge.com)

## Related

See [versions not verified](https://www.botgauge.com/docs/integrations/versions-not-verified.md) if you run a different version, [capture and redaction](https://www.botgauge.com/docs/tracing/capture-and-redaction.md) to control exported content, and [troubleshooting](https://www.botgauge.com/docs/tracing/troubleshooting.md) if spans are missing.


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