--- id: opentelemetry-instrumentation-openai-v2 version: "2.4b0" license: Apache-2.0 license_treatment: permissive maintenance: active --- # opentelemetry-instrumentation-openai-v2 — OpenTelemetry Official OpenAI instrumentation License: permissive · Maintenance: active · Downloads: 1.9M/mo ## What it is and what it does This package integrates OpenTelemetry tracing into applications using the OpenAI Python SDK or compatible LLM platforms. When installed and initialized, it automatically captures spans for chat completions, embeddings, and other API operations, recording metrics like token usage and operation duration. It works with OpenAI-compatible services including Azure OpenAI, Gemini, Perplexity, xAI, DeepSeek, Groq, and MistralAI when accessed through the OpenAI SDK. The instrumentation is configured via environment variables to control what telemetry is captured—by default it traces operations without capturing message content, but you can enable content logging as events or span attributes. It requires an existing OpenTelemetry setup (tracing, logging, and events configured) to emit the captured telemetry. The package is in Beta status and aligns with OpenTelemetry Semantic Conventions v1.30.0, with experimental features available through opt-in environment variables. Use it for: - Monitor and debug OpenAI API calls in production applications by viewing traces of chat completions and embeddings. - Track token consumption across LLM operations for cost analysis and quota management. - Correlate LLM requests with other application traces in a centralized observability platform. - Audit and log prompt and completion content when compliance or debugging requires it. - Observe applications using OpenAI-compatible services (Groq, Gemini, etc.) with a single instrumentation. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Automatically traces and logs OpenAI API calls (and compatible platforms like Azure OpenAI, Gemini, Groq) with OpenTelemetry, capturing request spans, token counts, and operation duration. Yes, if you already have OpenTelemetry configured in your application and need visibility into OpenAI or compatible LLM API calls. The low install friction, active maintenance, permissive license, and zero known vulnerabilities make it safe to adopt. Not necessary if you have no OpenTelemetry setup or do not use the OpenAI SDK. ## Install pip install opentelemetry-instrumentation-openai-v2 uv add opentelemetry-instrumentation-openai-v2 poetry add opentelemetry-instrumentation-openai-v2 ## Installing opentelemetry-instrumentation-openai-v2 Before you install: Low friction installation with four stable OpenTelemetry dependencies already in the ecosystem. Active maintenance (last commit 2026-08-14) and no known vulnerabilities. Requires Python 3.10 or later. License in practice: Apache-2.0 permissive license allows use in most commercial and open-source projects without significant restrictions. Quickstart: pip install opentelemetry-instrumentation-openai-v2 from opentelemetry.instrumentation.openai_v2 import OpenAIInstrumentor from openai import OpenAI OpenAIInstrumentor().instrument() client = OpenAI() response = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello"}] ) Requires OpenTelemetry tracing, logging, and events to be configured before instrumentation will emit telemetry. Requires Python 3.10 or later. Verify before relying: - Whether the package works with all listed OpenAI-compatible platforms (Azure OpenAI, Gemini, Perplexity, xAI, DeepSeek, Groq, MistralAI) equally well or if some have limitations. - Performance overhead of instrumentation on high-volume LLM applications. - Whether the optional upload hook for prompts/completions (requiring fsspec) is production-ready. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags openai api tracing, llm instrumentation opentelemetry, openai request monitoring, genai observability, opentelemetry llm logging, api call tracing, token usage metrics, observability, llm-monitoring, instrumentation [View on SkillFed](https://skillfed.io/packages/opentelemetry-instrumentation-openai-v2) · [View on PyPI](https://pypi.org/project/opentelemetry-instrumentation-openai-v2/)