{"id":2147,"library":"openinference-semantic-conventions","title":"OpenInference Semantic Conventions","description":"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.","status":"active","version":"0.1.28","language":"python","source_language":"en","source_url":"https://github.com/Arize-ai/openinference/tree/main/python/openinference-semantic-conventions","tags":["OpenTelemetry","observability","AI/ML","LLM","semantic-conventions","tracing"],"install":[{"cmd":"pip install openinference-semantic-conventions","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for interacting with OpenTelemetry's tracing API, which is necessary to apply the defined semantic conventions.","package":"opentelemetry-api","optional":false}],"imports":[{"note":"Provides constants for span-level attributes relevant to AI/ML operations.","symbol":"SpanAttributes","correct":"from openinference.semconv.trace import SpanAttributes"},{"note":"Provides constants for resource-level attributes describing the environment or service.","symbol":"ResourceAttributes","correct":"from openinference.semconv.resource import ResourceAttributes"},{"note":"Provides constants for event-level attributes, useful for annotating specific occurrences within a span.","symbol":"EventAttributes","correct":"from openinference.semconv.trace import EventAttributes"}],"quickstart":{"code":"import opentelemetry.trace as trace\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor\nfrom openinference.semconv.trace import SpanAttributes, EventAttributes\n\n# Configure OpenTelemetry Tracer (for demonstration purposes)\nprovider = TracerProvider()\nprocessor = SimpleSpanProcessor(ConsoleSpanExporter())\nprovider.add_span_processor(processor)\ntrace.set_tracer_provider(provider)\ntracer = trace.get_tracer(__name__)\n\n# Example: Tracing an LLM call with OpenInference Semantic Conventions\nwith tracer.start_as_current_span(\"my-llm-generation\") as span:\n    span.set_attribute(SpanAttributes.LLM_MODEL_NAME, \"gpt-4\")\n    span.set_attribute(SpanAttributes.LLM_VENDOR, \"OpenAI\")\n    span.set_attribute(SpanAttributes.LLM_REQUEST_TYPE, \"completion\")\n    span.set_attribute(SpanAttributes.INPUT_VALUE, \"What is the capital of France?\")\n    span.set_attribute(SpanAttributes.OUTPUT_VALUE, \"Paris.\")\n    span.set_attribute(SpanAttributes.TOKEN_COUNT_TOTAL, 5)\n    span.add_event(\"tool_call\", attributes={\n        EventAttributes.TOOL_CALL_NAME: \"search_engine\",\n        EventAttributes.TOOL_CALL_ARGUMENTS: '{\"query\": \"capital of France\"}'\n    })\nprint(\"OpenInference-compliant trace emitted to console.\")","lang":"python","description":"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."},"warnings":[{"fix":"Always review the `openinference-semantic-conventions` changelog and the official OpenInference specification when upgrading to ensure your attribute usage remains compliant.","message":"As 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.","severity":"breaking","affected_versions":"0.1.x"},{"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`.","message":"This 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the official OpenInference specification and documentation for precise definitions and usage guidelines of each semantic attribute. Avoid guessing attribute names.","message":"It'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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.1.28':45 'across':37 'activ':52 'ai':39 'ai/ml':22,63 'applic':25 'attribut':12 'build':26 'captur':17 'common':33 'convent':3,6,67 'current':42 'data':19 'defin':7 'develop':53 'differ':38 'event':14 'framework':40 'frequent':56 'instrument':60 'llm':24,64 'monorepo':54 'name':15 'observ':36,62 'openinfer':1,4 'opentelemetri':28,61 'part':49 'provid':31 'relat':20 'releas':57 'semant':2,5,66 'semantic-convent':65 'set':10 'standard':9,29 'telemetri':18 'trace':68 'various':59 'version':43 'vocabulari':34","created_at":"2026-04-09T18:45:31.880198+00:00","updated_at":"2026-04-16T17:36:07.326527+00:00","problems":[{"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.","cause":"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.","error":"AttributeError: type object 'SpanAttributes' has no attribute 'LLM_REQUEST_MODEL'"},{"fix":"Correct the import statement to include the `openinference` prefix, for example: `from openinference.semantic_conventions.trace import SpanAttributes` or `import openinference.semantic_conventions`.","cause":"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.","error":"ModuleNotFoundError: No module named 'semantic_conventions'"},{"fix":"Import the `SpanAttributes` class from its specific submodule where it is defined, such as `from openinference.semantic_conventions.trace import SpanAttributes`.","cause":"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.","error":"ImportError: cannot import name 'SpanAttributes' from 'openinference.semantic_conventions'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.33","cli_name":"","cli_version":null,"type":"library","homepage":"https://openinference.com","github":"https://github.com/Arize-ai/openinference","docs":null,"changelog":null,"pypi":"https://pypi.org/project/openinference-semantic-conventions/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability","ai-ml","llm-agents"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}