Skip to main content
CrewAI is a framework for orchestrating teams of AI agents. Braintrust traces a CrewAI run as a single nested trace, covering crew kickoff, task execution, agent reasoning, LLM calls, and tool usage. The integration works with any model provider CrewAI supports.
CrewAI requires Python < 3.14. A transitive dependency (pydantic-core) does not yet ship Python 3.14 wheels, so installation will fail on Python 3.14 and later.

Setup

Install the Braintrust SDK and CrewAI, then set your API keys. The examples below use OpenAI.
1

Install packages

2

Set environment variables

.env

Auto-instrumentation

To trace CrewAI alongside Braintrust’s other supported libraries, call braintrust.auto_instrument() before creating your crew.
To trace CrewAI without auto-instrumenting other libraries, use setup_crewai() instead of braintrust.auto_instrument().
Already running CrewAI with OpenTelemetry? Keep that setup and route spans to Braintrust using the Braintrust OpenTelemetry guide.

What Braintrust traces

Braintrust traces CrewAI runs as nested spans that mirror the actual execution flow. Captured spans:
  • Crew kickoff spans (crewai.kickoff), with crew inputs, name, process, and fingerprint.
  • Task spans (crewai.task), with description, expected output, assigned agent, and execution context.
  • Agent execution spans (crewai.agent), with task prompt, role/goal/backstory, and available tools.
  • LLM call spans (crewai.llm), with messages, model, tools, and provider config (temperature, max tokens, top p, response format, and so on); response on completion.
  • Tool call spans (crewai.tool.<name>), with tool arguments, output, run attempts, and cache hits.
  • Token usage metrics for LLM calls (input, output, total, plus cached and reasoning tokens when the provider reports them), captured on crewai.llm spans by default, or on the LiteLLM completion child span when LiteLLM is also auto-instrumented (to avoid double-counting).
  • Time-to-first-token metric for streaming LLM calls.
  • Errors on failed kickoffs, tasks, agents, LLM calls, and tool calls.
  • Causal nesting via CrewAI event IDs, nested under any enclosing Braintrust span.

Resources