View Source OpenTelemetry.SemConv.Incubating.GenAiAttributes (OpenTelemetry.SemConv v1.27.0)

OpenTelemetry Semantic Conventions for Gen_Ai attributes.

Summary

Types

The name of the operation being performed.

The Generative AI product as identified by the client or server instrumentation.

The type of token being counted.

Functions

The full response received from the GenAI model.

The name of the operation being performed.

The full prompt sent to the GenAI model.

The frequency penalty setting for the GenAI request.

The maximum number of tokens the model generates for a request.

The name of the GenAI model a request is being made to.

The presence penalty setting for the GenAI request.

List of sequences that the model will use to stop generating further tokens.

The temperature setting for the GenAI request.

The top_k sampling setting for the GenAI request.

The top_p sampling setting for the GenAI request.

Array of reasons the model stopped generating tokens, corresponding to each generation received.

The unique identifier for the completion.

The name of the model that generated the response.

The Generative AI product as identified by the client or server instrumentation.

The type of token being counted.

The number of tokens used in the GenAI input (prompt).

The number of tokens used in the GenAI response (completion).

Types

Link to this type

gen_ai_operation_name_values()

View Source
@type gen_ai_operation_name_values() :: %{
  chat: :chat,
  text_completion: :text_completion
}

The name of the operation being performed.

Enum Values

Link to this type

gen_ai_system_values()

View Source
@type gen_ai_system_values() :: %{
  openai: :openai,
  vertex_ai: :vertex_ai,
  anthropic: :anthropic,
  cohere: :cohere
}

The Generative AI product as identified by the client or server instrumentation.

Enum Values

  • :openai e - OpenAI
  • :vertex_ai e - Vertex AI
  • :anthropic e - Anthropic
  • :cohere e - Cohere
Link to this type

gen_ai_token_type_values()

View Source
@type gen_ai_token_type_values() :: %{input: :input, completion: :output}

The type of token being counted.

Enum Values

  • :input e - Input tokens (prompt, input, etc.)
  • :completion e - Output tokens (completion, response, etc.)

Functions

@spec gen_ai_completion() :: :"gen_ai.completion"

The full response received from the GenAI model.

Value type

Value must be of type atom() | String.t().

Notes

It's RECOMMENDED to format completions as JSON string matching OpenAI messages format

Examples

["[{'role': 'assistant', 'content': 'The capital of France is Paris.'}]"]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_completion()
:"gen_ai.completion"
@spec gen_ai_operation_name() :: :"gen_ai.operation.name"

The name of the operation being performed.

Notes

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.

iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_operation_name()
:"gen_ai.operation.name"

iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_operation_name_values().chat
:chat

iex> %{OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_operation_name() => OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_operation_name_values().chat}
%{:"gen_ai.operation.name" => :chat}
Link to this function

gen_ai_operation_name_values()

View Source
@spec gen_ai_operation_name_values() :: gen_ai_operation_name_values()
@spec gen_ai_prompt() :: :"gen_ai.prompt"

The full prompt sent to the GenAI model.

Value type

Value must be of type atom() | String.t().

Notes

It's RECOMMENDED to format prompts as JSON string matching OpenAI messages format

Examples

["[{'role': 'user', 'content': 'What is the capital of France?'}]"]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_prompt()
:"gen_ai.prompt"
Link to this function

gen_ai_request_frequency_penalty()

View Source
@spec gen_ai_request_frequency_penalty() :: :"gen_ai.request.frequency_penalty"

The frequency penalty setting for the GenAI request.

Value type

Value must be of type float().

Examples

[0.1]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_request_frequency_penalty()
:"gen_ai.request.frequency_penalty"
Link to this function

gen_ai_request_max_tokens()

View Source
@spec gen_ai_request_max_tokens() :: :"gen_ai.request.max_tokens"

The maximum number of tokens the model generates for a request.

Value type

Value must be of type integer().

Examples

[100]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_request_max_tokens()
:"gen_ai.request.max_tokens"
@spec gen_ai_request_model() :: :"gen_ai.request.model"

The name of the GenAI model a request is being made to.

Value type

Value must be of type atom() | String.t().

Examples

gpt-4
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_request_model()
:"gen_ai.request.model"
Link to this function

gen_ai_request_presence_penalty()

View Source
@spec gen_ai_request_presence_penalty() :: :"gen_ai.request.presence_penalty"

The presence penalty setting for the GenAI request.

Value type

Value must be of type float().

Examples

[0.1]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_request_presence_penalty()
:"gen_ai.request.presence_penalty"
Link to this function

