class

Anthropic::Beta::MessagesAPI

Inherits Reference < Object

Beta namespace wrapper for Messages API.

Provides access to Messages API methods and sub-resources (e.g. batches) through the beta namespace, automatically merging beta headers into all requests.

Usage

client = Anthropic::Client.new

# Access messages API with beta headers
response = client.beta.messages.create(request)

# Stream with beta headers
client.beta.messages.stream(request) { |event| puts event }

# Access batches through beta.messages namespace
batch = client.beta.messages.batches.create(request)

# With custom beta headers
batch = client.beta(["custom-feature"]).messages.batches.list

Constructors

new(client : Client, namespace_beta_headers : Array(String))
Source

Instance methods

batches

Access the Batches API through the beta messages namespace.

Returns a Beta::BatchesAPI that automatically merges beta headers into all batch requests.

Example:

client.beta.messages.batches.create(request)
client.beta(["custom-beta"]).messages.batches.list
Source
count_tokens(request : Messages::CountTokensRequest, request_options : RequestOptions | Nil = nil) : Messages::CountTokensResponse

Count tokens with beta headers automatically merged.

Beta namespace headers are merged with any per-request options. See Messages::API#count_tokens for full parameter documentation.

Source
count_tokens(model : Model | String, messages : Array(Message), system : String | Nil = nil, request_options : RequestOptions | Nil = nil) : Messages::CountTokensResponse

Count tokens with beta headers automatically merged (convenience overload).

Beta namespace headers are merged with any per-request options. See Messages::API#count_tokens for full parameter documentation.

Source
create(model : Model | String, messages : Array(Message), max_tokens : Int32, request_options : RequestOptions | Nil = nil, **options) : Messages::Response

Create a message with beta headers automatically merged (convenience overload).

Beta namespace headers are merged with any per-request options. See Messages::API#create for full parameter documentation.

Source
create(request : Messages::Request, request_options : RequestOptions | Nil = nil) : Messages::Response

Create a message with beta headers automatically merged.

Beta namespace headers are merged with any per-request options. See Messages::API#create for full parameter documentation.

Source
stream(model : Model | String, messages : Array(Message), max_tokens : Int32, request_options : RequestOptions | Nil = nil, **options, &block : StreamEvent -> ) : Nil

Stream a message with beta headers automatically merged (convenience overload).

Beta namespace headers are merged with any per-request options. See Messages::API#stream for full parameter documentation.

Source
stream(request : Messages::Request, request_options : RequestOptions | Nil = nil, &block : StreamEvent -> ) : Nil

Stream a message with beta headers automatically merged.

Beta namespace headers are merged with any per-request options. See Messages::API#stream for full parameter documentation.

Source