Skip to content

How to access the annotations from ChatOpenAI messages? #414

@lud-wj

Description

@lud-wj

I would like to know if it is possible to retrieve the annotations from the chain result.

Thank you

RAW REQ RESPONSE: %Req.Response{
  status: 200,
  headers: %{
  # ...
  },
  body: %{
    "choices" => [
      %{
        "finish_reason" => "stop",
        "index" => 0,
        "message" => %{
          "annotations" => [],                                # <-- HERE - I would like to retrieve that field
          "content" => "Hello! How can I help you today?",
          "refusal" => nil,
          "role" => "assistant"
        }
      }
    ],
    "created" => 1764872609,
    "id" => "chatcmpl...",
    "model" => "gpt-5-search-api-2025-10-14",
    "object" => "chat.completion",
    "system_fingerprint" => nil,
    "usage" => %{
      "completion_tokens" => 13,
      "completion_tokens_details" => %{
        "accepted_prediction_tokens" => 0,
        "audio_tokens" => 0,
        "reasoning_tokens" => 0,
        "rejected_prediction_tokens" => 0
      },
      "prompt_tokens" => 1564,
      "prompt_tokens_details" => %{"audio_tokens" => 0, "cached_tokens" => 0},
      "total_tokens" => 1577
    }
  },
  trailers: %{},
  private: %{}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions