class

Anthropic::Beta::FilesAPI

Inherits Reference < Object

Beta-scoped file operations with automatic beta header merging.

Wraps Files::API so that every request includes the beta namespace headers configured on the parent Beta::API, merged (deduplicated) with any per-request options the caller passes.

Usage

client = Anthropic::Client.new

# Upload a file through the beta namespace
file = client.beta(["files-beta-2025"]).files.upload("doc.txt", "content")

# Per-request options are merged, not overwritten
opts = Anthropic::RequestOptions.new(beta_headers: ["extra-beta"])
file = client.beta(["files-beta-2025"]).files.retrieve("file_123", opts)
# => request includes both "files-beta-2025" AND "extra-beta"

Constructors

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

Instance methods

delete(file_id : String, request_options : RequestOptions | Nil = nil) : FileDeleted

Delete a file.

Source
download(file_id : String, request_options : RequestOptions | Nil = nil) : Bytes

Download file content as raw bytes.

Source
download_base64(file_id : String, request_options : RequestOptions | Nil = nil) : String

Download file content as base64.

Source
download_string(file_id : String, request_options : RequestOptions | Nil = nil) : String

Download file content as string.

Source
list(params : ListParams = ListParams.new, request_options : RequestOptions | Nil = nil) : Page(File)

List files with pagination.

Source
list_all(limit : Int32 | Nil = nil, request_options : RequestOptions | Nil = nil) : AutoPaginator(File)

Auto-paginating iterator for listing all files.

Source
retrieve(file_id : String, request_options : RequestOptions | Nil = nil) : File

Retrieve a specific file by ID.

Source
upload(request : UploadFileRequest, request_options : RequestOptions | Nil = nil) : File

Upload a file via an UploadFileRequest.

Source
upload(filename : String, content : String, mime_type : String | Nil = nil, request_options : RequestOptions | Nil = nil) : File

Upload a file from a string.

Source