@ai-sdk/anthropic 4.0.59 → 4.0.60

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.
@@ -197,17 +197,27 @@ const result = streamText({
197
197
  });
198
198
  ```
199
199
 
200
- For `claude-fable-5-1`, the default `"auto"` mode uses native structured
201
- outputs through `output_config.format`. Fable 5.1 rejects forced tool use, so
202
- do not use `"jsonTool"` or a required or named tool choice to implement
203
- structured output with this model.
200
+ For `claude-opus-5-5` and `claude-fable-5-1`, the default `"auto"` mode uses
201
+ native structured outputs through `output_config.format`. These models reject
202
+ forced tool use, so the `"jsonTool"` mode cannot be used with them. If you
203
+ request `"jsonTool"` anyway, the provider falls back to `"outputFormat"` and
204
+ emits a warning. Likewise, a `required` or named `toolChoice` is downgraded to
205
+ `auto` with a warning; instruct the model to use the tool in your prompt and
206
+ verify that a tool call was made.
204
207
 
205
208
  ### Effort
206
209
 
207
- 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.
210
+ 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.
208
211
 
209
212
  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.
210
213
 
214
+ On `claude-opus-5-5`, thinking is always adaptive and cannot be disabled, so
215
+ `effort` is the main control for latency and cost. The API default effort for
216
+ `claude-opus-5-5` is `medium`. Start there and test other levels rather than
217
+ carrying over the setting you used on `claude-opus-5`. Set `maxOutputTokens`
218
+ with room for thinking as well as the reply; thinking counts toward the limit
219
+ even when its content is not returned.
220
+
211
221
  ```ts highlight="8-10"
212
222
  import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
213
223
  import { generateText } from 'ai';
@@ -479,6 +489,41 @@ const { text } = await generateText({
479
489
  });
480
490
  ```
481
491
 
492
+ ##### Adaptive-Only Models
493
+
494
+ `claude-opus-5-5`, `claude-fable-5`, and `claude-fable-5-1` always run adaptive
495
+ thinking. The API rejects `thinking: { type: 'disabled' }` and budget-based
496
+ `thinking: { type: 'enabled' }` for these models. To keep existing code working,
497
+ the provider:
498
+
499
+ - removes `thinking: { type: 'disabled' }` and emits a warning,
500
+ - converts `thinking: { type: 'enabled', budgetTokens }` to `{ type: 'adaptive' }` and emits a warning,
501
+ - maps the top-level `reasoning: 'none'` option to `effort: 'low'` and emits a warning.
502
+
503
+ Use `effort` to control how much these models think. On `claude-opus-5-5`, set
504
+ `effort: 'low'` when time to first token matters, and move to `medium` if
505
+ quality drops:
506
+
507
+ ```ts highlight="6-9"
508
+ const { text } = await generateText({
509
+ model: anthropic('claude-opus-5-5'),
510
+ prompt: 'Summarize this ticket in one sentence.',
511
+ providerOptions: {
512
+ anthropic: {
513
+ // thinking stays adaptive; effort controls how much the model thinks
514
+ effort: 'low',
515
+ } satisfies AnthropicLanguageModelOptions,
516
+ },
517
+ });
518
+ ```
519
+
520
+ <Note>
521
+ Responses from adaptive-only models can begin with a thinking block. Read the
522
+ response by content type (`text`, `reasoning`, `tool-call`) rather than
523
+ assuming the first part is text. Under the default `display: 'omitted'`
524
+ setting, thinking blocks are returned with empty text.
525
+ </Note>
526
+
482
527
  ##### Thinking Display (Opus 4.7+)
483
528
 
484
529
  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'`:
@@ -506,8 +551,10 @@ console.log(text);
506
551
 
507
552
  ##### Thinking Updates
508
553
 
509
- Use `display: 'updates'` with `claude-fable-5-1` to stream thinking summaries
510
- between tool calls. The provider adds the required
554
+ Use `display: 'updates'` with `claude-opus-5-5` or `claude-fable-5-1` to stream
555
+ thinking summaries between tool calls. These models return progress notes
556
+ between tool calls as thinking blocks rather than text, so without this setting
557
+ a long tool-calling turn can look silent. The provider adds the required
511
558
  `thinking-display-updates-2026-08-18` beta header automatically:
512
559
 
513
560
  ```ts highlight="12-16"
@@ -1077,11 +1124,74 @@ const computerTool = anthropic.tools.computer_20251124({
1077
1124
  ```
1078
1125
 
1079
1126
  <Note>
1080
- Use `computer_20251124` for Claude Opus 4.5 which supports the zoom action.
1081
- Use `computer_20250124` for Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4,
1082
- Opus 4, and Sonnet 3.7.
1127
+ Use `computerToolset_20260801` for Claude Opus 5.5 (required), Opus 5, Sonnet
1128
+ 5, Fable 5, Fable 5.1, and Opus 4.8. Use `computer_20251124` for Claude Opus
1129
+ 4.5 through Opus 4.7, which support the zoom action. Use `computer_20250124`
1130
+ for Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7.
1083
1131
  </Note>
1084
1132
 
