skillfed

openinference-instrumentation-openai

OpenInference OpenAI Instrumentation

openinference-instrumentation-openai v0.1.54 2.2M downloads/30d#3,214 on PyPI1,147
Permissive license Apache-2.0 Active released

What it is and what it does

This package wraps OpenAI Python SDK calls with OpenTelemetry instrumentation, capturing detailed traces of each API interaction without requiring code changes to your OpenAI calls. The traces are emitted in OpenTelemetry format and can be sent to any compatible collector for visualization and analysis.

It works by installing an OpenAIInstrumentor that hooks into the SDK at runtime. You configure a tracer provider with span processors and call instrument() once; thereafter, all OpenAI client calls automatically generate spans. The package depends on opentelemetry-api, opentelemetry-instrumentation, and openinference-semantic-conventions to standardize span attributes.

Use it for:

  • Debug LLM application behavior by viewing detailed traces of each OpenAI API call.
  • Monitor token usage and latency across production OpenAI calls for cost and performance analysis.
  • Correlate OpenAI calls with upstream application logic using OpenTelemetry's distributed tracing context.
  • Audit and log all LLM interactions for compliance or troubleshooting without modifying application code.
  • Integrate LLM observability into existing OpenTelemetry infrastructure.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Auto-instruments OpenAI Python SDK calls to emit OpenTelemetry-compatible traces for observability and debugging of LLM interactions.

Yes. This is a lightweight, actively maintained instrumentation library with no known vulnerabilities, permissive licensing, and low install friction. Install it if you use OpenAI's Python SDK and want to observe LLM calls via OpenTelemetry—it requires minimal setup and integrates cleanly with existing observability stacks.

Install

openinference-instrumentation-openai on PyPI

pip

pip install openinference-instrumentation-openai

uv

uv add openinference-instrumentation-openai

poetry

poetry add openinference-instrumentation-openai

Installing openinference-instrumentation-openai

Before you install

Low friction installation with a pure Python wheel. Active maintenance—released 7 days ago with a stable codebase (1147 GitHub stars). Supports current Python versions (3.10–3.14).

License in practice

Apache-2.0 permissive license allows commercial use, modification, and distribution with minimal restrictions.

Quickstart

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

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

Requires OPENAI_API_KEY environment variable to authenticate with OpenAI API; an OpenTelemetry collector must be running at the configured endpoint to receive traces.

Verify before relying

  • Whether instrumentation overhead is negligible for high-throughput production workloads.
  • Compatibility with OpenAI SDK versions prior to 1.26 for non-streaming use cases.
  • Support for async OpenAI client methods beyond the synchronous example shown.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (<3.15,>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 7 — openinference-instrumentation, openinference-semantic-conventions, opentelemetry-api, opentelemetry-instrumentation, opentelemetry-semantic-conventions, typing-extensions, wrapt
Maintenance actively maintained — 7 days since the last release
Last repo commit
First released
Downloads 2,199,804/month — #3,214 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: openinference_instrumentation_openai-0.1.54-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

openai tracing instrumentationllm observability opentelemetryopenai api monitoring tracesopentelemetry openai integrationai call tracing and debuggingopenai span collectionllm request tracking
llm-observabilityopentelemetrytracing

More Monitoring packages

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

opentelemetry-semantic-conventions

Provides generated Python code for…

permissive · top 100 on PyPI

opentelemetry-sdk

Provides the reference implementation of the…

permissive · top 100 on PyPI

opentelemetry-api

Provides the abstract API and interfaces for…

permissive · top 100 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI

langwatch

LangWatch is a Python SDK for instrumenting and…

permissive · top 15,000 on PyPI

openinference-instrumentation

Provides utility functions to convert typed…

permissive · top 5,000 on PyPI

openinference-instrumentation-agno

Auto-instruments Agno Agent applications to…

permissive · top 15,000 on PyPI

openinference-instrumentation-google-genai

Automatically instruments Google GenAI SDK…

permissive · top 15,000 on PyPI

openinference-instrumentation-langchain

Auto-instruments LangChain applications to…

permissive · top 5,000 on PyPI

openinference-instrumentation-mcp

Auto-instruments MCP tool calls to propagate…

permissive · top 15,000 on PyPI

openinference-instrumentation-openai-agents

Auto-instruments OpenAI Agents SDK to emit…

permissive · top 5,000 on PyPI

openinference-instrumentation-portkey

Automatically instruments Portkey AI API calls…

permissive · top 15,000 on PyPI

openinference-instrumentation-claude-agent-sdk

Auto-instruments Claude Agent SDK calls to emit…

permissive · top 15,000 on PyPI

openinference-semantic-conventions

Defines semantic conventions and standardized…

permissive · top 5,000 on PyPI