# OpenInference

> OpenTelemetry tracing conventions and instrumentors for LLM and agent apps

- Category: Evaluation & Production Ops / Observability & LLMOps
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/Arize-ai/openinference
- Website: https://arize.com/docs/phoenix/learn/openinference
- Canonical page: https://ai-tldr.dev/tools/openinference/

## In short

OpenInference is a set of OpenTelemetry conventions and instrumentation libraries for tracing AI applications. It defines standard span attributes for LLM calls, retrieval from vector stores, tool use, and agent steps, so traces from different frameworks describe the same things in the same way. It sits in the Observability & LLMOps category of the Evaluation & Production Ops tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

OpenInference is a set of OpenTelemetry conventions and instrumentation libraries for tracing AI applications. It defines standard span attributes for LLM calls, retrieval from vector stores, tool use, and agent steps, so traces from different frameworks describe the same things in the same way.

It is meant for developers who build LLM, RAG, and agent applications and want to see what their code is actually doing in production. The instrumentors auto-capture spans from popular SDKs such as OpenAI, LangChain, LlamaIndex, DSPy, and AWS Bedrock with little code on your side.

As an LLM observability tool, OpenInference is the data layer rather than the dashboard. It is natively supported by Arize Phoenix, but because it builds on OpenTelemetry you can send the traces to any OpenTelemetry-compatible backend.

## What it does

- OpenTelemetry-based semantic conventions for LLM, retrieval, tool, and agent spans
- Drop-in instrumentors for OpenAI, LangChain, LlamaIndex, DSPy, Bedrock, MistralAI, MCP, and more
- Works with any OpenTelemetry-compatible backend, with native support in Arize Phoenix
- Available for Python and JavaScript framework SDKs
- Transport- and format-agnostic spec (usable with JSON, ProtoBuf, DataFrames)
- Reusable decorators and helpers for instrumenting your own code

## Getting started

Install an instrumentor for the SDK you use, point it at an OpenTelemetry tracer provider, and your LLM calls start producing traces. The example below uses the OpenAI instrumentor with a local Phoenix collector.

1. Install the packages

   Install the OpenAI instrumentor along with the OpenTelemetry SDK and an exporter. Swap in the instrumentor for your framework if you are not using OpenAI.

```bash
pip install openinference-instrumentation-openai "openai>=1.26" arize-phoenix opentelemetry-sdk opentelemetry-exporter-otlp
```

2. Register a tracer provider and instrument

   Set up a tracer provider that exports spans, then call the instrumentor. After this, normal OpenAI calls are traced automatically.

```python
import openai
from openinference.instrumentation.openai import OpenAIInstrumentor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

endpoint = "http://127.0.0.1:6006/v1/traces"
tracer_provider = trace_sdk.TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))

OpenAIInstrumentor().instrument(tracer_provider=tracer_provider)

if __name__ == "__main__":
    client = openai.OpenAI()
    response = client.chat.completions.create(
        model="gpt-3.5-turbo",
        messages=[{"role": "user", "content": "Write a haiku."}],
        max_tokens=20,
    )
    print(response.choices[0].message.content)
```

## When to use it

- Trace and debug a RAG pipeline to see retrieval, prompts, and model responses in one place
- Add LLM observability to an agent app without writing custom span code for each framework
- Send standardized AI traces to Arize Phoenix or another OpenTelemetry backend
- Compare behavior across frameworks (OpenAI, LangChain, LlamaIndex) using one shared span schema