1133
+ #### Computer Toolset
1134
+
1135
+ Newer models use the computer toolset instead of a versioned computer tool.
1136
+ `claude-opus-5-5` accepts computer use only through the toolset and rejects the
1137
+ older `computer_*` tool types with a 400. The toolset does not require a beta
1138
+ header and has no display size parameters: coordinates are always in the pixel
1139
+ space of the screenshots you return. Zoom is enabled by default, and Claude can
1140
+ return several actions in one turn, each as its own tool call.
1141
+
1142
+ The API returns each action as a separate `tool_use` block with
1143
+ `toolset_name: 'computer'`. The AI SDK maps every action to the toolset tool and
1144
+ passes the action name as `action`, so `execute` receives the same input shape
1145
+ as the older computer tools:
1146
+
1147
+ ```ts
1148
+ const computerTool = anthropic.tools.computerToolset_20260801({
1149
+ // optional: turn individual actions on or off
1150
+ configs: {
1151
+ zoom: { enabled: false },
1152
+ },
1153
+
1154
+ execute: async ({ action, coordinate, text, region }) => {
1155
+ switch (action) {
1156
+ case 'screenshot': {
1157
+ return {
1158
+ type: 'image',
1159
+ data: fs.readFileSync('./data/screenshot.png').toString('base64'),
1160
+ };
1161
+ }
1162
+ default: {
1163
+ console.log('Action:', action, coordinate, text, region);
1164
+ return `executed ${action}`;
1165
+ }
1166
+ }
1167
+ },
1168
+
1169
+ toModelOutput({ output }) {
1170
+ return typeof output === 'string'
1171
+ ? [{ type: 'text', text: output }]
1172
+ : [{ type: 'file-data', data: output.data, mediaType: 'image/png' }];
1173
+ },
1174
+ });
1175
+ ```
1176
+
1177
+ Parameters:
1178
+
1179
+ - `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.
1180
+ - `coordinate` (number[], optional): The (x, y) pixel coordinates for click, move, and scroll actions.
1181
+ - `start_coordinate` (number[], optional): Where a `left_click_drag` starts.
1182
+ - `region` (number[], optional): `[x1, y1, x2, y2]` for the `zoom` action.
1183
+ - `text` (string, optional): Text to type, the key combination for `key` and `hold_key`, or modifier keys to hold during click and scroll actions.
1184
+ - `repeat` (number, optional): How many times to press the key for `key`.
1185
+ - `duration` (number, optional): Seconds for `hold_key` and `wait`.
1186
+ - `scroll_direction` ('up' | 'down' | 'left' | 'right', optional) and `scroll_amount` (number, optional): For the `scroll` action.
1187
+ - `configs` (object, optional): Per-action settings keyed by action name. Each entry accepts `enabled` (default `true`) and `deferLoading` (default `false`, for tool search).
1188
+
1189
+ Tool calls and results of the toolset are serialized with `toolset_name` when
1190
+ you pass the message history back. Keep the toolset tool in `tools` on
1191
+ follow-up requests, or the provider falls back to the `toolsetName` provider
1192
+ metadata on the tool calls of previous responses. Do not declare the toolset
1193
+ together with an older `computer_*` tool.
1194
+
1085
1195
  Parameters:
1086
1196
 
1087
1197
  - `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`.
@@ -1380,11 +1490,11 @@ This sends `tool_reference` blocks to Anthropic, which loads the corresponding d
1380
1490
 
1381
1491
  ### Mid-Conversation System Controls
1382
1492
 
1383
- With `claude-fable-5-1`, a mid-conversation system message can be cleared
1384
- before the next user message with `clearAt: 'next_user_message'`, or set the
1385
- effort for the next turn. The provider adds the required
1493
+ With `claude-opus-5-5` and `claude-fable-5-1`, a mid-conversation system message
1494
+ can be cleared before the next user message with `clearAt: 'next_user_message'`,
1495
+ or set the effort for the next turn without invalidating the prompt cache. The provider adds the required
1386
1496
  `mid-conversation-system-clear-at-2026-08-21` and
1387
- `mid-conversation-effort-2026-08-01` beta headers automatically.
1497
+ `mid-conversation-output-config-2026-07-01` beta headers automatically.
1388
1498
 
1389
1499
  ```ts highlight="17-25"
1390
1500
  import { anthropic } from '@ai-sdk/anthropic';
@@ -1923,6 +2033,7 @@ and the `mediaType` should be set to `'application/pdf'`.
1923
2033
 
1924
2034
  | Model | Image Input | Object Generation | Tool Usage | Computer Use | Web Search | Tool Search | Compaction |
1925
2035
  | ------------------- | ----------- | ----------------- | ---------- | ------------ | ---------- | ----------- | ---------- |
2036
+ | `claude-opus-5-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
1926
2037
  | `claude-opus-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
1927
2038
  | `claude-sonnet-5` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
1928
2039
  | `claude-fable-5-1` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "4.0.59",
