Tracing Providers

OpenInference Integration

Export OpenInference traces to the Judgment platform.

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

Quickstart

Install Dependencies

uv add openinference-instrumentation-openai judgeval openai
pip install openinference-instrumentation-openai judgeval openai

Initialize Integration

setup.py
from judgeval.tracer import Tracer
from openinference.instrumentation.openai import OpenAIInstrumentor

tracer = Tracer(project_name="openinference_project")
OpenAIInstrumentor().instrument()

Always initialize the Tracer before calling OpenInference instrumentors to ensure proper trace routing.

Add to Existing Code

Add these lines to your existing OpenInference-instrumented application:

from openai import OpenAI
from judgeval.tracer import Tracer  
from openinference.instrumentation.openai import OpenAIInstrumentor  

tracer = Tracer(project_name="openinference-app")  
OpenAIInstrumentor().instrument()  

client = OpenAI()

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

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

All OpenInference traces are exported to the Judgment platform.

Example: Multi-Workflow Application

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

multi_workflow_example.py
from judgeval.tracer import Tracer
from openinference.instrumentation.openai import OpenAIInstrumentor
from openai import OpenAI

tracer = Tracer(project_name="multi_workflow_app")
OpenAIInstrumentor().instrument()

client = OpenAI()

def analyze_sentiment(text: str) -> str:
    response = client.chat.completions.create(
        model="gpt-5-mini",
        messages=[
            {"role": "system", "content": "You are a sentiment analysis expert."},
            {"role": "user", "content": f"Analyze the sentiment of: {text}"}
        ]
    )
    return response.choices[0].message.content

def extract_entities(text: str) -> str:
    response = client.chat.completions.create(
        model="gpt-5-mini",
        messages=[
            {"role": "system", "content": "You are an entity extraction expert."},
            {"role": "user", "content": f"Extract entities from: {text}"}
        ]
    )
    return response.choices[0].message.content

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

@tracer.observe(span_type="function")  
def main():
    text = "Apple Inc. announced today that their new iPhone will be released next month. The market reacted positively to this news."

    sentiment = analyze_sentiment(text)
    entities = extract_entities(text)
    summary = summarize_text(text)

    print(f"Sentiment: {sentiment}")
    print(f"Entities: {entities}")
    print(f"Summary: {summary}")

if __name__ == "__main__":
    main()

Available Instrumentors

OpenInference provides instrumentors for various frameworks and libraries:

OpenAI

from openinference.instrumentation.openai import OpenAIInstrumentor
OpenAIInstrumentor().instrument()

Anthropic

from openinference.instrumentation.anthropic import AnthropicInstrumentor
AnthropicInstrumentor().instrument()

OpenAI Agents SDK

from openinference.instrumentation.openai_agents import OpenAIAgentsInstrumentor
OpenAIAgentsInstrumentor().instrument()

PydanticAI

from openinference.instrumentation.pydanticai import PydanticAIInstrumentor
PydanticAIInstrumentor().instrument()

Other

For a complete list of available instrumentors, visit the OpenInference GitHub repository.

Next Steps