openinference-semantic-conventions package defines standardized attributes for tracing AI/ML applications using OpenTelemetry.
Installation
SpanAttributes
TheSpanAttributes class contains attribute keys for annotating spans with metadata about LLM calls, embeddings, retrievals, and more.
Import
Core Attributes
LLM Attributes
Attributes specific to Large Language Model operations:Embedding Attributes
Retrieval Attributes
Tool Attributes
OpenInferenceSpanKindValues
TheOpenInferenceSpanKindValues enum defines the types of operations in an AI application:
Usage Example
Message Attributes
For detailed message content:Document Attributes
For retrieval results:Additional Attribute Classes
MessageContentAttributes- Multi-modal message content (text, images)ImageAttributes- Image URLs and dataAudioAttributes- Audio files and transcriptsEmbeddingAttributes- Individual embedding vectorsRerankerAttributes- Reranker inputs/outputsToolCallAttributes- Function call detailsPromptAttributes- Completion API promptsChoiceAttributes- Completion API choices