{"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":"en","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,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}