@ai-sdk/anthropic 3.0.119 → 3.0.120

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -189,17 +189,27 @@ const result = streamText({
189
189
  });
190
190
  ```
191
191
 
192
- For `claude-fable-5-1`, the default `"auto"` mode uses native structured
193
- outputs through `output_config.format`. Fable 5.1 rejects forced tool use, so
194
- do not use `"jsonTool"` or a required or named tool choice to implement
195
- structured output with this model.
192
+ For `claude-opus-5-5` and `claude-fable-5-1`, the default `"auto"` mode uses
193
+ native structured outputs through `output_config.format`. These models reject
194
+ forced tool use, so the `"jsonTool"` mode cannot be used with them. If you
195
+ request `"jsonTool"` anyway, the provider falls back to `"outputFormat"` and
196
+ emits a warning. Likewise, a `required` or named `toolChoice` is downgraded to
197
+ `auto` with a warning; instruct the model to use the tool in your prompt and
198
+ verify that a tool call was made.
196
199
 
197
200
  ### Effort
198
201
 
199
- Anthropic introduced an `effort` option with `claude-opus-4-5` that affects thinking, text responses, and function calls. Effort defaults to `high` and you can set it to `medium` or `low` to save tokens and to lower time-to-last-token latency (TTLT). `claude-opus-4-7`, `claude-opus-4-8`, `claude-opus-5`, `claude-fable-5`, `claude-fable-5-1`, and `claude-sonnet-5` additionally support `xhigh` for maximum reasoning effort.
202
+ Anthropic introduced an `effort` option with `claude-opus-4-5` that affects thinking, text responses, and function calls. Effort defaults to `high` and you can set it to `medium` or `low` to save tokens and to lower time-to-last-token latency (TTLT). `claude-opus-4-7`, `claude-opus-4-8`, `claude-opus-5`, `claude-opus-5-5`, `claude-fable-5`, `claude-fable-5-1`, and `claude-sonnet-5` additionally support `xhigh` for maximum reasoning effort.
200
203
 
201
204
  On `claude-opus-5`, thinking can only be disabled at effort levels up to and including `high`. When you combine `thinking: { type: 'disabled' }` with `effort: 'xhigh'` or `effort: 'max'`, the AI SDK lowers the effort to `high` and emits a warning instead of sending a request that the API would reject.
202
205
 
206
+ On `claude-opus-5-5`, thinking is always adaptive and cannot be disabled, so
207
+ `effort` is the main control for latency and cost. The API default effort for
208
+ `claude-opus-5-5` is `medium`. Start there and test other levels rather than
209
+ carrying over the setting you used on `claude-opus-5`. Set `maxOutputTokens`
210
+ with room for thinking as well as the reply; thinking counts toward the limit
211
+ even when its content is not returned.
212
+
203
213
  ```ts highlight="8-10"
204
214
  import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
205
215
  import { generateText } from 'ai';
@@ -419,6 +429,40 @@ const { text } = await generateText({
419
429
  });
420
430
  ```
421
431
 
432
+ ##### Adaptive-Only Models
433
+
434
+ `claude-opus-5-5`, `claude-fable-5`, and `claude-fable-5-1` always run adaptive
435
+ thinking. The API rejects `thinking: { type: 'disabled' }` and budget-based
436
+ `thinking: { type: 'enabled' }` for these models. To keep existing code working,
437
+ the provider:
438
+
439
+ - removes `thinking: { type: 'disabled' }` and emits a warning,
440
+ - converts `thinking: { type: 'enabled', budgetTokens }` to `{ type: 'adaptive' }` and emits a warning.
441
+
442
+ Use `effort` to control how much these models think. On `claude-opus-5-5`, set
443
+ `effort: 'low'` when time to first token matters, and move to `medium` if
444
+ quality drops:
445
+
446
+ ```ts highlight="6-9"
447
+ const { text } = await generateText({
448
+ model: anthropic('claude-opus-5-5'),
449
+ prompt: 'Summarize this ticket in one sentence.',
450
+ providerOptions: {
451
+ anthropic: {
452
+ // thinking stays adaptive; effort controls how much the model thinks
453
+ effort: 'low',
454
+ } satisfies AnthropicLanguageModelOptions,
455
+ },
456
+ });
457
+ ```
458
+
459
+ <Note>
460
+ Responses from adaptive-only models can begin with a thinking block. Read the
461
+ response by content type (`text`, `reasoning`, `tool-call`) rather than
462
+ assuming the first part is text. Under the default `display: 'omitted'`
463
+ setting, thinking blocks are returned with empty text.
464
+ </Note>
465
+
422
466
  ##### Thinking Display (Opus 4.7+)
423
467
 
424
468
  Starting with `claude-opus-4-7`, thinking content is omitted from the response by default — thinking blocks are present in the stream but their text is empty. To receive reasoning output, set `display: 'summarized'`:
@@ -446,8 +490,11 @@ console.log(text);
446
490
 
447
491
  ##### Thinking Updates
448
492
 
449
- Use `display: 'updates'` with `claude-fable-5-1` to stream thinking summaries
450
- between tool calls:
493
+ Use `display: 'updates'` with `claude-opus-5-5` or `claude-fable-5-1` to stream
494
+ thinking summaries between tool calls. These models return progress notes
495
+ between tool calls as thinking blocks rather than text, so without this setting
496
+ a long tool-calling turn can look silent. The provider adds the required
497
+ `thinking-display-updates-2026-08-18` beta header automatically:
451
498
 
452
499
  ```ts highlight="12-16"