3
+ "version": "4.0.60",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -173,6 +173,11 @@ export interface AnthropicToolCallContent {
173
173
  * (e.g., code execution calling a user-defined tool programmatically).
174
174
  */
175
175
  caller?: AnthropicToolCallCaller;
176
+ /**
177
+ * Present when this tool call is a member call of a toolset
178
+ * (e.g. `computer` for the computer toolset). `name` is then the member name.
179
+ */
180
+ toolset_name?: string;
176
181
  cache_control: AnthropicCacheControl | undefined;
177
182
  }
178
183
 
@@ -228,6 +233,10 @@ export interface AnthropicToolReferenceContent {
228
233
  export interface AnthropicToolResultContent {
229
234
  type: 'tool_result';
230
235
  tool_use_id: string;
236
+ /**
237
+ * Required for results of toolset member calls (e.g. `computer`).
238
+ */
239
+ toolset_name?: string;
231
240
  content:
232
241
  | string
233
242
  | Array<
@@ -484,6 +493,15 @@ export type AnthropicTool =
484
493
  enable_zoom?: boolean;
485
494
  cache_control: AnthropicCacheControl | undefined;
486
495
  }
496
+ | {
497
+ /**
498
+ * Computer toolset. Declared without a `name`; the API returns member
499
+ * tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
500
+ */
501
+ type: 'computer_toolset_20260801';
502
+ configs?: Record<string, { enabled?: boolean; defer_loading?: boolean }>;
503
+ cache_control: AnthropicCacheControl | undefined;
504
+ }
487
505
  | {
488
506
  name: string;
489
507
  type:
@@ -795,6 +813,8 @@ export const anthropicResponseSchema = lazySchema(() =>
795
813
  input: z.unknown(),
796
814
  // Programmatic tool calling: caller info when triggered from code execution
797
815
  caller: anthropicToolCallCallerSchema.optional(),
816
+ // Toolsets (e.g. computer toolset): name of the toolset this member call belongs to
817
+ toolset_name: z.string().nullish(),
798
818
  }),
799
819
  z.object({
800
820
  type: z.literal('server_tool_use'),
@@ -1120,6 +1140,7 @@ export const anthropicChunkSchema = lazySchema(() =>
1120
1140
  name: z.string(),
1121
1141
  input: z.unknown(),
1122
1142
  caller: anthropicToolCallCallerSchema.optional(),
1143
+ toolset_name: z.string().nullish(),
1123
1144
  }),
1124
1145
  ]),
1125
1146
  )
@@ -1156,6 +1177,8 @@ export const anthropicChunkSchema = lazySchema(() =>
1156
1177
  input: z.record(z.string(), z.unknown()).optional(),
1157
1178
  // Programmatic tool calling: caller info when triggered from code execution
1158
1179
  caller: anthropicToolCallCallerSchema.optional(),
1180
+ // Toolsets (e.g. computer toolset): name of the toolset this member call belongs to
1181
+ toolset_name: z.string().nullish(),
1159
1182
  }),
1160
1183
  z.object({
1161
1184
  type: z.literal('redacted_thinking'),
@@ -20,6 +20,7 @@ export type AnthropicModelId =
20
20
  | 'claude-opus-4-7'
21
21
  | 'claude-opus-4-8'
22
22
  | 'claude-opus-5'
23
+ | 'claude-opus-5-5'
23
24
  | 'claude-fable-5'
24
25
  | 'claude-fable-5-1'
25
26
  | 'claude-sonnet-5'
@@ -82,8 +83,8 @@ export const anthropicSystemMessageProviderOptions = z.object({
82
83
 
83
84
  /**
84
85
  * Sets the model effort for the turn that follows this mid-conversation
85
- * system message. The required `mid-conversation-effort-2026-08-01` beta
86
- * is added automatically.
86
+ * system message. The required `mid-conversation-output-config-2026-07-01`
87
+ * beta is added automatically.
87
88
  */
88
89
  effort: z.enum(['low', 'medium', 'high', 'xhigh', 'max']).optional(),
89
90
 
@@ -143,6 +144,11 @@ export const anthropicLanguageModelOptions = z.object({
143
144
  *
144
145
  * When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
145
146
  * Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
147
+ *
148
+ * Models that always use adaptive thinking (e.g. `claude-opus-5-5`,
149
+ * `claude-fable-5-1`) reject `enabled` and `disabled`. For those models the
150
+ * provider drops the unsupported setting, emits a warning, and sends an
151
+ * adaptive thinking request. Use `effort` to control how much they think.
146
152
  */
147
153
  thinking: z
148
154
  .union([
@@ -278,7 +284,11 @@ export const anthropicLanguageModelOptions = z.object({
278
284
  toolStreaming: z.boolean().optional(),
279
285
 
280
286
  /**
281
- * @default 'high'
287
+ * Controls how much effort the model spends on thinking, text responses,
288
+ * and tool calls. On models that always use adaptive thinking
289
+ * (e.g. `claude-opus-5-5`), effort is the main lever for latency and cost.
290
+ *
291
+ * The API default is `high` for most models and `medium` for `claude-opus-5-5`.
282
292
  */
283
293
  effort: z.enum(['low', 'medium', 'high', 'xhigh', 'max']).optional(),
284
294