# Semantic conventions for Anthropic client operations
**Status**: [Development][DocumentStatus]
- [Spans](#spans)
- [Inference](#inference)
- [Embedding](#embedding)
- [Metrics](#metrics)
The Semantic Conventions for [Anthropic](https://www.anthropic.com/) extend and override the [GenAI Semantic Conventions](README.md).
## Spans
### Inference
`gen_ai.provider.name` MUST be set to `"anthropic"` and SHOULD be provided **at span creation time**.
**Status:** 
Semantic Conventions for [Anthropic](https://www.anthropic.com/) client spans extend and override the semantic conventions for [Gen AI Spans](gen-ai-spans.md).
`gen_ai.provider.name` MUST be set to `"anthropic"` and SHOULD be provided **at span creation time**.
**Span name** SHOULD be `{gen_ai.operation.name} {gen_ai.request.model}`.
Semantic conventions for individual GenAI systems and frameworks MAY specify different span name format
and MUST follow the overall [guidelines for span names](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.56.0/specification/trace/api.md#span).
**Span kind** SHOULD be `CLIENT`.
**Span status** SHOULD follow the [Recording Errors](https://github.com/open-telemetry/semantic-conventions/blob/v1.45.0/docs/general/recording-errors.md) document.
**Requirement level:** [Recommended](https://github.com/open-telemetry/semantic-conventions/blob/v1.45.0/docs/general/signal-requirement-level.md).
**Attributes:**
| Key | Stability | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`gen_ai.operation.name`](/docs/registry/attributes/gen-ai.md) |  | `Required` | string | The name of the operation being performed. [1] | `chat`; `generate_content`; `realtime_inference` |
| [`error.type`](https://github.com/open-telemetry/semantic-conventions/blob/v1.45.0/docs/registry/attributes/error.md) |  | `Conditionally Required` If the operation ended in an error. | string | Describes a class of error the operation ended with. [2] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` |
| [`gen_ai.conversation.id`](/docs/registry/attributes/gen-ai.md) |  | `Conditionally Required` [3] | string | The unique identifier for a conversation (session, thread), used to store and correlate messages within this conversation. [4] | `conv_5j66UpCpwteGg4YSxUnt7lPY` |
| [`gen_ai.output.type`](/docs/registry/attributes/gen-ai.md) |  | `Conditionally Required` [5] | string | Represents the content type requested by the client. [6] | `text`; `json`; `image` |
| [`gen_ai.prompt.name`](/docs/registry/attributes/gen-ai.md) |  | `Conditionally Required` when a named prompt template is used | string | The name of the prompt that uniquely identifies it. | `analyze-code` |
| [`gen_ai.prompt.version`](/docs/registry/attributes/gen-ai.md) |  | `Conditionally Required` [7] | string | The version of the prompt template used. [8] | `1.0.0`; `2025-05-01`; `prod`; `v2` |
| [`gen_ai.request.choice.count`](/docs/registry/attributes/gen-ai.md) |  | `Conditionally Required` If available, in the request, and !=1. | int | The target number of candidate completions to return. | `3` |
| [`gen_ai.request.model`](/docs/registry/attributes/gen-ai.md) |  | `Conditionally Required` If available. | string | The name of the GenAI model a request is being made to. [9] | `gpt-4` |
| [`gen_ai.request.seed`](/docs/registry/attributes/gen-ai.md) |  | `Conditionally Required` If applicable and if the request includes a seed. | int | Requests with same seed value more likely to return same result. | `100` |
| [`gen_ai.request.stream`](/docs/registry/attributes/gen-ai.md) |  | `Conditionally Required` [10] | boolean | Indicates whether the GenAI request was made in streaming mode. | |
| [`server.port`](https://github.com/open-telemetry/semantic-conventions/blob/v1.45.0/docs/registry/attributes/server.md) |  | `Conditionally Required` If `server.address` is set. | int | GenAI server port. [11] | `80`; `8080`; `443` |
| [`gen_ai.conversation.compacted`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` when available | boolean | Indicates whether the effective conversation context used for this operation is a compacted view of a prior conversation. [12] | `true` |
| [`gen_ai.request.frequency_penalty`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | double | The frequency penalty setting for the GenAI request. | `0.1` |
| [`gen_ai.request.max_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | int | The maximum number of tokens the model generates for a request. | `100` |
| [`gen_ai.request.presence_penalty`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | double | The presence penalty setting for the GenAI request. | `0.1` |
| [`gen_ai.request.previous_response.id`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` [13] | string | The unique identifier of a previous response or interaction used to provide context for the current operation. [14] | `resp_0123456789aBCdef`; `interaction-123` |
| [`gen_ai.request.reasoning.level`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When applicable. | string | The reasoning or thinking effort level requested for a GenAI model. [15] | `low`; `medium`; `high` |
| [`gen_ai.request.stop_sequences`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | string[] | List of sequences that the model will use to stop generating further tokens. | `["forest", "lived"]` |
| [`gen_ai.request.temperature`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | double | The temperature setting for the GenAI request. | `0.0` |
| [`gen_ai.request.top_k`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | int | The top-K sampling setting for the GenAI request: restricts token generation at each step to the K most likely next tokens. [16] | `40` |
| [`gen_ai.request.top_p`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | double | The top_p sampling setting for the GenAI request. | `1.0` |
| [`gen_ai.response.finish_reasons`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | string[] | Array of reasons the model stopped generating tokens, corresponding to each generation received. [17] | `["stop"]`; `["stop", "length"]`; `["stop", "length", "error"]` |
| [`gen_ai.response.id`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | string | The identifier for the completion returned in the response. | `chatcmpl-123` |
| [`gen_ai.response.model`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | string | The model name returned in the response. | `gpt-4-0613` |
| [`gen_ai.response.time_to_first_chunk`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` If the request was a streaming request. | double | Time from the start of a logical inference operation to the first chunk in its streaming response, in seconds. [18] | `0.5`; `1.2` |
| [`gen_ai.usage.audio.cache_read.input_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of audio input tokens served from a provider-managed cache, as reported by the provider for this inference operation. [19] | `60` |
| [`gen_ai.usage.audio.input_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of audio input tokens, as reported by the provider for this inference operation. [20] | `120` |
| [`gen_ai.usage.audio.output_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of audio output tokens, as reported by the provider for this inference operation. [21] | `240` |
| [`gen_ai.usage.cache_read.input_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of input tokens served from a provider-managed cache, as reported by the provider for this inference operation. [22] | `50` |
| [`gen_ai.usage.cache_write.input_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of input tokens written to a provider-managed cache, as reported by the provider for this inference operation. [23] | `25` |
| [`gen_ai.usage.image.cache_read.input_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of image input tokens served from a provider-managed cache, as reported by the provider for this inference operation. [24] | `128` |
| [`gen_ai.usage.image.input_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of image input tokens, as reported by the provider for this inference operation. [25] | `258` |
| [`gen_ai.usage.image.output_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of image output tokens, as reported by the provider for this inference operation. [26] | `1290` |
| [`gen_ai.usage.input_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | int | The number of input tokens reported by the provider for this inference operation. [27] | `100` |
| [`gen_ai.usage.output_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` | int | The number of output tokens reported by the provider for this inference operation. [28] | `180` |
| [`gen_ai.usage.reasoning.output_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of output tokens used for reasoning (e.g. chain-of-thought, extended thinking), as reported by the provider for this inference operation. [29] | `50` |
| [`gen_ai.usage.text.cache_read.input_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of text input tokens served from a provider-managed cache, as reported by the provider for this inference operation. [30] | `40` |
| [`gen_ai.usage.text.input_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of text input tokens, as reported by the provider for this inference operation. [31] | `100` |
| [`gen_ai.usage.text.output_tokens`](/docs/registry/attributes/gen-ai.md) |  | `Recommended` When available and non-zero. | int | The number of text output tokens, as reported by the provider for this inference operation. [32] | `180` |
| [`server.address`](https://github.com/open-telemetry/semantic-conventions/blob/v1.45.0/docs/registry/attributes/server.md) |  | `Recommended` | string | GenAI server address. [33] | `example.com`; `10.1.2.80`; `/tmp/my.sock` |
| [`gen_ai.input.messages`](/docs/registry/attributes/gen-ai.md) |  | `Opt-In` | any | The chat history provided to the model as an input. [34] | [
{
"role": "user",
"parts": [
{
"type": "text",
"content": "Weather in Paris?"
}
]
},
{
"role": "assistant",
"parts": [
{
"type": "tool_call",
"id": "call_VSPygqKTWdrhaFErNvMV18Yl",
"name": "get_weather",
"arguments": {
"location": "Paris"
}
}
]
},
{
"role": "tool",
"parts": [
{
"type": "tool_call_response",
"id": "call_VSPygqKTWdrhaFErNvMV18Yl",
"response": "rainy, 57°F"
}
]
}
] |
| [`gen_ai.input.messages_ref`](/docs/registry/attributes/gen-ai.md) |  | `Opt-In` | string | An absolute URI identifying the input messages in external storage. [35] | `s3://example-bucket/gen-ai/674f35f4-e3f6-41f5-b104-864b3964f6d3_inputs.json` |
| [`gen_ai.output.messages`](/docs/registry/attributes/gen-ai.md) |  | `Opt-In` | any | Messages returned by the model where each message represents a specific model response (choice, candidate). [36] | [
{
"role": "assistant",
"parts": [
{
"type": "text",
"content": "The weather in Paris is currently rainy with a temperature of 57°F."
}
]
}
] |
| [`gen_ai.output.messages_ref`](/docs/registry/attributes/gen-ai.md) |  | `Opt-In` | string | An absolute URI identifying the output messages in external storage. [37] | `s3://example-bucket/gen-ai/674f35f4-e3f6-41f5-b104-864b3964f6d3_outputs.json` |
| [`gen_ai.prompt.variables`](/docs/registry/attributes/gen-ai.md) |  | `Opt-In` | any | Variables passed to the prompt template. [38] | {
"user_name": "Alice",
"language": "French"
} |
| [`gen_ai.system_instructions`](/docs/registry/attributes/gen-ai.md) |  | `Opt-In` | any | The system message or instructions provided to the GenAI model separately from the chat history. [39] | [
{
"type": "text",
"content": "You are an Agent that greet users, always use greetings tool to respond"
}
]; [
{
"type": "text",
"content": "You are a language translator."
},
{
"type": "text",
"content": "Your mission is to translate text in English to French."
}
] |
| [`gen_ai.system_instructions_ref`](/docs/registry/attributes/gen-ai.md) |  | `Opt-In` | string | An absolute URI identifying the system instructions in external storage. [40] | `s3://example-bucket/gen-ai/e68562472088cf0fec6124d5268608b01b1e248afb408e748738d39c6352d169_system_instruction.json` |
| [`gen_ai.tool.definitions`](/docs/registry/attributes/gen-ai.md) |  | `Opt-In` | any | The list of tool definitions supplied to the model for this inference operation. [41] | [
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
]
}
},
"required": [
"location",
"unit"
]
}
}
] |
| [`gen_ai.tool.definitions_ref`](/docs/registry/attributes/gen-ai.md) |  | `Opt-In` | string | An absolute URI identifying the tool definitions in external storage. [42] | `s3://example-bucket/gen-ai/b61c3b21581c79d687c07f31970d1a9482dca47756ccf014d408fd6cd091ef66_tool.definitions.json` |
**[1] `gen_ai.operation.name`:** If one of the predefined values applies, but specific system uses a different name it's RECOMMENDED to document it in the semantic conventions for specific GenAI system and use system-specific name in the instrumentation. If a different name is not documented, instrumentation libraries SHOULD use applicable predefined value.
**[2] `error.type`:** The `error.type` SHOULD match the error code returned by the Generative AI provider or the client library,
the canonical name of exception that occurred, or another low-cardinality error identifier.
Instrumentations SHOULD document the list of errors they report.
**[3] `gen_ai.conversation.id`:** If and only if the instrumented library has one readily available, or the user application provides one through OpenTelemetry context or library-specific mechanisms.
**[4] `gen_ai.conversation.id`:** Instrumentations SHOULD populate conversation id when they have an identifier
for the conversation readily available for a given operation, for example:
- when the client framework being instrumented manages conversation history
(see [LlamaIndex chat store](https://docs.llamaindex.ai/en/stable/module_guides/storing/chat_stores/),
[LangChain `session_id`](https://reference.langchain.com/python/langchain-core/runnables/history/RunnableWithMessageHistory),
and [Google ADK sessions](https://adk.dev/sessions/session))
- when instrumenting GenAI client libraries that maintain a conversation on the backend
(see [AWS Bedrock agent sessions](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-session-state.html),
[OpenAI Assistant threads](https://platform.openai.com/docs/api-reference/threads))
When no identifier for the conversation is available, instrumentations SHOULD NOT
populate conversation id. For example, a new UUID, a trace identifier, or a hash
of request content SHOULD NOT be used as a fallback value.
Application developers that manage conversation history MAY add conversation id to GenAI and other
spans or logs using custom span or log record processors or hooks provided by instrumentation
libraries.
**[5] `gen_ai.output.type`:** When applicable and if the request includes an output format.
**[6] `gen_ai.output.type`:** This attribute SHOULD be used when the client requests output of a specific type. The model may return zero or more outputs of this type.
This attribute specifies the output modality and not the actual output format. For example, if an image is requested, the actual output could be a URL pointing to an image file.
Additional output format details may be recorded in the future in the `gen_ai.output.{type}.*` attributes.
**[7] `gen_ai.prompt.version`:** when `gen_ai.prompt.name` is set and a version is available
**[8] `gen_ai.prompt.version`:** The version string can follow any versioning scheme chosen by the
application (e.g., SemVer, date-based, or platform-specific tags).
When a prompt management system is in use, this SHOULD match the
version identifier used by that system.
**[9] `gen_ai.request.model`:** The name of the GenAI model a request is being made to. If the model is supplied by a vendor, then the value must be the exact name of the model requested. If the model is a fine-tuned custom model, the value should have a more specific name than the base model that's been fine-tuned.
**[10] `gen_ai.request.stream`:** If and only if the request is streaming. If unset, the request is assumed to be non-streaming.
**[11] `server.port`:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available.
**[12] `gen_ai.conversation.compacted`:** This attribute is a positive indicator of context compaction. Instrumentations
SHOULD set it to `true` only when they can reliably determine that context
compaction was applied. Instrumentations SHOULD NOT set it to `false`; they
SHOULD leave it unset otherwise.
**[13] `gen_ai.request.previous_response.id`:** When available and if the request references a previous response.
**[14] `gen_ai.request.previous_response.id`:** Instrumentations SHOULD populate this attribute when the request references a previous response or interaction identifier to continue a conversation or pass prior context.
For example, `previous_response_id` in [OpenAI Responses API](https://developers.openai.com/api/docs/guides/conversation-state#passing-context-from-the-previous-response)
or `previous_interaction_id` in [Google GenAI Interactions API](https://ai.google.dev/gemini-api/docs/interactions-overview).
**[15] `gen_ai.request.reasoning.level`:** Corresponds to the [`output_config.effort`](https://docs.anthropic.com/en/docs/build-with-claude/effort) request parameter.
**[16] `gen_ai.request.top_k`:** This is a decoding/sampling parameter (e.g., Anthropic `top_k`, Cohere `k`, Google `topK`), not an output-shaping parameter. In particular, OpenAI's `top_logprobs` controls how many per-token log-probabilities are returned in the response and does not change generation; it MUST NOT be reported as `gen_ai.request.top_k`.
**[17] `gen_ai.response.finish_reasons`:** Values correspond to generations in the same order as the returned
choices/candidates.
For interrupted generations, instrumentations SHOULD report the
provider-reported interruption reason when available and `interrupted` otherwise.
Each position SHOULD contain the finish reason for the corresponding
choice/candidate. If a finish reason was expected but not received, for
example because generation failed, was cancelled, or a stream ended before
the final event, instrumentations SHOULD report `error` for that position
instead of omitting it.
`error` indicates that the generation ended abnormally, whether reported
by the provider or inferred by the instrumentation.
**[18] `gen_ai.response.time_to_first_chunk`:** A chunk is a decoded provider stream event carrying new, non-empty output: text, refusals, reasoning (including opaque payloads), audio, images, or tool-call names or arguments. Instrumentations MUST NOT treat empty start events or events carrying only usage, roles, IDs, signatures, keep-alives, progress/status updates, or end markers as chunks. Chunk boundaries follow provider events, not TCP reads, HTTP frames, or extra SDK callbacks.
Instrumentations SHOULD measure the time from the start of the logical inference operation, before authentication and the first attempt, to when the first chunk is fully received by the client, before application processing. The measurement SHOULD include authentication, failed attempts, and retry backoff.
Instrumentations SHOULD set this attribute when the first chunk is received and MUST NOT set it if no chunk is received.
**[19] `gen_ai.usage.audio.cache_read.input_tokens`:** The value SHOULD be included in `gen_ai.usage.cache_read.input_tokens` and in `gen_ai.usage.audio.input_tokens`.
**[20] `gen_ai.usage.audio.input_tokens`:** The value SHOULD be included in `gen_ai.usage.input_tokens`.
**[21] `gen_ai.usage.audio.output_tokens`:** The value SHOULD be included in `gen_ai.usage.output_tokens`.
**[22] `gen_ai.usage.cache_read.input_tokens`:** Anthropic reports this separately from `input_tokens`. This value MUST be added to the Anthropic `input_tokens` to compute `gen_ai.usage.input_tokens`.
**[23] `gen_ai.usage.cache_write.input_tokens`:** Anthropic reports this separately from `input_tokens`. This value MUST be added to the Anthropic `input_tokens` to compute `gen_ai.usage.input_tokens`.
**[24] `gen_ai.usage.image.cache_read.input_tokens`:** The value SHOULD be included in `gen_ai.usage.cache_read.input_tokens` and in `gen_ai.usage.image.input_tokens`.
**[25] `gen_ai.usage.image.input_tokens`:** The value SHOULD be included in `gen_ai.usage.input_tokens`.
**[26] `gen_ai.usage.image.output_tokens`:** The value SHOULD be included in `gen_ai.usage.output_tokens`.
**[27] `gen_ai.usage.input_tokens`:** Anthropic `input_tokens` excludes cached tokens. Compute:
`gen_ai.usage.input_tokens = input_tokens + cache_read_input_tokens + cache_write_input_tokens`
The same tokens can be reported on multiple types of spans. See
[how to aggregate token usage](/docs/gen-ai/gen-ai-token-metrics.md#how-to-aggregate-token-usage).
**[28] `gen_ai.usage.output_tokens`:** This value SHOULD include reasoning tokens and tokens of all modalities.
When the provider reports both billed token counts and model-consumed
token counts (for example, Cohere exposes both `usage.billed_units` and
`usage.tokens`), instrumentations SHOULD report the billed count so the
value matches the units the customer is charged for.
The same tokens can be reported on multiple types of spans. See
[how to aggregate token usage](/docs/gen-ai/gen-ai-token-metrics.md#how-to-aggregate-token-usage).
**[29] `gen_ai.usage.reasoning.output_tokens`:** The value SHOULD be included in `gen_ai.usage.output_tokens`.
**[30] `gen_ai.usage.text.cache_read.input_tokens`:** The value SHOULD be included in `gen_ai.usage.cache_read.input_tokens` and in `gen_ai.usage.text.input_tokens`.
**[31] `gen_ai.usage.text.input_tokens`:** The value SHOULD be included in `gen_ai.usage.input_tokens`.
**[32] `gen_ai.usage.text.output_tokens`:** The value SHOULD be included in `gen_ai.usage.output_tokens`.
**[33] `server.address`:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available.
**[34] `gen_ai.input.messages`:** Messages MUST be provided in the order they were sent to the model.
Instrumentations MAY provide a way for users to filter or truncate
input messages.
> [!Warning]
> This attribute is likely to contain sensitive information including user/PII data.
See [Recording content on attributes](/docs/gen-ai/gen-ai-spans.md#recording-content-on-attributes)
section for more details.
This attribute MUST be recorded as an [AnyValue](https://opentelemetry.io/docs/specs/otel/common/#anyvalue) conforming to its [JSON schema](/model/gen-ai/gen-ai-input-messages.json).
**[35] `gen_ai.input.messages_ref`:** The presence of this attribute does not indicate whether storing the
content succeeded or whether the content remains available.
It is NOT RECOMMENDED to embed credentials, such as signed URL
query parameters, in the URI. Access to the stored content SHOULD be
secured by other means, for example by storage-level access control.
> [!Warning]
> The URI may expose sensitive storage metadata, such as storage provider,
> bucket or container names, tenant or object identifiers.
**[36] `gen_ai.output.messages`:** Each message represents a single output choice/candidate generated by
the model. Each message corresponds to exactly one generation
(choice/candidate) and vice versa - one choice cannot be split across
multiple messages or one message cannot contain parts from multiple choices.
Instrumentations MAY provide a way for users to filter or truncate
output messages. `gen_ai.response.finish_reasons` remains aligned with the
generations returned by the provider, not with a filtered or truncated
`gen_ai.output.messages` value.
When an operation ends in an error, this attribute SHOULD only be set
when the operation produced output, including partial streamed output.
Instrumentation SHOULD NOT synthesize output content for a failed
operation.
> [!Warning]
> This attribute is likely to contain sensitive information including user/PII data.
See [Recording content on attributes](/docs/gen-ai/gen-ai-spans.md#recording-content-on-attributes)
section for more details.
This attribute MUST be recorded as an [AnyValue](https://opentelemetry.io/docs/specs/otel/common/#anyvalue) conforming to its [JSON schema](/model/gen-ai/gen-ai-output-messages.json).
**[37] `gen_ai.output.messages_ref`:** The presence of this attribute does not indicate whether storing the
content succeeded or whether the content remains available.
It is NOT RECOMMENDED to embed credentials, such as signed URL
query parameters, in the URI. Access to the stored content SHOULD be
secured by other means, for example by storage-level access control.
> [!Warning]
> The URI may expose sensitive storage metadata, such as storage provider,
> bucket or container names, tenant or object identifiers.
**[38] `gen_ai.prompt.variables`:**
> [!WARNING]
> This attribute may contain sensitive information.
Prompt templates are parameterized with variables that are filled in
at runtime. This attribute records the map of variable names to their
values passed to the template.
This attribute MUST be recorded as an [AnyValue](https://opentelemetry.io/docs/specs/otel/common/#anyvalue) conforming to its [JSON schema](/model/gen-ai/gen-ai-prompt-variables.json).
**[39] `gen_ai.system_instructions`:** This attribute SHOULD be used when the corresponding provider or API
allows to provide system instructions or messages separately from the
chat history.
Instructions that are part of the chat history SHOULD be recorded in
`gen_ai.input.messages` attribute instead.
Instrumentations MAY provide a way for users to filter or truncate
system instructions.
> [!Warning]
> This attribute may contain sensitive information.
See [Recording content on attributes](/docs/gen-ai/gen-ai-spans.md#recording-content-on-attributes)
section for more details.
This attribute MUST be recorded as an [AnyValue](https://opentelemetry.io/docs/specs/otel/common/#anyvalue) conforming to its [JSON schema](/model/gen-ai/gen-ai-system-instructions.json).
**[40] `gen_ai.system_instructions_ref`:** The presence of this attribute does not indicate whether storing the
content succeeded or whether the content remains available.
It is NOT RECOMMENDED to embed credentials, such as signed URL
query parameters, in the URI. Access to the stored content SHOULD be
secured by other means, for example by storage-level access control.
> [!Warning]
> The URI may expose sensitive storage metadata, such as storage provider,
> bucket or container names, tenant or object identifiers.
**[41] `gen_ai.tool.definitions`:**
> [!WARNING]
> This attribute may contain sensitive information.
Since this attribute could be large, it's NOT RECOMMENDED to populate
non-required properties by default. Instrumentations MAY provide a way
to enable populating optional properties.
This attribute MUST be recorded as an [AnyValue](https://opentelemetry.io/docs/specs/otel/common/#anyvalue) conforming to its [JSON schema](/model/gen-ai/gen-ai-tool-definitions.json).
**[42] `gen_ai.tool.definitions_ref`:** The presence of this attribute does not indicate whether storing the
content succeeded or whether the content remains available.
It is NOT RECOMMENDED to embed credentials, such as signed URL
query parameters, in the URI. Access to the stored content SHOULD be
secured by other means, for example by storage-level access control.
> [!Warning]
> The URI may expose sensitive storage metadata, such as storage provider,
> bucket or container names, tenant or object identifiers.
The following attributes can be important for making sampling decisions
and SHOULD be provided **at span creation time** (if provided at all):
* [`gen_ai.operation.name`](/docs/registry/attributes/gen-ai.md)
* [`gen_ai.request.model`](/docs/registry/attributes/gen-ai.md)
* [`server.address`](https://github.com/open-telemetry/semantic-conventions/blob/v1.45.0/docs/registry/attributes/server.md)
* [`server.port`](https://github.com/open-telemetry/semantic-conventions/blob/v1.45.0/docs/registry/attributes/server.md)
---
`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
| --- | --- | --- |
| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. |  |
---
`gen_ai.operation.name` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
| --- | --- | --- |
| `chat` | Chat completion operation such as [OpenAI Chat API](https://platform.openai.com/docs/api-reference/chat) |  |
| `create_agent` | Create GenAI agent |  |
| `create_memory` | Create new memory records |  |
| `create_memory_store` | Create or initialize a memory store |  |
| `delete_memory` | Delete memory records |  |
| `delete_memory_store` | Delete or deprovision a memory store |  |
| `embeddings` | Embeddings operation such as [OpenAI Create embeddings API](https://platform.openai.com/docs/api-reference/embeddings/create) |  |
| `execute_tool` | Execute a tool |  |
| `fetch_response` | Fetch a previously generated model response by its identifier, without performing inference, such as [OpenAI Get a model response](https://platform.openai.com/docs/api-reference/responses/get) [43] |  |
| `generate_content` | Multimodal content generation operation such as [Gemini Generate Content](https://ai.google.dev/api/generate-content) |  |
| `invoke_agent` | Invoke GenAI agent |  |
| `invoke_runner` | Invoke a framework runner that is not itself an agent or a workflow |  |
| `invoke_workflow` | Invoke GenAI workflow |  |
| `plan` | Agent planning or task decomposition phase |  |
| `realtime_inference` | Server-side model generation within a realtime, bidirectional streaming session such as [OpenAI Realtime](https://platform.openai.com/docs/guides/realtime) or [Gemini Live](https://ai.google.dev/gemini-api/docs/live). |  |
| `retrieval` | Execution of a retrieval pipeline that returns documents relevant to a query [44] |  |
| `search_memory` | Search/query memories from a memory store |  |
| `text_completion` | Text completions operation such as [OpenAI Completions API (Legacy)](https://platform.openai.com/docs/api-reference/completions) |  |
| `update_memory` | Update existing memory records |  |
| `upsert_memory` | Create or update memory records without the caller choosing which |  |
| `user_speech` | Describes the process of recording user speech input. |  |
**[43]:** Instrumentations SHOULD NOT report token usage (as attributes or metrics) for this operation.
**[44]:** Examples include LangChain, LlamaIndex, and Haystack retrievers.
A retrieval pipeline usually combines other operations such as embeddings,
database queries, web search, or reranking. These operations SHOULD be
reported following their own conventions.
---
`gen_ai.output.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
| --- | --- | --- |
| `image` | Image |  |
| `json` | JSON object with known or unknown schema |  |
| `speech` | Speech |  |
| `text` | Plain text |  |
### Embedding
See [common embedding span definition](./client-embeddings.md#span-gen_aiclientembeddings).
## Metrics
Anthropic metrics follow generic [Generative AI metrics](gen-ai-metrics.md).
[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status