Follow Discord
Sweep 22 Oct 2026 · 04:32Z Build v2.1.308 527 read Stable v2.1.308 Latest v2.1.308 Next v2.1.308 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

Automatically handles tool execution loop changedcli-sdks-libraries/sdks/ruby

Nearest release: v2.1.307, published an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+16added
Lines−16removed
From line 40 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits10to this page, all time

### Undocumented request parameters ### Undocumented request params

The whole hunk

from line 40, old and new numbered
/
lines
from line 40
4040end
4141```
4242 
43For authentication options including Workload Identity Federation, see [Authentication](https://platform.claude.com/docs/en/manage-claude/authentication). If your API key is a [personal or service account key](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) with access to multiple workspaces, set the workspace ID in the `anthropic-workspace-id` request header; [Select a workspace](https://platform.claude.com/docs/en/manage-claude/authentication#select-a-workspace) shows the per-request option for this SDK.
43For authentication options including Workload Identity Federation, see [Authentication](https://platform.claude.com/docs/en/manage-claude/authentication). If your API key is a [personal or service account key](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) that isn't scoped to a workspace, set the workspace ID in the `anthropic-workspace-id` request header; [Select a workspace](https://platform.claude.com/docs/en/manage-claude/authentication#select-a-workspace) shows the per-request option for this SDK.
4444 
4545## Streaming
4646 
from line 80
8080 
8181## Input schema and tool calling
8282 
83The SDK provides helper mechanisms to define structured data classes for tools and let Claude automatically execute them. For detailed documentation on tool use patterns including the tool runner, see [Tool Runner (SDK)](https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-runner).
83The SDK provides helper mechanisms to define structured data classes for tools and let Claude automatically run them. For detailed documentation on tool use patterns including the tool runner, see [Tool Runner (SDK)](https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-runner).
8484 
8585```ruby
8686anthropic = Anthropic::Client.new
from line 113
113113 
114114## Handling errors
115115 
116When the library is unable to connect to the API, or if the API returns a non-success status code (that is, 4xx or 5xx response), a subclass of `Anthropic::Errors::APIError` is raised:
116When the library is unable to connect to the API, or if the API returns a non-success status code (that is, a 4xx or 5xx response), a subclass of `Anthropic::Errors::APIError` is raised:
117117 
118118```ruby
119119anthropic = Anthropic::Client.new
from line 136
136136 
137137Error codes are as follows:
138138 
139| Cause | Error Type |
139| Cause | Error type |
140140| ---------------- | -------------------------- |
141141| HTTP 400 | `BadRequestError` |
142142| HTTP 401 | `AuthenticationError` |
from line 152
152152 
153153## Retries
154154 
155Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
155Certain errors are automatically retried 2 times by default, with a short exponential backoff.
156156 
157157Connection errors (for example, because of a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts are all retried by default.
158158 
from line 236
236236anthropic = Anthropic::Client.new
237237require "pathname"
238238 
239# Use `Pathname` to send the filename and/or avoid paging a large file into memory:
239# Use `Pathname` to send the filename, avoid paging a large file into memory, or both:
240240file_metadata = anthropic.files.upload(file: Pathname("/path/to/file"))
241241 
242242# Alternatively, pass file contents or a `StringIO` directly:
243243file_metadata = anthropic.files.upload(file: File.read("/path/to/file"))
244244 
245# Or, to control the filename and/or content type:
245# Or, to control the filename, the content type, or both:
246246file = Anthropic::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "...")
247247file_metadata = anthropic.files.upload(file: file)
248248 
from line 249
249249puts(file_metadata.id)
250250```
251251 
252Note that you can also pass a raw `IO` descriptor, but this disables retries, as the library can't be sure if the descriptor is a file or pipe (which cannot be rewound).
252Note that you can also pass a raw `IO` descriptor, but this disables retries, as the library can't determine whether the descriptor is a file or pipe (which cannot be rewound).
253253 
254254## Sorbet
255255 
256256This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.
257257 
258You can provide typesafe request parameters like so:
258You can provide typesafe request parameters as follows:
259259 
260260```ruby
261261anthropic = Anthropic::Client.new
from line 335
335335 
336336The `Anthropic::Client` instances are threadsafe, but are only fork-safe when there are no in-flight HTTP requests.
337337 
338Each instance of `Anthropic::Client` has its own HTTP connection pool with a default size of 99. As such, the recommendation is to create the client once per application in most settings.
338Each instance of `Anthropic::Client` has its own HTTP connection pool with a default size of 99. As such, the recommendation is to create the client once for each application in most settings.
339339 
340340When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting toward the request timeout.
341341 
from line 345
345345 
346346### Undocumented properties
347347 
348You can send undocumented parameters to any endpoint, and read undocumented response properties, like so:
348You can send undocumented parameters to any endpoint, and read undocumented response properties, as follows:
349349 
350350<Warning>
351 The `extra_` parameters of the same name override the documented parameters. For security reasons, ensure these methods are only used with trusted input data.
351 The `extra_` parameters of the same name override the documented parameters. For security reasons, use these methods only with trusted input data.
352352</Warning>
353353 
354354```ruby
from line 369
369369puts(message[:my_undocumented_property])
370370```
371371 
372### Undocumented request params
372### Undocumented request parameters
373373 
374If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the previous examples.
374If you want to explicitly send an extra parameter, you can do so with `extra_query`, `extra_body`, and `extra_headers` under `request_options:` when making a request, as seen in the previous examples.
375375 
376376### Undocumented endpoints
377377 
378To make requests to undocumented endpoints while retaining the benefit of authentication, retries, and so on, you can make requests using `anthropic.request`, like so:
378To make requests to undocumented endpoints while retaining the benefit of authentication, retries, and so on, you can make requests using `anthropic.request`, as follows:
379379 
380380```ruby
381381response = anthropic.request(
Feedback