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, callbraintrust.auto_instrument() before creating your crew.setup_crewai() instead of braintrust.auto_instrument().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.llmspans 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.