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

# CrewAI

> Orchestrate AI agent teams with CrewAI and Adaline.

# CrewAI

Use the Adaline CrewAI observer to send CrewAI crew executions into Adaline. The integration wraps an existing crew and observes its kickoff lifecycle without changing the crew or task logic itself.

## Prerequisites

Before you start, make sure you have:

* An [Adaline account](https://app.adaline.ai/sign-up?utm_source=adaline.ai).
* A **workspace API key** — create one under **Settings → API keys**.
* Your **project ID** — copy it from **Monitor → Copy Project ID**.

See [Integrate your AI Agent](/docs/get-started/integrate-your-ai-agent) for a full walkthrough.

Set both as environment variables before running the examples on this page:

```bash theme={null}
export ADALINE_API_KEY="your-api-key"
export ADALINE_PROJECT_ID="your-project-id"
```

## Install

```bash theme={null}
pip install adaline-client adaline-crewai crewai
```

## Initialize Adaline

Create an Adaline client, then initialize a monitor for the target project.

```python theme={null}
import os

from adaline import Adaline

adaline = Adaline(api_key=os.environ["ADALINE_API_KEY"])
monitor = adaline.init_monitor(project_id=os.environ["ADALINE_PROJECT_ID"])
```

<Note>
  For production guidance — buffering, batching, retries, serverless flushing, and graceful shutdown — see [Instrument with the Adaline SDK](/docs/instrument/with-adaline-sdks).
</Note>

## Wrap a CrewAI crew

Create an `AdalineCrewAIObserver`, then wrap the crew you want to observe.

```python theme={null}
from adaline_crewai import AdalineCrewAIObserver

observer = AdalineCrewAIObserver(monitor=monitor)
wrapped = observer.wrap_crew(crew)
```

## Basic example

This example keeps the integration intentionally small: one crew with one agent and one task, observed through `wrap_crew`.

```python theme={null}
import asyncio

from crewai import Agent, Crew, Task

from adaline_crewai import AdalineCrewAIObserver

async def main():
    observer = AdalineCrewAIObserver(
        monitor=monitor,
        tags=["crewai"],
    )

    agent = Agent(
        role="greeter",
        goal="reply with a single word greeting",
        backstory="You respond concisely.",
        llm="gpt-4o-mini",
        allow_delegation=False,
        verbose=False,
    )
    task = Task(
        description="Reply with exactly one word: 'hello'.",
        agent=agent,
        expected_output="hello",
    )
    crew = Crew(agents=[agent], tasks=[task], verbose=False)

    wrapped = observer.wrap_crew(crew)
    result = wrapped.kickoff()

    await monitor.flush()


asyncio.run(main())
```

## Use an existing parent trace or span

The CrewAI observer accepts:

* `parent_trace`
* `parent_span`

Pass one or the other, but not both.

## What the observer captures

The CrewAI integration is designed to capture crew execution activity, including:

* a root observation for the crew kickoff
* serialized task and agent input metadata
* step callbacks emitted during the run
* child spans under an Adaline parent when provided

This page focuses on how to wrap the crew. The exact span tree depends on the CrewAI run behavior and step callbacks emitted during execution.

## Next steps

<CardGroup cols={2}>
  <Card title="Instrument with the Adaline SDK" icon="code" href="/docs/instrument/with-adaline-sdks">
    Monitor lifecycle, buffering and batching, retries, serverless flushing, and graceful shutdown.
  </Card>

  <Card title="SDK reference" icon="braces" href="/docs/reference/sdk/v2/overview">
    Full class and type reference for the TypeScript and Python SDKs.
  </Card>

  <Card title="All integrations" icon="layout-grid" href="/docs/integrations/introduction">
    Browse every framework and AI-provider integration Adaline supports.
  </Card>

  <Card title="View your logs" icon="line-chart" href="https://app.adaline.ai">
    Open Adaline to see traces and spans land in your project.
  </Card>
</CardGroup>
