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

# Traceloop (OpenLLMetry)

[Traceloop's OpenLLMetry](https://www.traceloop.com/docs/openllmetry/introduction) is an open source project that allows you to easily start monitoring and debugging the execution of your LLM app.

> [!NOTE]
>
> Traceloop's non-intrusive instrumentation combined with Prisma AIRS AI Gateway's intelligent gateway provides comprehensive observability without modifying your application code, while adding routing intelligence, caching, and failover capabilities.

## Why Traceloop + the AI Gateway?

> **Non-Intrusive Monitoring**
>
> Automatic instrumentation without changing your application code

> **OpenTelemetry Native**
>
> Built on industry-standard OpenTelemetry for maximum compatibility

> **Flexible Export Options**
>
> Send traces to the AI Gateway or any OpenTelemetry-compatible backend

> **Enhanced Intelligence**
>
> The AI Gateway adds gateway features like caching, fallbacks, and load balancing

## Quick Start

### Prerequisites

* Python
* Strata Cloud Manager account with API key
* OpenAI API key (or add it to [Model Catalog](https://docs.portkey.ai/docs/aigw/product/model-catalog.md))

### Step 1: Install Dependencies

Install the required packages for Traceloop and AI Gateway integration:

```bash theme={"system"}
pip install openai traceloop-sdk
```

### Step 2: Initialize Traceloop

Configure Traceloop to send traces to the AI Gateway's OpenTelemetry endpoint:

```python theme={"system"}
from traceloop.sdk import Traceloop

# Initialize Traceloop with the AI Gateway's endpoint
Traceloop.init(
    disable_batch=True,  # Process traces immediately
    api_endpoint="https://aigw.portkey.ai/v1/logs/otel",
    headers="Authorization=Bearer YOUR_PORTKEY_API_KEY",
    telemetry_enabled=False  # Disable Traceloop's own telemetry
)
```

### Step 3: Configure AI Gateway

Set up the OpenAI client to use the AI Gateway's intelligent gateway:

```python theme={"system"}
from openai import OpenAI

# Use the AI Gateway for intelligent routing
client = OpenAI(
    api_key="PORTKEY_API_KEY",
    base_url="https://aigw.portkey.ai/v1",
    default_headers={
        "x-portkey-provider": "@openai-prod",  # Your AI Provider slug from Model Catalog
    }
)
```

### Step 4: Make Instrumented LLM Calls

Your LLM calls are now automatically traced by Traceloop and enhanced by the AI Gateway:

```python theme={"system"}
# Make calls through the AI Gateway
# Traceloop automatically instruments the call
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Explain the benefits of OpenTelemetry for LLM applications"}],
    temperature=0.7
)

print(response.choices[0].message.content)

# You now get:
# 1. Automatic, non-intrusive tracing from Traceloop
# 2. Gateway features (caching, fallbacks, routing)
# 3. Combined insights in Strata Cloud Manager
```

## Complete Example

Here's a full example bringing everything together:

```python theme={"system"}
from traceloop.sdk import Traceloop
from openai import OpenAI

# Step 1: Initialize Traceloop with the AI Gateway endpoint
Traceloop.init(
    disable_batch=True,
    api_endpoint="https://aigw.portkey.ai/v1/logs/otel",
    headers="Authorization=Bearer YOUR_PORTKEY_API_KEY",
    telemetry_enabled=False
)

# Step 2: Configure the AI Gateway
client = OpenAI(
    api_key="PORTKEY_API_KEY",
    base_url="https://aigw.portkey.ai/v1"
)

# Step 3: Make instrumented calls
response = client.chat.completions.create(
    model="@openai-prod/gpt-4o",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What makes observability important for production AI?"}
    ]
)

print(response.choices[0].message.content)
```

## Next Steps

> **[Configure Gateway](https://docs.portkey.ai/docs/aigw/product/ai-gateway/configs.md)**
>
> Set up intelligent routing, fallbacks, and caching

> **[Model Catalog](https://docs.portkey.ai/docs/aigw/product/model-catalog.md)**
>
> Manage AI providers, credentials, and model access centrally

> **[View Analytics](https://docs.portkey.ai/docs/aigw/product/observability/analytics.md)**
>
> Analyze costs, performance, and usage patterns

> **[Set Up Alerts](https://docs.portkey.ai/docs/aigw/product/observability/analytics.md)**
>
> Configure alerts for anomalies and performance issues

***

## See Your Traces in Action

Once configured, navigate to the [Strata Cloud Manager](https://stratacloudmanager.paloaltonetworks.com/) to see your Traceloop instrumentation combined with gateway intelligence:

![OpenTelemetry traces in Prisma AIRS AI Gateway](https://mintcdn.com/portkey-docs/Buc1Vm2P31GSPm3S/images/product/opentelemetry.png?fit=max\&auto=format\&n=Buc1Vm2P31GSPm3S\&q=85\&s=bc982b581d5ce60764d207b004b4677f)


## Related topics

- [Supported OTel Libraries](https://docs.portkey.ai/docs/aigw/product/observability/opentelemetry/list-of-supported-otel-instrumenters.md)
- [OpenTelemetry for LLM Observability](https://docs.portkey.ai/docs/aigw/product/observability/opentelemetry.md)
- [OpenAI](https://docs.portkey.ai/docs/aigw/integrations/llms/openai.md)
- [OpenLIT](https://docs.portkey.ai/docs/aigw/integrations/tracing-providers/openlit.md)
- [Open Responses](https://docs.portkey.ai/docs/aigw/product/ai-gateway/responses-api.md)


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