Registry /
observability / openinference-semantic-conventions
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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.002s · 17.9MB
glibcpy 3.10–3.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.")
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.
fixUpdate 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.
fixCorrect 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.
fixImport 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.