Crew AI
Use Confident AI for LLM observability and evals for CrewAI
Overview
CrewAI is a lean, lightning-fast Python framework for creating autonomous AI agents tailored to any scenario. Confident AI allows you to trace and evaluate CrewAI crews with a single line of code — every kickoff shows up in the Observatory as a trace with the full crew → task → agent → tool hierarchy, so you can see which agent called which tool, what each model call returned, and where the time and tokens went.
| Runtime | Requirements | Setup |
|---|---|---|
| Python | Python 3.10+, CrewAI 1.x (tested with 1.15.20) | Call init() before kicking off the crew |
| TypeScript | Not supported | — |
Auto-Instrument
Install Dependencies
Run the following command to install
confident-tracealong with CrewAI and the model provider SDK your crew uses (the example below uses OpenAI):pip install confident-trace crewai openaiSetup Confident AI Key
Get your Confident AI Project API key and set it as an environment variable, or pass it to
init()directly:export CONFIDENT_API_KEY="<your-confident-api-key>" export OPENAI_API_KEY="<your-openai-key>"from confident_trace import init init(api_key="<your-confident-api-key>")Configure CrewAI
Call
init()once at startup, before kicking off any crew. Keep importingAgent,Task, andCrewfromcrewaias usual — the installed framework is detected automatically.main.py from confident_trace import init, shutdown from crewai import Agent, Crew, Task init() agent = Agent( role="Consultant", goal="Write clear, concise explanations.", backstory="An expert consultant with a keen eye for software trends.", llm="openai/gpt-4o-mini", ) task = Task( description="Explain the given topic", expected_output="A clear and concise explanation.", agent=agent, ) crew = Crew(agents=[agent], tasks=[task]) try: result = crew.kickoff({"input": "What are LLMs?"}) print(result.raw) finally: shutdown()Run CrewAI
Kickoff your crew by executing the script:
python main.pyDone ✅. Open the Observatory in your Confident AI project to inspect the trace and its child spans.
What Gets Captured
CrewAI crew and flow runs are exported with their hierarchy intact, so you can follow an execution from kickoff through its tasks, agents, model calls, and tools.
- Crew, task, and flow execution — operation names, timing, status, and the parent-child relationships between steps.
- Agent execution — the task prompt sent to each agent and the agent's final answer.
- Model calls — messages, model details, tool requests, finish reasons, and token usage.
- Tool calls — tool names and their input/output.
- Custom spans — any custom application spans created inside a tool or flow remain nested under it.
Captured inputs, outputs, and messages follow the content policy. Agent configuration, credentials, memory stores, and checkpoint state aren't exported.
Set Trace Span Properties
Use a trace context to add properties you know before the call starts. It creates no extra span; the trace started by crew.kickoff() inherits the tags, metadata, and user ID.
from confident_trace import init, trace_context
init()
with trace_context(
tags=["support"],
metadata={"release": "2026-09"},
user_id="user-42",
):
result = crew.kickoff({"input": "Explain OpenTelemetry in one sentence."})See trace context for every supported trace property and update behavior.
Instrumenting Multi-Turn
You do not need turn() when one CrewAI entry-point call is already one conversational turn—the integration creates that turn's trace automatically. Use turn() when you want to define the boundary yourself, such as grouping two sequential CrewAI calls into one turn. Reuse the same thread ID on later turns to group them into one conversation.
from confident_trace import init, turn
init()
with turn("support-turn", thread_id="chat-42"):
context = crew.kickoff({"input": "Find the relevant account details."})
answer = crew.kickoff({"input": f"Summarize these details: {context.raw}"})See threads for thread I/O, turn IDs, and user IDs.
Disable CrewAI Instrumentation
Pass init() a list of integration identifiers to opt in to only those integrations. The identifier for CrewAI is "crewai" in Python; omit it to disable this integration. An empty list disables all automatic instrumentation:
from confident_trace import init
init(instrumentations=())
# Use ("crewai",) to opt in; omit "crewai" to disable it.This turns off Confident AI's automatic instrumentation; calls made after initialization are not instrumented by this integration.
Next Steps
Now that your crew is traced, dive deeper into:
Online Evals
Run evaluations on traces and spans in real-time as they're ingested into Confident AI to monitor your crew's quality.
Threads
Group kickoffs from the same conversation into a thread and evaluate the whole conversation as one unit.
Last updated on