struct

Anthropic::Metadata

Inherits Struct < Value < Object

Request metadata for the Anthropic API.

Contains user_id for end-user identification (used for abuse monitoring) and an optional custom hash for arbitrary key-value metadata.

Usage

# With user_id only
metadata = Anthropic::Metadata.with_user_id("user-123")

# With user_id and custom fields
metadata = Anthropic::Metadata.new(
  user_id: "user-123",
  custom: {"session_id" => JSON::Any.new("abc")}
)

Constructors

new(user_id : String | Nil = nil, custom : Hash(String, JSON::Any) | Nil = nil)
Source
with_user_id(user_id : String) : Metadata

Convenience constructor for just user_id.

Source

Instance methods

custom
Source
to_json(json : JSON::Builder) : Nil
Source
user_id
Source