Follow Discord
Sweep 03 Nov 2026 · 22:27Z Build v2.1.318 536 read Stable v2.1.311 Latest v2.1.318 Next v2.1.318 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

typescript changedcli-sdks-libraries/sdks/typescript

Nearest release: v2.1.318, published 4 hours before 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+14added
Lines−7removed
From line 178 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits16to this page, all time

The whole hunk

from line 178, old and new numbered
/
lines
from line 178
178178To report an error from a tool back to the model, throw a `ToolError` from the `run` function. Unlike a plain `Error`, `ToolError` accepts content blocks, allowing you to include images or other structured content in the error response:
179179 
180180```typescript
181import { ToolError } from "@anthropic-ai/sdk/lib/tools/BetaRunnableTool";
181import { betaZodTool } from "@anthropic-ai/sdk/helpers/beta/zod";
182import { ToolError } from "@anthropic-ai/sdk/resources/beta/messages";
183import { z } from "zod";
182184 
183185const screenshotTool = betaZodTool({
184186 name: "take_screenshot",
185187 inputSchema: z.object({ url: z.string() }),
188 description: "Take a screenshot of a webpage",
186189 run: async (input) => {
187190 if (!isValidUrl(input.url)) {
188191 throw new ToolError(`Invalid URL: ${input.url}`);
from line 201
198201 }
199202 ]);
200203 }
201 return {
202 type: "image",
203 source: { type: "base64", data: result.screenshot, media_type: "image/png" }
204 };
204 return [
205 {
206 type: "image",
207 source: { type: "base64", data: result.screenshot, media_type: "image/png" }
208 }
209 ];
205210 }
206211});
207212```
from line 766
761766 
762767 * **Internal tools:** If the application is used solely within a controlled internal environment where the users are trusted, the risk of credential exposure can be mitigated.
763768 * **Development or debugging purpose:** Enabling this feature temporarily might be acceptable, provided the credentials are short-lived, aren’t also used in production environments, or are frequently rotated.
769 
770 Even in these cases, browser support works only if your organization can call the Claude API directly from a browser. Organizations with zero data retention (ZDR) or the Compliance API enabled cannot, and their browser requests fail with a 401 error. See [Browser-based applications](https://platform.claude.com/docs/en/manage-claude/authentication#browser-based-applications).
764771</Accordion>
765772 
766773## Platform integrations
from line 797
790797 
791798## Semantic versioning
792799 
793Each major version of this SDK sends one API version in the `anthropic-version` header by default, and a new major version comes with each new API version. The first major version that sends `2026-10-21` is 1.0.0; see [Migrating to API version 2026-10-21](https://platform.claude.com/docs/en/api/migration-2026-10-21#upgrade).
794 
795800This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backward-incompatible changes may be released as minor versions:
796801 
7978021. Changes that only affect static types, without breaking runtime behavior.
from line 804
7998043. Changes that aren’t expected to impact the vast majority of users in practice.
800805 
801806Backward compatibility is taken seriously to ensure you can rely on a smooth upgrade experience.
807 
808Every request to the Claude API uses an API version. With this SDK, your requests use the API version that was current when your SDK’s major version was released, so you move to a new API version by upgrading to a new major version. Version 1.0.0 is the first to use `2026-10-21`. See [Migrating to API version 2026-10-21](https://platform.claude.com/docs/en/api/migration-2026-10-21#upgrade) for how to upgrade.
802809 
803810## Frequently asked questions
804811 
Feedback