gen_ai_request_stop_sequences()

View Source
@spec gen_ai_request_stop_sequences() :: :"gen_ai.request.stop_sequences"

List of sequences that the model will use to stop generating further tokens.

Value type

Value must be of type [atom() | String.t()].

Examples

["forest", "lived"]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_request_stop_sequences()
:"gen_ai.request.stop_sequences"
Link to this function

gen_ai_request_temperature()

View Source
@spec gen_ai_request_temperature() :: :"gen_ai.request.temperature"

The temperature setting for the GenAI request.

Value type

Value must be of type float().

Examples

[0.0]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_request_temperature()
:"gen_ai.request.temperature"
@spec gen_ai_request_top_k() :: :"gen_ai.request.top_k"

The top_k sampling setting for the GenAI request.

Value type

Value must be of type float().

Examples

[1.0]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_request_top_k()
:"gen_ai.request.top_k"
@spec gen_ai_request_top_p() :: :"gen_ai.request.top_p"

The top_p sampling setting for the GenAI request.

Value type

Value must be of type float().

Examples

[1.0]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_request_top_p()
:"gen_ai.request.top_p"
Link to this function

gen_ai_response_finish_reasons()

View Source
@spec gen_ai_response_finish_reasons() :: :"gen_ai.response.finish_reasons"

Array of reasons the model stopped generating tokens, corresponding to each generation received.

Value type

Value must be of type [atom() | String.t()].

Examples

["stop"]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_response_finish_reasons()
:"gen_ai.response.finish_reasons"
@spec gen_ai_response_id() :: :"gen_ai.response.id"

The unique identifier for the completion.

Value type

Value must be of type atom() | String.t().

Examples

["chatcmpl-123"]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_response_id()
:"gen_ai.response.id"
@spec gen_ai_response_model() :: :"gen_ai.response.model"

The name of the model that generated the response.

Value type

Value must be of type atom() | String.t().

Examples

["gpt-4-0613"]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_response_model()
:"gen_ai.response.model"
@spec gen_ai_system() :: :"gen_ai.system"

The Generative AI product as identified by the client or server instrumentation.

Notes

The gen_ai.system describes a family of GenAI models with specific model identified
by gen_ai.request.model and gen_ai.response.model attributes.

The actual GenAI product may differ from the one identified by the client.
For example, when using OpenAI client libraries to communicate with Mistral, the gen_ai.system
is set to openai based on the instrumentation's best knowledge.

For custom model, a custom friendly name SHOULD be used.
If none of these options apply, the gen_ai.system SHOULD be set to _OTHER.

Examples

openai
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_system()
:"gen_ai.system"

iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_system_values().openai
:openai

iex> %{OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_system() => OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_system_values().openai}
%{:"gen_ai.system" => :openai}
@spec gen_ai_system_values() :: gen_ai_system_values()
@spec gen_ai_token_type() :: :"gen_ai.token.type"

The type of token being counted.

Examples

["input", "output"]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_token_type()
:"gen_ai.token.type"

iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_token_type_values().input
:input

iex> %{OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_token_type() => OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_token_type_values().input}
%{:"gen_ai.token.type" => :input}
Link to this function

gen_ai_token_type_values()

View Source
@spec gen_ai_token_type_values() :: gen_ai_token_type_values()
Link to this function

gen_ai_usage_completion_tokens()

View Source
This function is deprecated. Replaced by `gen_ai.usage.output_tokens` attribute. .
@spec gen_ai_usage_completion_tokens() :: :"gen_ai.usage.completion_tokens"
Link to this function

gen_ai_usage_input_tokens()

View Source
@spec gen_ai_usage_input_tokens() :: :"gen_ai.usage.input_tokens"

The number of tokens used in the GenAI input (prompt).

Value type

Value must be of type integer().

Examples

[100]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_usage_input_tokens()
:"gen_ai.usage.input_tokens"
Link to this function

gen_ai_usage_output_tokens()

View Source
@spec gen_ai_usage_output_tokens() :: :"gen_ai.usage.output_tokens"

The number of tokens used in the GenAI response (completion).

Value type

Value must be of type integer().

Examples

[180]
iex> OpenTelemetry.SemConv.Incubating.GenAiAttributes.gen_ai_usage_output_tokens()
:"gen_ai.usage.output_tokens"
Link to this function

gen_ai_usage_prompt_tokens()

View Source
This function is deprecated. Replaced by `gen_ai.usage.input_tokens` attribute. .
@spec gen_ai_usage_prompt_tokens() :: :"gen_ai.usage.prompt_tokens"