--- id: openinference-instrumentation-openai version: "0.1.54" license: Apache-2.0 license_treatment: permissive maintenance: active --- # openinference-instrumentation-openai — OpenInference OpenAI Instrumentation License: permissive · Maintenance: active · Downloads: 2.2M/mo ## 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 above — 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 pip install openinference-instrumentation-openai uv add openinference-instrumentation-openai 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_current - Install friction: low - Maintenance: active - Downloads: 2.2M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags openai tracing instrumentation, llm observability opentelemetry, openai api monitoring traces, opentelemetry openai integration, ai call tracing and debugging, openai span collection, llm request tracking, llm-observability, opentelemetry, tracing [View on SkillFed](https://skillfed.io/packages/openinference-instrumentation-openai) · [View on PyPI](https://pypi.org/project/openinference-instrumentation-openai/)