@ai-sdk/anthropic 3.0.134 → 3.0.135
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.
- package/CHANGELOG.md +10 -0
- package/dist/index.d.mts +121 -156
- package/dist/index.d.ts +121 -156
- package/dist/index.js +528 -515
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +485 -469
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +521 -508
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +484 -468
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/anthropic-messages-api.ts +65 -57
- package/src/anthropic-messages-options.ts +386 -367
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lazySchema,
|
|
3
|
+
zodSchema,
|
|
4
|
+
type InferSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
1
6
|
import { z } from 'zod/v4';
|
|
2
7
|
|
|
3
8
|
// https://docs.claude.com/en/docs/about-claude/models/overview
|
|
@@ -32,420 +37,434 @@ export type AnthropicMessagesModelId =
|
|
|
32
37
|
* Anthropic file part provider options for document-specific features.
|
|
33
38
|
* These options apply to individual file parts (documents).
|
|
34
39
|
*/
|
|
35
|
-
export const anthropicFilePartProviderOptions =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* When enabled, this document will generate citations in the response.
|
|
39
|
-
*/
|
|
40
|
-
citations: z
|
|
41
|
-
.object({
|
|
40
|
+
export const anthropicFilePartProviderOptions = lazySchema(() =>
|
|
41
|
+
zodSchema(
|
|
42
|
+
z.object({
|
|
42
43
|
/**
|
|
43
|
-
*
|
|
44
|
+
* Citation configuration for this document.
|
|
45
|
+
* When enabled, this document will generate citations in the response.
|
|
44
46
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
citations: z
|
|
48
|
+
.object({
|
|
49
|
+
/**
|
|
50
|
+
* Enable citations for this document
|
|
51
|
+
*/
|
|
52
|
+
enabled: z.boolean(),
|
|
53
|
+
})
|
|
54
|
+
.optional(),
|
|
48
55
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Custom title for the document.
|
|
58
|
+
* If not provided, the filename will be used.
|
|
59
|
+
*/
|
|
60
|
+
title: z.string().optional(),
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
+
/**
|
|
63
|
+
* Context about the document that will be passed to the model
|
|
64
|
+
* but not used towards cited content.
|
|
65
|
+
* Useful for storing document metadata as text or stringified JSON.
|
|
66
|
+
*/
|
|
67
|
+
context: z.string().optional(),
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
);
|
|
62
71
|
|
|
63
|
-
export type AnthropicFilePartProviderOptions =
|
|
72
|
+
export type AnthropicFilePartProviderOptions = InferSchema<
|
|
64
73
|
typeof anthropicFilePartProviderOptions
|
|
65
74
|
>;
|
|
66
75
|
|
|
67
76
|
/**
|
|
68
77
|
* Anthropic provider options for system messages.
|
|
69
78
|
*/
|
|
70
|
-
export const anthropicSystemMessageProviderOptions =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
export const anthropicSystemMessageProviderOptions = lazySchema(() =>
|
|
80
|
+
zodSchema(
|
|
81
|
+
z.object({
|
|
82
|
+
/**
|
|
83
|
+
* Clears this mid-conversation system message after the current turn.
|
|
84
|
+
*
|
|
85
|
+
* Requires the `mid-conversation-system-clear-at-2026-08-21` beta,
|
|
86
|
+
* which is added automatically.
|
|
87
|
+
*/
|
|
88
|
+
clearAt: z.literal('next_user_message').optional(),
|
|
78
89
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Sets the model effort from the next user turn until a later message
|
|
92
|
+
* changes it. An effort-only system message with empty content can appear
|
|
93
|
+
* first. The required `mid-conversation-output-config-2026-07-01` beta is
|
|
94
|
+
* added automatically.
|
|
95
|
+
*/
|
|
96
|
+
effort: z.enum(['low', 'medium', 'high', 'xhigh', 'max']).optional(),
|
|
86
97
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
})
|
|
98
|
+
/**
|
|
99
|
+
* Mid-conversation tool changes. Adds or removes tools from the
|
|
100
|
+
* conversation's tool set between turns without invalidating the prompt
|
|
101
|
+
* cache.
|
|
102
|
+
*
|
|
103
|
+
* Only supported on system messages that appear mid-conversation (not the
|
|
104
|
+
* initial system prompt). A system message carrying tool changes must come
|
|
105
|
+
* right before an assistant message or at the end of the messages.
|
|
106
|
+
*
|
|
107
|
+
* Tools referenced by a `tool_addition` must be declared in the `tools`
|
|
108
|
+
* option (typically with `deferLoading: true` so they are not loaded until
|
|
109
|
+
* the addition surfaces them). The required
|
|
110
|
+
* `mid-conversation-tool-changes-2026-07-01` beta is added automatically.
|
|
111
|
+
*/
|
|
112
|
+
toolChanges: z
|
|
113
|
+
.array(
|
|
114
|
+
z.discriminatedUnion('type', [
|
|
115
|
+
z.object({
|
|
116
|
+
type: z.literal('tool_addition'),
|
|
117
|
+
toolName: z.string(),
|
|
118
|
+
}),
|
|
119
|
+
z.object({
|
|
120
|
+
type: z.literal('tool_removal'),
|
|
121
|
+
toolName: z.string(),
|
|
122
|
+
}),
|
|
123
|
+
]),
|
|
124
|
+
)
|
|
125
|
+
.optional(),
|
|
126
|
+
}),
|
|
127
|
+
),
|
|
128
|
+
);
|
|
116
129
|
|
|
117
|
-
export type AnthropicSystemMessageProviderOptions =
|
|
130
|
+
export type AnthropicSystemMessageProviderOptions = InferSchema<
|
|
118
131
|
typeof anthropicSystemMessageProviderOptions
|
|
119
132
|
>;
|
|
120
133
|
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
134
|
+
export const anthropicLanguageModelOptions = lazySchema(() => {
|
|
135
|
+
const anthropicThinkingBlockBinding = z.object({
|
|
136
|
+
prefixMismatchBehavior: z.enum(['error', 'drop_block']),
|
|
137
|
+
});
|
|
124
138
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
return zodSchema(
|
|
140
|
+
z.object({
|
|
141
|
+
/**
|
|
142
|
+
* Whether to send reasoning to the model.
|
|
143
|
+
*
|
|
144
|
+
* This allows you to deactivate reasoning inputs for models that do not support them.
|
|
145
|
+
*/
|
|
146
|
+
sendReasoning: z.boolean().optional(),
|
|
132
147
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Determines how structured outputs are generated.
|
|
150
|
+
*
|
|
151
|
+
* - `outputFormat`: Use the `output_config.format` parameter to specify the structured output format.
|
|
152
|
+
* - `jsonTool`: Use a special 'json' tool to specify the structured output format.
|
|
153
|
+
* - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
|
|
154
|
+
*/
|
|
155
|
+
structuredOutputMode: z
|
|
156
|
+
.enum(['outputFormat', 'jsonTool', 'auto'])
|
|
157
|
+
.optional(),
|
|
141
158
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Configuration for enabling Claude's extended thinking.
|
|
161
|
+
*
|
|
162
|
+
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
163
|
+
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
164
|
+
*
|
|
165
|
+
* Models that always use adaptive thinking (e.g. `claude-opus-5-5`,
|
|
166
|
+
* `claude-fable-5-1`) reject `enabled` and `disabled`. For those models the
|
|
167
|
+
* provider drops the unsupported setting, emits a warning, and sends an
|
|
168
|
+
* adaptive thinking request. Use `effort` to control how much they think.
|
|
169
|
+
*
|
|
170
|
+
* `claude-sonnet-5-5` supports `between_tools`, its lowest thinking setting,
|
|
171
|
+
* and the provider uses it in place of `disabled` for that model.
|
|
172
|
+
*/
|
|
173
|
+
thinking: z
|
|
174
|
+
.union([
|
|
175
|
+
z.discriminatedUnion('type', [
|
|
176
|
+
z.object({
|
|
177
|
+
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
178
|
+
type: z.literal('adaptive'),
|
|
179
|
+
/**
|
|
180
|
+
* Controls whether thinking content is included in the response.
|
|
181
|
+
* - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
|
|
182
|
+
* - `"summarized"`: Thinking content is returned. Required to see reasoning output.
|
|
183
|
+
* - `"updates"`: Thinking updates are returned between tool calls.
|
|
184
|
+
*/
|
|
185
|
+
display: z.enum(['omitted', 'summarized', 'updates']).optional(),
|
|
186
|
+
/**
|
|
187
|
+
* Controls how thinking blocks are bound to an assistant prefix.
|
|
188
|
+
*
|
|
189
|
+
* Requires the `thinking-binding-controls-2026-08-01` beta,
|
|
190
|
+
* which is added automatically.
|
|
191
|
+
*/
|
|
192
|
+
blockBinding: anthropicThinkingBlockBinding.optional(),
|
|
193
|
+
}),
|
|
194
|
+
z.object({
|
|
195
|
+
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
196
|
+
type: z.literal('enabled'),
|
|
197
|
+
budgetTokens: z.number().optional(),
|
|
198
|
+
}),
|
|
199
|
+
z.object({
|
|
200
|
+
type: z.literal('disabled'),
|
|
201
|
+
}),
|
|
202
|
+
z.object({
|
|
203
|
+
/**
|
|
204
|
+
* for `claude-sonnet-5-5`: no upfront thinking, but progress notes
|
|
205
|
+
* between tool calls are returned as summarized thinking blocks.
|
|
206
|
+
* Only supported at `low`, `medium`, and `high` effort.
|
|
207
|
+
*/
|
|
208
|
+
type: z.literal('between_tools'),
|
|
209
|
+
}),
|
|
210
|
+
]),
|
|
186
211
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* Only supported at `low`, `medium`, and `high` effort.
|
|
212
|
+
* Configures prefix mismatch recovery without changing the model's
|
|
213
|
+
* default thinking mode.
|
|
190
214
|
*/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
215
|
+
z.object({
|
|
216
|
+
blockBinding: anthropicThinkingBlockBinding,
|
|
217
|
+
}),
|
|
218
|
+
])
|
|
219
|
+
.optional(),
|
|
220
|
+
|
|
194
221
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
222
|
+
* Whether to disable parallel function calling during tool use. Default is false.
|
|
223
|
+
* When set to true, Claude will use at most one tool per response.
|
|
197
224
|
*/
|
|
198
|
-
z.
|
|
199
|
-
blockBinding: anthropicThinkingBlockBinding,
|
|
200
|
-
}),
|
|
201
|
-
])
|
|
202
|
-
.optional(),
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Whether to disable parallel function calling during tool use. Default is false.
|
|
206
|
-
* When set to true, Claude will use at most one tool per response.
|
|
207
|
-
*/
|
|
208
|
-
disableParallelToolUse: z.boolean().optional(),
|
|
225
|
+
disableParallelToolUse: z.boolean().optional(),
|
|
209
226
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Cache control settings for this message.
|
|
229
|
+
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
230
|
+
*/
|
|
231
|
+
cacheControl: z
|
|
232
|
+
.object({
|
|
233
|
+
type: z.literal('ephemeral'),
|
|
234
|
+
ttl: z.union([z.literal('5m'), z.literal('1h')]).optional(),
|
|
235
|
+
})
|
|
236
|
+
.optional(),
|
|
220
237
|
|
|
221
|
-
/**
|
|
222
|
-
* Metadata to include with the request.
|
|
223
|
-
*
|
|
224
|
-
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
225
|
-
*/
|
|
226
|
-
metadata: z
|
|
227
|
-
.object({
|
|
228
238
|
/**
|
|
229
|
-
*
|
|
239
|
+
* Metadata to include with the request.
|
|
230
240
|
*
|
|
231
|
-
*
|
|
232
|
-
* Must not contain PII (name, email, phone number, etc.).
|
|
241
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
233
242
|
*/
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
name: z.string(),
|
|
246
|
-
url: z.string(),
|
|
247
|
-
authorizationToken: z.string().nullish(),
|
|
248
|
-
toolConfiguration: z
|
|
249
|
-
.object({
|
|
250
|
-
enabled: z.boolean().nullish(),
|
|
251
|
-
allowedTools: z.array(z.string()).nullish(),
|
|
252
|
-
})
|
|
253
|
-
.nullish(),
|
|
254
|
-
}),
|
|
255
|
-
)
|
|
256
|
-
.optional(),
|
|
243
|
+
metadata: z
|
|
244
|
+
.object({
|
|
245
|
+
/**
|
|
246
|
+
* An external identifier for the user associated with the request.
|
|
247
|
+
*
|
|
248
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
249
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
250
|
+
*/
|
|
251
|
+
userId: z.string().optional(),
|
|
252
|
+
})
|
|
253
|
+
.optional(),
|
|
257
254
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
*/
|
|
263
|
-
container: z
|
|
264
|
-
.object({
|
|
265
|
-
id: z.string().optional(),
|
|
266
|
-
skills: z
|
|
255
|
+
/**
|
|
256
|
+
* MCP servers to be utilized in this request.
|
|
257
|
+
*/
|
|
258
|
+
mcpServers: z
|
|
267
259
|
.array(
|
|
268
260
|
z.object({
|
|
269
|
-
type: z.
|
|
270
|
-
|
|
271
|
-
|
|
261
|
+
type: z.literal('url'),
|
|
262
|
+
name: z.string(),
|
|
263
|
+
url: z.string(),
|
|
264
|
+
authorizationToken: z.string().nullish(),
|
|
265
|
+
toolConfiguration: z
|
|
266
|
+
.object({
|
|
267
|
+
enabled: z.boolean().nullish(),
|
|
268
|
+
allowedTools: z.array(z.string()).nullish(),
|
|
269
|
+
})
|
|
270
|
+
.nullish(),
|
|
272
271
|
}),
|
|
273
272
|
)
|
|
274
273
|
.optional(),
|
|
275
|
-
})
|
|
276
|
-
.optional(),
|
|
277
274
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Agent Skills configuration. Skills enable Claude to perform specialized tasks
|
|
277
|
+
* like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
|
|
278
|
+
* Requires code execution tool to be enabled.
|
|
279
|
+
*/
|
|
280
|
+
container: z
|
|
281
|
+
.object({
|
|
282
|
+
id: z.string().optional(),
|
|
283
|
+
skills: z
|
|
284
|
+
.array(
|
|
285
|
+
z.object({
|
|
286
|
+
type: z.union([z.literal('anthropic'), z.literal('custom')]),
|
|
287
|
+
skillId: z.string(),
|
|
288
|
+
version: z.string().optional(),
|
|
289
|
+
}),
|
|
290
|
+
)
|
|
291
|
+
.optional(),
|
|
292
|
+
})
|
|
293
|
+
.optional(),
|
|
288
294
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Whether to enable fine-grained (eager) streaming of tool call inputs
|
|
297
|
+
* and structured outputs for every function tool in the request. When
|
|
298
|
+
* true (the default), each function tool receives a default of
|
|
299
|
+
* `eager_input_streaming: true` unless it explicitly sets
|
|
300
|
+
* `providerOptions.anthropic.eagerInputStreaming`.
|
|
301
|
+
*
|
|
302
|
+
* @default true
|
|
303
|
+
*/
|
|
304
|
+
toolStreaming: z.boolean().optional(),
|
|
297
305
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
.object({
|
|
307
|
-
type: z.literal('tokens'),
|
|
308
|
-
total: z.number().int().min(20000),
|
|
309
|
-
remaining: z.number().int().min(0).optional(),
|
|
310
|
-
})
|
|
311
|
-
.optional(),
|
|
306
|
+
/**
|
|
307
|
+
* Controls how much effort the model spends on thinking, text responses,
|
|
308
|
+
* and tool calls. On models that always use adaptive thinking
|
|
309
|
+
* (e.g. `claude-opus-5-5`), effort is the main lever for latency and cost.
|
|
310
|
+
*
|
|
311
|
+
* The API default is `high` for most models and `medium` for `claude-opus-5-5`.
|
|
312
|
+
*/
|
|
313
|
+
effort: z.enum(['low', 'medium', 'high', 'xhigh', 'max']).optional(),
|
|
312
314
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
/**
|
|
316
|
+
* Task budget for agentic turns. Informs the model of the total token budget
|
|
317
|
+
* available for the current task, allowing it to prioritize work and wind down
|
|
318
|
+
* gracefully as the budget is consumed.
|
|
319
|
+
*
|
|
320
|
+
* Advisory only — does not enforce a hard token limit.
|
|
321
|
+
*/
|
|
322
|
+
taskBudget: z
|
|
323
|
+
.object({
|
|
324
|
+
type: z.literal('tokens'),
|
|
325
|
+
total: z.number().int().min(20000),
|
|
326
|
+
remaining: z.number().int().min(0).optional(),
|
|
327
|
+
})
|
|
328
|
+
.optional(),
|
|
318
329
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
*
|
|
325
|
-
* See https://platform.claude.com/docs/en/build-with-claude/data-residency
|
|
326
|
-
*/
|
|
327
|
-
inferenceGeo: z.enum(['us', 'global']).optional(),
|
|
330
|
+
/**
|
|
331
|
+
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
332
|
+
* Only supported with claude-opus-4-6.
|
|
333
|
+
*/
|
|
334
|
+
speed: z.enum(['fast', 'standard']).optional(),
|
|
328
335
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
* `server-side-fallback-2026-07-01` beta, which is added automatically.
|
|
339
|
-
* - Array form: an explicit fallback chain. Each entry is merged into the
|
|
340
|
-
* request as a direct request to that entry's model, so it must be
|
|
341
|
-
* formatted accordingly: `model` is required, and an entry may
|
|
342
|
-
* additionally override `max_tokens`, `thinking`, `output_config`, and
|
|
343
|
-
* `speed` for that attempt only (`speed` additionally requires the speed
|
|
344
|
-
* beta). The value is passed through to the API as-is, and the
|
|
345
|
-
* `server-side-fallback-2026-06-01` beta is added automatically.
|
|
346
|
-
*/
|
|
347
|
-
fallbacks: z
|
|
348
|
-
.union([
|
|
349
|
-
z.literal('default'),
|
|
350
|
-
z.array(
|
|
351
|
-
z.object({
|
|
352
|
-
model: z.string(),
|
|
353
|
-
max_tokens: z.number().int().optional(),
|
|
354
|
-
thinking: z.record(z.string(), z.unknown()).optional(),
|
|
355
|
-
output_config: z.record(z.string(), z.unknown()).optional(),
|
|
356
|
-
speed: z.enum(['fast', 'standard']).optional(),
|
|
357
|
-
}),
|
|
358
|
-
),
|
|
359
|
-
])
|
|
360
|
-
.optional(),
|
|
336
|
+
/**
|
|
337
|
+
* Controls where model inference runs for this request.
|
|
338
|
+
*
|
|
339
|
+
* - `"global"`: Inference may run in any available geography (default).
|
|
340
|
+
* - `"us"`: Inference runs only in US-based infrastructure.
|
|
341
|
+
*
|
|
342
|
+
* See https://platform.claude.com/docs/en/build-with-claude/data-residency
|
|
343
|
+
*/
|
|
344
|
+
inferenceGeo: z.enum(['us', 'global']).optional(),
|
|
361
345
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
346
|
+
/**
|
|
347
|
+
* Server-side fallback configuration.
|
|
348
|
+
*
|
|
349
|
+
* When the primary model's safety classifiers block a turn, the API
|
|
350
|
+
* automatically retries it server-side on a fallback model. A
|
|
351
|
+
* `content-filter` finish reason means the fallback(s) refused as well.
|
|
352
|
+
*
|
|
353
|
+
* - `'default'` (recommended): the API routes the retry to Anthropic's
|
|
354
|
+
* recommended fallback model based on the refusal category. Requires the
|
|
355
|
+
* `server-side-fallback-2026-07-01` beta, which is added automatically.
|
|
356
|
+
* - Array form: an explicit fallback chain. Each entry is merged into the
|
|
357
|
+
* request as a direct request to that entry's model, so it must be
|
|
358
|
+
* formatted accordingly: `model` is required, and an entry may
|
|
359
|
+
* additionally override `max_tokens`, `thinking`, `output_config`, and
|
|
360
|
+
* `speed` for that attempt only (`speed` additionally requires the speed
|
|
361
|
+
* beta). The value is passed through to the API as-is, and the
|
|
362
|
+
* `server-side-fallback-2026-06-01` beta is added automatically.
|
|
363
|
+
*/
|
|
364
|
+
fallbacks: z
|
|
365
|
+
.union([
|
|
366
|
+
z.literal('default'),
|
|
367
|
+
z.array(
|
|
368
|
+
z.object({
|
|
369
|
+
model: z.string(),
|
|
370
|
+
max_tokens: z.number().int().optional(),
|
|
371
|
+
thinking: z.record(z.string(), z.unknown()).optional(),
|
|
372
|
+
output_config: z.record(z.string(), z.unknown()).optional(),
|
|
373
|
+
speed: z.enum(['fast', 'standard']).optional(),
|
|
374
|
+
}),
|
|
375
|
+
),
|
|
376
|
+
])
|
|
377
|
+
.optional(),
|
|
367
378
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
* relies on). The per-call verdicts are returned in
|
|
374
|
-
* `providerMetadata.anthropic.safeguardResults`, keyed by tool call id.
|
|
375
|
-
* `classifierContext` is passed through to the API as `classifier_context`.
|
|
376
|
-
* The `dangerous-tool-use-2026-09-03` beta is added automatically.
|
|
377
|
-
*/
|
|
378
|
-
safeguards: z
|
|
379
|
-
.array(
|
|
380
|
-
z.object({
|
|
381
|
-
type: z.literal('dangerous_tool_use'),
|
|
382
|
-
classifierContext: z.record(z.string(), z.unknown()).optional(),
|
|
383
|
-
}),
|
|
384
|
-
)
|
|
385
|
-
.optional(),
|
|
379
|
+
/**
|
|
380
|
+
* A set of beta features to enable.
|
|
381
|
+
* Allow a provider to receive the full `betas` set if it needs it.
|
|
382
|
+
*/
|
|
383
|
+
anthropicBeta: z.array(z.string()).optional(),
|
|
386
384
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
z.object({
|
|
400
|
-
type: z.literal('tool_uses'),
|
|
401
|
-
value: z.number(),
|
|
402
|
-
}),
|
|
403
|
-
])
|
|
404
|
-
.optional(),
|
|
405
|
-
keep: z
|
|
406
|
-
.object({
|
|
407
|
-
type: z.literal('tool_uses'),
|
|
408
|
-
value: z.number(),
|
|
409
|
-
})
|
|
410
|
-
.optional(),
|
|
411
|
-
clearAtLeast: z
|
|
412
|
-
.object({
|
|
413
|
-
type: z.literal('input_tokens'),
|
|
414
|
-
value: z.number(),
|
|
415
|
-
})
|
|
416
|
-
.optional(),
|
|
417
|
-
clearToolInputs: z.boolean().optional(),
|
|
418
|
-
excludeTools: z.array(z.string()).optional(),
|
|
419
|
-
}),
|
|
420
|
-
z.object({
|
|
421
|
-
type: z.literal('clear_thinking_20251015'),
|
|
422
|
-
keep: z
|
|
423
|
-
.union([
|
|
424
|
-
z.literal('all'),
|
|
425
|
-
z.object({
|
|
426
|
-
type: z.literal('thinking_turns'),
|
|
427
|
-
value: z.number(),
|
|
428
|
-
}),
|
|
429
|
-
])
|
|
430
|
-
.optional(),
|
|
431
|
-
}),
|
|
385
|
+
/**
|
|
386
|
+
* Server-side safeguards to run as part of the request.
|
|
387
|
+
*
|
|
388
|
+
* `dangerous_tool_use` asks the API to classify every `tool_use` block in
|
|
389
|
+
* the response for dangerous actions (the check Claude Code's auto mode
|
|
390
|
+
* relies on). The per-call verdicts are returned in
|
|
391
|
+
* `providerMetadata.anthropic.safeguardResults`, keyed by tool call id.
|
|
392
|
+
* `classifierContext` is passed through to the API as `classifier_context`.
|
|
393
|
+
* The `dangerous-tool-use-2026-09-03` beta is added automatically.
|
|
394
|
+
*/
|
|
395
|
+
safeguards: z
|
|
396
|
+
.array(
|
|
432
397
|
z.object({
|
|
433
|
-
type: z.literal('
|
|
434
|
-
|
|
435
|
-
.object({
|
|
436
|
-
type: z.literal('input_tokens'),
|
|
437
|
-
value: z.number(),
|
|
438
|
-
})
|
|
439
|
-
.optional(),
|
|
440
|
-
pauseAfterCompaction: z.boolean().optional(),
|
|
441
|
-
instructions: z.string().optional(),
|
|
398
|
+
type: z.literal('dangerous_tool_use'),
|
|
399
|
+
classifierContext: z.record(z.string(), z.unknown()).optional(),
|
|
442
400
|
}),
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
401
|
+
)
|
|
402
|
+
.optional(),
|
|
403
|
+
|
|
404
|
+
contextManagement: z
|
|
405
|
+
.object({
|
|
406
|
+
edits: z.array(
|
|
407
|
+
z.discriminatedUnion('type', [
|
|
408
|
+
z.object({
|
|
409
|
+
type: z.literal('clear_tool_uses_20250919'),
|
|
410
|
+
trigger: z
|
|
411
|
+
.discriminatedUnion('type', [
|
|
412
|
+
z.object({
|
|
413
|
+
type: z.literal('input_tokens'),
|
|
414
|
+
value: z.number(),
|
|
415
|
+
}),
|
|
416
|
+
z.object({
|
|
417
|
+
type: z.literal('tool_uses'),
|
|
418
|
+
value: z.number(),
|
|
419
|
+
}),
|
|
420
|
+
])
|
|
421
|
+
.optional(),
|
|
422
|
+
keep: z
|
|
423
|
+
.object({
|
|
424
|
+
type: z.literal('tool_uses'),
|
|
425
|
+
value: z.number(),
|
|
426
|
+
})
|
|
427
|
+
.optional(),
|
|
428
|
+
clearAtLeast: z
|
|
429
|
+
.object({
|
|
430
|
+
type: z.literal('input_tokens'),
|
|
431
|
+
value: z.number(),
|
|
432
|
+
})
|
|
433
|
+
.optional(),
|
|
434
|
+
clearToolInputs: z.boolean().optional(),
|
|
435
|
+
excludeTools: z.array(z.string()).optional(),
|
|
436
|
+
}),
|
|
437
|
+
z.object({
|
|
438
|
+
type: z.literal('clear_thinking_20251015'),
|
|
439
|
+
keep: z
|
|
440
|
+
.union([
|
|
441
|
+
z.literal('all'),
|
|
442
|
+
z.object({
|
|
443
|
+
type: z.literal('thinking_turns'),
|
|
444
|
+
value: z.number(),
|
|
445
|
+
}),
|
|
446
|
+
])
|
|
447
|
+
.optional(),
|
|
448
|
+
}),
|
|
449
|
+
z.object({
|
|
450
|
+
type: z.literal('compact_20260112'),
|
|
451
|
+
trigger: z
|
|
452
|
+
.object({
|
|
453
|
+
type: z.literal('input_tokens'),
|
|
454
|
+
value: z.number(),
|
|
455
|
+
})
|
|
456
|
+
.optional(),
|
|
457
|
+
pauseAfterCompaction: z.boolean().optional(),
|
|
458
|
+
instructions: z.string().optional(),
|
|
459
|
+
}),
|
|
460
|
+
]),
|
|
461
|
+
),
|
|
462
|
+
})
|
|
463
|
+
.optional(),
|
|
464
|
+
}),
|
|
465
|
+
);
|
|
447
466
|
});
|
|
448
467
|
|
|
449
|
-
export type AnthropicLanguageModelOptions =
|
|
468
|
+
export type AnthropicLanguageModelOptions = InferSchema<
|
|
450
469
|
typeof anthropicLanguageModelOptions
|
|
451
470
|
>;
|