Registry / observability / openinference-semantic-conventions

openinference-semantic-conventions

JSON →
library0.1.33pypypi✓ verified 25d ago

OpenInference Semantic Conventions defines a standardized set of attributes and event names for capturing telemetry data related to AI/ML and LLM applications, building on OpenTelemetry standards. It provides a common vocabulary for observability across different AI frameworks. The current version is 0.1.28 and it is part of an actively developed monorepo with frequent releases for various instrumentations.

pip install openinference-semantic-conventions
INSTALL
IMPORT
SIG · OPENINFERENCE-SEMA
O
openinference-semantic-conventions
observabilitypythonv0.1.33
Install
1.6s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.33 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.002s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.002s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SpanAttributes
from openinference.semconv.trace import SpanAttributes
Provides constants for span-level attributes relevant to AI/ML operations.
ResourceAttributes
from openinference.semconv.resource import ResourceAttributes
Provides constants for resource-level attributes describing the environment or service.
EventAttributes
from openinference.semconv.trace import EventAttributes
Provides constants for event-level attributes, useful for annotating specific occurrences within a span.

This quickstart demonstrates how to use `openinference-semantic-conventions` constants to annotate an OpenTelemetry span. It requires an OpenTelemetry SDK to be configured to process and export the traces. The example configures a `ConsoleSpanExporter` for easy verification.

import opentelemetry.trace as trace from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor from openinference.semconv.trace import SpanAttributes, EventAttributes # Configure OpenTelemetry Tracer (for demonstration purposes) provider = TracerProvider() processor = SimpleSpanProcessor(ConsoleSpanExporter()) provider.add_span_processor(processor) trace.set_tracer_provider(provider) tracer = trace.get_tracer(__name__) # Example: Tracing an LLM call with OpenInference Semantic Conventions with tracer.start_as_current_span("my-llm-generation") as span: span.set_attribute(SpanAttributes.LLM_MODEL_NAME, "gpt-4") span.set_attribute(SpanAttributes.LLM_VENDOR, "OpenAI") span.set_attribute(SpanAttributes.LLM_REQUEST_TYPE, "completion") span.set_attribute(SpanAttributes.INPUT_VALUE, "What is the capital of France?") span.set_attribute(SpanAttributes.OUTPUT_VALUE, "Paris.") span.set_attribute(SpanAttributes.TOKEN_COUNT_TOTAL, 5) span.add_event("tool_call", attributes={ EventAttributes.TOOL_CALL_NAME: "search_engine", EventAttributes.TOOL_CALL_ARGUMENTS: '{"query": "capital of France"}' }) print("OpenInference-compliant trace emitted to console.")
Debug
Known issues
breakingAs a 0.x release, the OpenInference semantic conventions may undergo non-backward compatible changes. Attribute names or their expected values could change between minor versions.
fix
Always review the `openinference-semantic-conventions` changelog and the official OpenInference specification when upgrading to ensure your attribute usage remains compliant.
affects: 0.1.x
gotchaThis library solely defines constants for semantic conventions. It must be used in conjunction with an OpenTelemetry SDK (e.g., `opentelemetry-sdk`) to actually capture and export traces. Installing this package alone will not emit any telemetry.
fix
Ensure you have `opentelemetry-api` and an OpenTelemetry SDK installed and properly configured, and use a `Tracer` to set attributes. For example, `pip install opentelemetry-sdk opentelemetry-exporter-otlp`.
affects: All versions
gotchaIt's crucial to correctly identify which specific attribute constant applies to your data (e.g., `SpanAttributes.LLM_MODEL_NAME` vs. `SpanAttributes.LLM_VENDOR`). Using the wrong attribute, even if similar, can lead to incorrect interpretation by observability platforms.
fix
Refer to the official OpenInference specification and documentation for precise definitions and usage guidelines of each semantic attribute. Avoid guessing attribute names.
affects: All versions
Errors
Common errors & fixes
AttributeError: type object 'SpanAttributes' has no attribute 'LLM_REQUEST_MODEL'
This error occurs when the `SpanAttributes` class in the installed `openinference-semantic-conventions` library version does not contain an attribute named `LLM_REQUEST_MODEL`. This can happen due to API changes where the attribute was renamed, removed, or was never part of that specific version.
fix
Update your `openinference-semantic-conventions` library to the latest version or consult the official documentation for the exact attribute names available in your installed version. For example, ensuring dependent packages are updated to compatible versions might resolve this.
ModuleNotFoundError: No module named 'semantic_conventions'
The `openinference-semantic-conventions` library is installed, but the import statement incorrectly omits the top-level `openinference` package, attempting to import `semantic_conventions` as a direct package.
fix
Correct the import statement to include the `openinference` prefix, for example: `from openinference.semantic_conventions.trace import SpanAttributes` or `import openinference.semantic_conventions`.
ImportError: cannot import name 'SpanAttributes' from 'openinference.semantic_conventions'
The `SpanAttributes` class is defined within a submodule (e.g., `trace.py`) inside the `openinference.semantic_conventions` package, but the user is trying to import it directly from the parent `openinference.semantic_conventions` package.
fix
Import the `SpanAttributes` class from its specific submodule where it is defined, such as `from openinference.semantic_conventions.trace import SpanAttributes`.
Upgrade
Version history
0.1.33latest on PyPI · released Aug 24, 2026
Audit
Dependencies
opentelemetry-apirequiredRequired for interacting with OpenTelemetry's tracing API, which is necessary to apply the defined semantic conventions.
Agent activity
25 hits · last 30 days
node
20
OpenAI (training)
2
Resources
openinference-semantic-conventions — pip install openinference-semantic-conventions · libregistry