---
title: "OpenLit Trace Export"
description: "Export OpenLit traces to the Judgment platform."
sidebar:
  label: "OpenLit Integration"
seo:
  title: "OpenLit Trace Export to Judgment | Integration Docs"
  description: "Export OpenLit traces to Judgment so teams can inspect agent behavior, run judges, and monitor production regressions."
---

**OpenLit integration** sends traces from your OpenLit-instrumented applications to Judgment. If you're already using OpenLit for observability, this integration forwards those traces to Judgment without requiring additional instrumentation.

{/* @test-flow
  id: tracing-openlit
  lang: python
  env: JUDGMENT_API_KEY, JUDGMENT_ORG_ID, OPENAI_API_KEY
*/}

## Quickstart

1. ### Install Dependencies

    **uv**

    ```bash
    uv add openlit judgeval openai
    ```

    **pip**

    ```bash
    pip install openlit judgeval openai
    ```

2. ### Initialize Integration

    ```python title="setup.py"
    from judgeval import Tracer
    from judgeval.integrations.openlit import Openlit

    Tracer.init(project_name="openlit_project")
    Openlit.initialize()
    ```

            > **Tip**
            >
            > Always initialize the `Tracer` before calling `Openlit.initialize()` to ensure proper trace routing.

3. ### Add to Existing Code

    Add these lines to your existing OpenLit-instrumented application:

    ```python
    from openai import OpenAI
    from judgeval import Tracer  # [!code ++]
    from judgeval.integrations.openlit import Openlit  # [!code ++]

    Tracer.init(project_name="openlit_project")  # [!code highlight]
    Openlit.initialize()  # [!code highlight]

    client = OpenAI()

    response = client.chat.completions.create(
        model="gpt-5.2",
        messages=[{"role": "user", "content": "Hello, world!"}]
    )

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

    All OpenLit traces are exported to the Judgment platform.

    > **Tip**
    >
    > **No OpenLit Initialization Required**: When using Judgment's OpenLit integration, you don't need to call `openlit.init()` separately. The `Openlit.initialize()` call handles all necessary OpenLit setup automatically.
    > ```python
    > import openlit  # [!code --]
    > openlit.init()  # [!code --]
    >
    > from judgeval import Tracer  # [!code ++]
    > from judgeval.integrations.openlit import Openlit  # [!code ++]
    > Tracer.init(project_name="openlit_project")  # [!code ++]
    > Openlit.initialize()  # [!code ++]
    >
    > from openai import OpenAI
    > client = OpenAI()
    > ```

## Example: Multi-Workflow Application

    > **Info**
    >
    > **Tracking Non-OpenLit Operations**: Use `@Tracer.observe()` to track any function or method that's not automatically captured by OpenLit. The multi-workflow example below shows how `@Tracer.observe()` (highlighted) can be used to monitor custom logic and operations that happen outside your OpenLit-instrumented workflows.

```python title="multi_workflow_example.py"
from judgeval import Tracer
from judgeval.integrations.openlit import Openlit
from openai import OpenAI

Tracer.init(project_name="openlit_project")
Openlit.initialize()

client = OpenAI()

def analyze_text(text: str) -> str:
    response = client.chat.completions.create(
        model="gpt-5.2",
        messages=[
            {"role": "system", "content": "You are a helpful AI assistant."},
            {"role": "user", "content": f"Analyze: {text}"}
        ]
    )
    return response.choices[0].message.content

def summarize_text(text: str) -> str:
    response = client.chat.completions.create(
        model="gpt-5.2",
        messages=[
            {"role": "system", "content": "You are a helpful AI assistant."},
            {"role": "user", "content": f"Summarize: {text}"}
        ]
    )
    return response.choices[0].message.content

def generate_content(prompt: str) -> str:
    response = client.chat.completions.create(
        model="gpt-5.2",
        messages=[
            {"role": "system", "content": "You are a creative AI assistant."},
            {"role": "user", "content": prompt}
        ]
    )
    return response.choices[0].message.content

@Tracer.observe(span_type="function")  # [!code highlight]
def main():
    text = "The future of artificial intelligence is bright and full of possibilities."

    analysis = analyze_text(text)
    summary = summarize_text(text)
    story = generate_content(f"Create a story about: {text}")

    print(f"Analysis: {analysis}")
    print(f"Summary: {summary}")
    print(f"Story: {story}")

if __name__ == "__main__":
    main()
```
