openinference

Embedding Spans

Embedding spans capture operations that generate vector embeddings from text, images, or other inputs.

Required Attributes

All embedding spans MUST include:

Common Attributes

Embedding spans typically include:

Privacy Considerations

When OPENINFERENCE_HIDE_EMBEDDING_VECTORS is set to true:

When OPENINFERENCE_HIDE_INPUT_TEXT is set to true:

Example

A span for generating embeddings with OpenAI:

{
    "name": "CreateEmbeddingResponse",
    "span_kind": "SPAN_KIND_INTERNAL",
    "attributes": {
        "openinference.span.kind": "EMBEDDING",
        "llm.system": "openai",
        "llm.model_name": "text-embedding-3-small",
        "input.value": "{\"input\": \"hello world\", \"model\": \"text-embedding-3-small\", \"encoding_format\": \"base64\"}",
        "input.mime_type": "application/json",
        "llm.invocation_parameters": "{\"model\": \"text-embedding-3-small\", \"encoding_format\": \"base64\"}",
        "embedding.model_name": "text-embedding-3-small",
        "embedding.text": "hello world",
        "embedding.vector": "[0.1, 0.2, 0.3, ...]"
    }
}

For batch embedding operations, the embeddings are flattened:

{
    "attributes": {
        "embedding.embeddings.0.embedding.text": "first text",
        "embedding.embeddings.0.embedding.vector": "[0.1, 0.2, ...]",
        "embedding.embeddings.1.embedding.text": "second text", 
        "embedding.embeddings.1.embedding.vector": "[0.3, 0.4, ...]"
    }
}