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

# How to trace CrewAI with HoneyHive

> Trace CrewAI crews, tasks, and agent collaboration with HoneyHive. Instrument crew workflows to capture role assignments, tool use, and model calls.

[CrewAI](https://www.crewai.com/) is a multi-agent framework for orchestrating crews, tasks, tools, and manager-driven delegation.

HoneyHive integrates with CrewAI through OpenInference instrumentors. Crew orchestration spans come from `CrewAIInstrumentor`. Model spans come from the provider client that CrewAI actually calls underneath. This page uses OpenAI-backed CrewAI flows, so it layers `OpenAIInstrumentor` on top of `CrewAIInstrumentor`.

## Quick Start

> [!TIP]
>
> **Recommended setup.** Initialize HoneyHive, instrument CrewAI for orchestration spans, then instrument the model provider your CrewAI app actually uses.

> [!TIP]
>
> To see where to initialize the tracer for your environment, including AWS Lambda and long-running servers, see [Tracer Initialization](https://docs.honeyhive.ai/v2/tracing/tracer-initialization.md).

> [!NOTE]
>
> Last tested with `crewai 1.15.23`, `openinference-instrumentation-crewai 1.1.18`, and `openinference-instrumentation-openai 0.1.61` (September 2026).

The examples on this page use `openai/gpt-4o-mini`, so they use `OpenAIInstrumentor`. If your CrewAI app uses another provider, use the matching provider instrumentor when one exists.

```bash theme={null}
uv pip install honeyhive crewai openinference-instrumentation-crewai openinference-instrumentation-openai
```

```python theme={null}
import os

from honeyhive import HoneyHiveTracer
from openinference.instrumentation.crewai import CrewAIInstrumentor
from openinference.instrumentation.openai import OpenAIInstrumentor

# Reads HH_INGESTION_API_KEY from your environment
tracer = HoneyHiveTracer.init(
    server_url=os.getenv("HH_API_URL"),
)

CrewAIInstrumentor().instrument(tracer_provider=tracer.provider)
OpenAIInstrumentor().instrument(tracer_provider=tracer.provider)

# Your existing CrewAI code works unchanged
```

## Required Environment Variables

* `HH_INGESTION_API_KEY` - Your HoneyHive ingestion API key
* `OPENAI_API_KEY` - Required for the examples on this page
* `HH_API_URL` - Optional override for non-production HoneyHive environments

If you use a different model provider with CrewAI, set that provider's credentials and instrument that provider's client when an openinference instrumentor exists.

## What Gets Traced

This setup captures:

* **Crew runs** - Crew kickoff spans and multi-step execution
* **Agent activity** - Agent roles, prompts, and outputs for each task
* **Model requests** - OpenAI-backed LLM calls with prompt and response payloads
* **Tool usage** - Each CrewAI tool run, with its arguments and result
* **Flows** - `Flow.kickoff()` runs and each flow method step
* **Standalone agents** - `Agent.kickoff()` calls made outside a crew

No manual `@trace` decorators are required for the standard CrewAI path.

Tool events require `openinference-instrumentation-crewai` 1.1.11 or later. Earlier versions do not emit spans for `@tool`-decorated functions.

***

## Example: Support Agent with Tool Calls

```python theme={null}
import os

from crewai import Agent, Crew, Process, Task
from crewai.tools import tool
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.crewai import CrewAIInstrumentor
from openinference.instrumentation.openai import OpenAIInstrumentor

MODEL = "openai/gpt-4o-mini"


@tool("OrderStatusLookup")
def lookup_order_status(order_id: str) -> str:
    """Look up the current status and ETA for a customer order."""
    statuses = {
        "ORD-1001": {"state": "shipped", "eta_days": 2},
        "ORD-1002": {"state": "processing", "eta_days": 5},
        "ORD-1003": {"state": "delayed", "eta_days": 8},
    }
    status = statuses.get(order_id.upper())
    if not status:
        return f"Order {order_id.upper()}: not found in the system."
    return (
        f"Order {order_id.upper()}: {status['state']}, "
        f"estimated delivery in {status['eta_days']} days."
    )


@tool("PolicyLookup")
def lookup_policy(topic: str) -> str:
    """Look up support policy by topic: refund, cancellation, or shipping."""
    policies = {
        "refund": "Refunds are available within 30 days for undelivered or damaged items.",
        "cancellation": "Cancellation is allowed before shipment. Delayed orders can request assisted cancellation.",
        "shipping": "Delays beyond 7 days trigger proactive support outreach.",
    }
    return policies.get(topic.strip().lower(), "No policy found.")

# Reads HH_INGESTION_API_KEY from your environment
tracer = HoneyHiveTracer.init(
    server_url=os.getenv("HH_API_URL"),
)

CrewAIInstrumentor().instrument(tracer_provider=tracer.provider)
OpenAIInstrumentor().instrument(tracer_provider=tracer.provider)

support_generalist = Agent(
    role="Support Generalist",
    goal="Resolve order and policy questions using the available tools",
    backstory=(
        "You are a customer support generalist. Use tools for order status and "
        "policy questions, then reply with short, customer-friendly answers."
    ),
    tools=[lookup_order_status, lookup_policy],
    llm=MODEL,
    verbose=False,
)

task = Task(
    description=(
        "For delayed order ORD-1003, explain the cancellation policy and "
        "recommended next steps."
    ),
    expected_output=(
        "A concise support response that uses tools when needed and includes "
        "the final customer-facing answer."
    ),
    agent=support_generalist,
)

crew = Crew(
    name="support_crew",
    agents=[support_generalist],
    tasks=[task],
    process=Process.sequential,
    verbose=False,
)

print(crew.kickoff())
```

For trace enrichment after setup, see [Enriching Traces](https://docs.honeyhive.ai/v2/tutorials/enriching-traces.md).

***

## Troubleshooting

### Traces not appearing

1. **Check environment variables** - Ensure `HH_INGESTION_API_KEY` is set
2. **Pass the tracer provider** - Both instrumentors must receive `tracer_provider=tracer.provider`:

```python theme={null}
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.crewai import CrewAIInstrumentor
from openinference.instrumentation.openai import OpenAIInstrumentor

tracer = HoneyHiveTracer.init()  # Reads HH_INGESTION_API_KEY from your environment

# Correct - pass tracer_provider
CrewAIInstrumentor().instrument(tracer_provider=tracer.provider)
OpenAIInstrumentor().instrument(tracer_provider=tracer.provider)

# Wrong - missing tracer_provider
CrewAIInstrumentor().instrument()
```

3. **Instrument your provider** - `CrewAIInstrumentor` captures orchestration spans; you also need the matching provider instrumentor for model input/output details
4. **Check your model provider** - Ensure the API key for your chosen model provider is set (e.g., `OPENAI_API_KEY`)

***

## Related

> [card] [Enrich Your Traces](https://docs.honeyhive.ai/v2/tutorials/enriching-traces.md)
>
> Add user IDs and custom metadata to CrewAI traces

> [card] [Custom Spans](https://docs.honeyhive.ai/v2/tracing/custom-spans.md)
>
> Create spans for business logic around agent calls

> [card] [Distributed Tracing](https://docs.honeyhive.ai/v2/tutorials/distributed-tracing.md)
>
> Trace agents across service boundaries

***

## Resources

* [CrewAI Documentation](https://docs.crewai.com/)
* [CrewAI GitHub](https://github.com/crewAIInc/crewAI)


## Related topics

- [How to trace Anthropic with HoneyHive](https://docs.honeyhive.ai/v2/integrations/anthropic.md)
- [How to trace Gemini with HoneyHive](https://docs.honeyhive.ai/v2/integrations/gemini.md)
- [How to trace Pydantic AI with HoneyHive](https://docs.honeyhive.ai/v2/integrations/pydantic-ai.md)


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