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

# OpenTelemetry

> Send LiteLLM OpenTelemetry traces to Qualifire for observability and tracing

Send OpenTelemetry (OTEL) traces from LiteLLM to Qualifire for complete observability across your LLM calls.

<Tip>
  Looking for real-time guardrails? Check out the [Qualifire Guardrails
  Integration](/integrations/litellm-guardrails) for content moderation, prompt
  injection detection, and more.
</Tip>

## Pre-Requisites

1. Create an account on [Qualifire](https://app.qualifire.ai/)
2. Get your API key from the [Qualifire dashboard](https://app.qualifire.ai/settings/api-keys)

```bash theme={null}
pip install litellm
```

## Quick Start

Use just 2 lines of code to send OpenTelemetry traces **across all providers** to Qualifire.

```python theme={null}
litellm.callbacks = ["otel"]
```

```python theme={null}
import litellm
import os

# Set OpenTelemetry configuration for Qualifire
os.environ["OTEL_EXPORTER"] = "otlp_http"
os.environ["OTEL_ENDPOINT"] = "https://proxy.qualifire.ai/api/telemetry"
os.environ["OTEL_HEADERS"] = "X-Qualifire-API-Key=your-qualifire-api-key"

# LLM API Keys
os.environ["OPENAI_API_KEY"] = "your-openai-api-key"

# Set otel as a callback & LiteLLM will send traces to Qualifire
litellm.callbacks = ["otel"]

# OpenAI call
response = litellm.completion(
  model="gpt-4o",
  messages=[
    {"role": "user", "content": "Hi 👋 - i'm openai"}
  ]
)
```

## Using with LiteLLM Proxy

<Steps>
  <Step title="Setup config.yaml">
    Configure the LiteLLM proxy with OpenTelemetry callback:

    ```yaml theme={null}
    model_list:
      - model_name: gpt-4o
        litellm_params:
          model: openai/gpt-4o
          api_key: os.environ/OPENAI_API_KEY

    litellm_settings:
      callbacks: ["otel"]

    general_settings:
      master_key: "sk-1234"

    environment_variables:
      OTEL_EXPORTER: "otlp_http"
      OTEL_ENDPOINT: "https://proxy.qualifire.ai/api/telemetry"
      OTEL_HEADERS: "X-Qualifire-API-Key=your-qualifire-api-key"
    ```
  </Step>

  <Step title="Start the proxy">
    ```bash theme={null}
    litellm --config config.yaml
    ```
  </Step>

  <Step title="Test it!">
    ```bash theme={null}
    curl -X POST 'http://0.0.0.0:4000/chat/completions' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer sk-1234' \
    -d '{ "model": "gpt-4o", "messages": [{"role": "user", "content": "Hello!"}]}'
    ```
  </Step>
</Steps>

## Environment Variables

<Info>
  All three environment variables are required for OTEL tracing. The `OTEL_HEADERS` variable must include your Qualifire API key.
</Info>

| Variable        | Description                                                              |
| --------------- | ------------------------------------------------------------------------ |
| `OTEL_EXPORTER` | The exporter type. Use `otlp_http` for Qualifire                         |
| `OTEL_ENDPOINT` | Qualifire telemetry endpoint: `https://proxy.qualifire.ai/api/telemetry` |
| `OTEL_HEADERS`  | Authentication header: `X-Qualifire-API-Key=<your-api-key>`              |

## What Gets Traced?

<AccordionGroup>
  <Accordion title="Span & Timing Data" icon="clock">
    Start time, end time, and duration for each operation in the trace.
  </Accordion>

  <Accordion title="Request & Response Attributes" icon="arrows-left-right">
    Model name, messages, parameters, generated content, and finish reason.
  </Accordion>

  <Accordion title="Token Usage & Errors" icon="coins">
    Prompt tokens, completion tokens, total tokens, and any exception details if the call fails. Custom metadata you add to requests is also captured.
  </Accordion>
</AccordionGroup>

Once data is in Qualifire, you can:

* View end-to-end traces across your AI pipeline
* Analyze latency and performance metrics
* Debug issues with detailed span information
* Correlate traces with evaluations and guardrail results

## Additional Resources

* [Qualifire Dashboard](https://app.qualifire.ai)
* [LiteLLM OpenTelemetry Documentation](https://docs.litellm.ai/docs/observability/opentelemetry_integration)
* [Qualifire Evals Integration](/integrations/litellm-evals)
* [Qualifire Guardrails Integration](/integrations/litellm-guardrails)
