class

Anthropic::Beta::API

Inherits Reference < Object

Beta namespace for opt-in access to beta-only API features.

The beta namespace provides a clean interface for accessing features that require beta headers, automatically injecting the appropriate headers.

Usage

client = Anthropic::Client.new

# Access skills through beta namespace
skills = client.beta.skills.list

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

# Use with additional beta headers
options = client.beta.options(["future-feature-2025-01-01"])
client.messages.create(request, request_options: options)

Constructors

new(client : Client, beta_headers : Array(String) = [] of String)

Create a beta API wrapper.

Parameters:

  • client: The Anthropic client to wrap
  • beta_headers: Default beta headers to include in all requests
Source

Instance methods

beta_headers

Returns a copy of the beta headers to prevent external mutation.

Source
client
Source
files

Access the Files API through the beta namespace.

File operations performed through this accessor automatically include the beta namespace headers in every request. This is useful for accessing file features that require beta opt-in.

Example:

file = client.beta(["files-beta-2025"]).files.upload("doc.txt", "content")
file = client.beta(["files-beta-2025"]).files.retrieve("file_123")
Source
merge_options(options : RequestOptions | Nil) : RequestOptions

Merge beta headers into existing request options.

Takes an existing RequestOptions and returns a new one with beta headers merged in. Useful for adding beta headers to requests that already have other options set.

Parameters:

  • options: Existing request options to merge with

Returns:

  • New RequestOptions with beta headers merged

Example:

base_options = Anthropic::RequestOptions.new(timeout: 30.seconds)
options = client.beta.merge_options(base_options)
Source
messages

Access the Messages API through the beta namespace.

This provides a messages interface that automatically merges the beta namespace's headers into all requests. Use this when you need beta features in the Messages API without manually managing headers.

Example:

response = client.beta(["some-beta"]).messages.create(request)
Source
models

Access the Models API through the beta namespace.

Beta namespace headers are automatically merged into all requests. This provides a clean way to access models with beta opt-in.

Example:

models = client.beta.models.list
models = client.beta(["custom-beta"]).models.retrieve("claude-3-5-sonnet-20241022")
Source
options(additional_betas : Array(String) = [] of String) : RequestOptions

Build request options with beta headers merged.

Creates RequestOptions that include both the beta namespace's default headers and any additional beta headers passed to this method.

Parameters:

  • additional_betas: Extra beta headers to include for this request

Returns:

  • RequestOptions with merged beta headers

Example:

options = client.beta.options(["experimental-feature"])
client.messages.create(request, request_options: options)
Source
skills

Access the Skills API through the beta namespace.

Skills require the skills-2025-10-02 beta header. This accessor provides a clean way to access skills with beta opt-in. The beta namespace headers are automatically merged with the skills beta header in all requests.

Example:

skills = client.beta.skills.list
skills = client.beta(["custom-beta"]).skills.list # includes both headers
Source