openinference-instrumentation-openai
OpenInference OpenAI Instrumentation
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-openaiuv
uv add openinference-instrumentation-openaipoetry
poetry add openinference-instrumentation-openaiInstalling 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
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
langwatchLangWatch is a Python SDK for instrumenting and…
permissive · top 15,000 on PyPI
openinference-instrumentationProvides utility functions to convert typed…
permissive · top 5,000 on PyPI
openinference-instrumentation-agnoAuto-instruments Agno Agent applications to…
permissive · top 15,000 on PyPI
openinference-instrumentation-google-genaiAutomatically instruments Google GenAI SDK…
permissive · top 15,000 on PyPI
openinference-instrumentation-langchainAuto-instruments LangChain applications to…
permissive · top 5,000 on PyPI
openinference-instrumentation-mcpAuto-instruments MCP tool calls to propagate…
permissive · top 15,000 on PyPI
openinference-instrumentation-openai-agentsAuto-instruments OpenAI Agents SDK to emit…
permissive · top 5,000 on PyPI
openinference-instrumentation-portkeyAutomatically instruments Portkey AI API calls…
permissive · top 15,000 on PyPI
openinference-instrumentation-claude-agent-sdkAuto-instruments Claude Agent SDK calls to emit…
permissive · top 15,000 on PyPI
openinference-semantic-conventionsDefines semantic conventions and standardized…
permissive · top 5,000 on PyPI