> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Traceloop Integration

> Wraps an agent run in a Traceloop @workflow-decorated function so the run appears under a parent workflow span.

Demonstrates wrapping Agno calls in Traceloop workflow spans.

```python traceloop_op.py theme={null}
"""
Traceloop Integration
=====================

Demonstrates wrapping Agno calls in Traceloop workflow spans.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from traceloop.sdk import Traceloop
from traceloop.sdk.decorators import workflow

# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
Traceloop.init(app_name="agno_workflows")


# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
    name="AnalysisAgent",
    model=OpenAIChat(id="gpt-5.2"),
)


@workflow(name="data_analysis_pipeline")
def analyze_data(query: str) -> str:
    """Custom workflow that wraps agent execution."""
    response = agent.run(query)
    return response.content


# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    # The workflow decorator creates a parent span
    result = analyze_data("Analyze the benefits of observability in AI systems")
    print(result)
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno openai traceloop-sdk
```

**2. Export your API keys**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
export TRACELOOP_API_KEY="your_traceloop_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
$Env:TRACELOOP_API_KEY="your_traceloop_api_key_here"
```

**3. Run the example**

Save the code above as `traceloop_op.py`, then run:

```bash theme={null}
python traceloop_op.py
```

Full source: [cookbook/observability/traceloop\_op.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/observability/traceloop_op.py)


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