453
500
  import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
@@ -991,11 +1038,74 @@ const computerTool = anthropic.tools.computer_20251124({
991
1038
  ```
992
1039
 
993
1040
  <Note>
994
- Use `computer_20251124` for Claude Opus 4.5 which supports the zoom action.
995
- Use `computer_20250124` for Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4,
996
- Opus 4, and Sonnet 3.7.
1041
+ Use `computerToolset_20260801` for Claude Opus 5.5 (required), Opus 5, Sonnet
1042
+ 5, Fable 5, Fable 5.1, and Opus 4.8. Use `computer_20251124` for Claude Opus
1043
+ 4.5 through Opus 4.7, which support the zoom action. Use `computer_20250124`
1044
+ for Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7.
997
1045
  </Note>
998
1046
 
1047
+ #### Computer Toolset
1048
+
1049
+ Newer models use the computer toolset instead of a versioned computer tool.
1050
+ `claude-opus-5-5` accepts computer use only through the toolset and rejects the
1051
+ older `computer_*` tool types with a 400. The toolset does not require a beta
1052
+ header and has no display size parameters: coordinates are always in the pixel
1053
+ space of the screenshots you return. Zoom is enabled by default, and Claude can
1054
+ return several actions in one turn, each as its own tool call.
1055
+
1056
+ The API returns each action as a separate `tool_use` block with
1057
+ `toolset_name: 'computer'`. The AI SDK maps every action to the toolset tool and
1058
+ passes the action name as `action`, so `execute` receives the same input shape
1059
+ as the older computer tools:
1060
+
1061
+ ```ts
1062
+ const computerTool = anthropic.tools.computerToolset_20260801({
1063
+ // optional: turn individual actions on or off
1064
+ configs: {
1065
+ zoom: { enabled: false },
1066
+ },
1067
+
1068
+ execute: async ({ action, coordinate, text, region }) => {
1069
+ switch (action) {
1070
+ case 'screenshot': {
1071
+ return {
1072
+ type: 'image',
1073
+ data: fs.readFileSync('./data/screenshot.png').toString('base64'),
1074
+ };
1075
+ }
1076
+ default: {
1077
+ console.log('Action:', action, coordinate, text, region);
1078
+ return `executed ${action}`;
1079
+ }
1080
+ }
1081
+ },
1082
+
1083
+ toModelOutput({ output }) {
1084
+ return typeof output === 'string'
1085
+ ? [{ type: 'text', text: output }]
1086
+ : [{ type: 'file-data', data: output.data, mediaType: 'image/png' }];
1087
+ },
1088
+ });
1089
+ ```
1090
+
1091
+ Parameters:
1092
+
1093
+ - `action` ('screenshot' | 'zoom' | 'left_click' | 'right_click' | 'middle_click' | 'double_click' | 'triple_click' | 'left_click_drag' | 'mouse_move' | 'left_mouse_down' | 'left_mouse_up' | 'cursor_position' | 'scroll' | 'type' | 'key' | 'hold_key' | 'wait'): The member tool that Claude invoked.
1094
+ - `coordinate` (number[], optional): The (x, y) pixel coordinates for click, move, and scroll actions.
1095
+ - `start_coordinate` (number[], optional): Where a `left_click_drag` starts.
1096
+ - `region` (number[], optional): `[x1, y1, x2, y2]` for the `zoom` action.
1097
+ - `text` (string, optional): Text to type, the key combination for `key` and `hold_key`, or modifier keys to hold during click and scroll actions.
1098
+ - `repeat` (number, optional): How many times to press the key for `key`.
1099
+ - `duration` (number, optional): Seconds for `hold_key` and `wait`.
1100
+ - `scroll_direction` ('up' | 'down' | 'left' | 'right', optional) and `scroll_amount` (number, optional): For the `scroll` action.
1101
+ - `configs` (object, optional): Per-action settings keyed by action name. Each entry accepts `enabled` (default `true`) and `deferLoading` (default `false`, for tool search).
1102
+
1103
+ Tool calls and results of the toolset are serialized with `toolset_name` when
1104
+ you pass the message history back. Keep the toolset tool in `tools` on
1105
+ follow-up requests, or the provider falls back to the `toolsetName` provider
1106
+ metadata on the tool calls of previous responses. Do not declare the toolset
1107
+ together with an older `computer_*` tool.
1108
+
999
1109
  Parameters:
1000
1110
 
1001
1111
  - `action` ('key' | 'type' | 'mouse_move' | 'left_click' | 'left_click_drag' | 'right_click' | 'middle_click' | 'double_click' | 'screenshot' | 'cursor_position' | 'zoom'): The action to perform. The `zoom` action is only available with `computer_20251124`.
@@ -1266,11 +1376,11 @@ This sends `tool_reference` blocks to Anthropic, which loads the corresponding d
1266
1376
 
1267
1377
  ### Mid-Conversation System Controls
1268
1378
 
1269
- With `claude-fable-5-1`, a mid-conversation system message can be cleared
1270
- before the next user message with `clearAt: 'next_user_message'`, or set the
1271
- effort for the next turn. The provider adds the required
1379
+ With `claude-opus-5-5` and `claude-fable-5-1`, a mid-conversation system message
1380
+ can be cleared before the next user message with `clearAt: 'next_user_message'`,
1381
+ or set the effort for the next turn without invalidating the prompt cache. The provider adds the required
1272
1382
  `mid-conversation-system-clear-at-2026-08-21` and
1273
- `mid-conversation-effort-2026-08-01` beta headers automatically.
1383
+ `mid-conversation-output-config-2026-07-01` beta headers automatically.
1274
1384
 
1275
1385
  ```ts highlight="17-25"
1276
1386
  import { anthropic } from '@ai-sdk/anthropic';
@@ -1755,6 +1865,7 @@ and the `mediaType` should be set to `'application/pdf'`.
1755
1865
  | Model | Image Input | Object Generation | Tool Usage | Computer Use | Web Search | Tool Search | Compaction |
1756
1866
  | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
1757
1867
  | `claude-fable-5-1` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1868
+ | `claude-opus-5-5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1758
1869
  | `claude-opus-5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1759
1870
  | `claude-sonnet-5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1760
1871
  | `claude-fable-5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "3.0.119",
3
+ "version": "3.0.120",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -162,6 +162,11 @@ export interface AnthropicToolCallContent {
162
162
  * (e.g., code execution calling a user-defined tool programmatically).
163
163
  */
164
164
  caller?: AnthropicToolCallCaller;
165
+ /**
166
+ * Present when this tool call is a member call of a toolset
167
+ * (e.g. `computer` for the computer toolset). `name` is then the member name.
168
+ */
169
+ toolset_name?: string;
165
170
  cache_control: AnthropicCacheControl | undefined;
166
171
  }
167
172
 
@@ -217,6 +222,10 @@ export interface AnthropicToolReferenceContent {
217
222
  export interface AnthropicToolResultContent {
218
223
  type: 'tool_result';
219
224
  tool_use_id: string;
225
+ /**
226
+ * Required for results of toolset member calls (e.g. `computer`).
227
+ */
228
+ toolset_name?: string;
220
229
  content:
221
230
  | string
222
231
  | Array<
@@ -465,6 +474,15 @@ export type AnthropicTool =
465
474
  enable_zoom?: boolean;
466
475
  cache_control: AnthropicCacheControl | undefined;
467
476
  }
477
+ | {
478
+ /**
479
+ * Computer toolset. Declared without a `name`; the API returns member
480
+ * tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
481
+ */
482
+ type: 'computer_toolset_20260801';
483
+ configs?: Record<string, { enabled?: boolean; defer_loading?: boolean }>;
484
+ cache_control: AnthropicCacheControl | undefined;
485
+ }
468
486
  | {
469
487
  name: string;
470
488
  type:
@@ -714,6 +732,8 @@ export const anthropicMessagesResponseSchema = lazySchema(() =>
714
732
  input: z.unknown(),
715
733
  // Programmatic tool calling: caller info when triggered from code execution
716
734
  caller: anthropicToolCallCallerSchema.optional(),
735
+ // Toolsets (e.g. computer toolset): name of the toolset this member call belongs to
736
+ toolset_name: z.string().nullish(),
717
737
  }),
718
738
  z.object({
719
739
  type: z.literal('server_tool_use'),
@@ -1037,6 +1057,7 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
1037
1057
  name: z.string(),
1038
1058
  input: z.unknown(),
1039
1059
  caller: anthropicToolCallCallerSchema.optional(),
1060
+ toolset_name: z.string().nullish(),
1040
1061
  }),
1041
1062
  ]),
1042
1063
  )
@@ -1073,6 +1094,8 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
1073
1094
  input: z.record(z.string(), z.unknown()).optional(),
1074
1095
  // Programmatic tool calling: caller info when triggered from code execution
1075
1096
  caller: anthropicToolCallCallerSchema.optional(),
1097
+ // Toolsets (e.g. computer toolset): name of the toolset this member call belongs to
1098
+ toolset_name: z.string().nullish(),
1076
1099
  }),
1077
1100
  z.object({
1078
1101
  type: z.literal('redacted_thinking'),