groups:
  - id: registry.gen_ai
    prefix: gen_ai
    type: attribute_group
    brief: >
      This document defines the attributes used to describe telemetry in the context of Generative Artificial Intelligence (GenAI) Models requests and responses.
    attributes:
      - id: system
        stability: experimental
        type:
          members:
            - id: openai
              stability: experimental
              value: "openai"
              brief: 'OpenAI'
            - id: vertex_ai
              stability: experimental
              value: "vertex_ai"
              brief: 'Vertex AI'
            - id: anthropic
              stability: experimental
              value: "anthropic"
              brief: 'Anthropic'
            - id: cohere
              stability: experimental
              value: "cohere"
              brief: 'Cohere'
        brief: The Generative AI product as identified by the client or server instrumentation.
        note: >
          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'
      - id: request.model
        stability: experimental
        type: string
        brief: The name of the GenAI model a request is being made to.
        examples: 'gpt-4'
      - id: request.max_tokens
        stability: experimental
        type: int
        brief: The maximum number of tokens the model generates for a request.
        examples: [100]
      - id: request.temperature
        stability: experimental
        type: double
        brief: The temperature setting for the GenAI request.
        examples: [0.0]
      - id: request.top_p
        stability: experimental
        type: double
        brief: The top_p sampling setting for the GenAI request.
        examples: [1.0]
        tag: llm-generic-request
      - id: request.top_k
        stability: experimental
        type: double
        brief: The top_k sampling setting for the GenAI request.
        examples: [1.0]
      - id: request.stop_sequences
        stability: experimental
        type: string[]
        brief: List of sequences that the model will use to stop generating further tokens.
        examples: ['forest', 'lived']
      - id: request.frequency_penalty
        stability: experimental
        type: double
        brief: The frequency penalty setting for the GenAI request.
        examples: [0.1]
      - id: request.presence_penalty
        stability: experimental
        type: double
        brief: The presence penalty setting for the GenAI request.
        examples: [0.1]
      - id: response.id
        stability: experimental
        type: string
        brief: The unique identifier for the completion.
        examples: ['chatcmpl-123']
      - id: response.model
        stability: experimental
        type: string
        brief: The name of the model that generated the response.
        examples: ['gpt-4-0613']
      - id: response.finish_reasons
        stability: experimental
        type: string[]
        brief: Array of reasons the model stopped generating tokens, corresponding to each generation received.
        examples: ['stop']
      - id: usage.prompt_tokens
        stability: experimental
        type: int
        brief: The number of tokens used in the GenAI input or prompt.
        examples: [100]
      - id: usage.completion_tokens
        stability: experimental
        type: int
        brief: The number of tokens used in the GenAI response (completion).
        examples: [180]
      - id: token.type
        stability: experimental
        type:
          members:
            - id: input
              stability: experimental
              value: "input"
              brief: 'Input tokens (prompt, input, etc.)'
            - id: completion
              stability: experimental
              value: "output"
              brief: 'Output tokens (completion, response, etc.)'
        brief: The type of token being counted.
        examples: ['input', 'output']
      - id: prompt
        stability: experimental
        type: string
        brief: The full prompt sent to the GenAI model.
        note: It's RECOMMENDED to format prompts as JSON string matching [OpenAI messages format](https://platform.openai.com/docs/guides/text-generation)
        examples: ["[{'role': 'user', 'content': 'What is the capital of France?'}]"]
      - id: completion
        stability: experimental
        type: string
        brief: The full response received from the GenAI model.
        note: It's RECOMMENDED to format completions as JSON string matching [OpenAI messages format](https://platform.openai.com/docs/guides/text-generation)
        examples: ["[{'role': 'assistant', 'content': 'The capital of France is Paris.'}]"]
      - id: operation.name
        stability: experimental
        type: string
        brief: The name of the operation being performed.
        examples: ['chat', 'completion']
