@ai-sdk/anthropic 4.0.107 → 4.0.108

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.
@@ -88,284 +88,541 @@ export type AnthropicLanguageModelEntry = ModelEntry<{
88
88
  requestConfig: { language: AnthropicLanguageRequestConfig };
89
89
  };
90
90
 
91
- type RuntimeDefinition = {
91
+ // Conditional support, used as a cell value in the matrix below.
92
+ const onlyWithoutThinking = {
93
+ condition: 'Only supported when thinking is disabled.',
94
+ } as const;
95
+
96
+ type AnthropicThinkingMode = 'adaptive' | 'budget' | 'between-tools';
97
+
98
+ /**
99
+ * One row of the language model matrix. Every capability that differs between
100
+ * models is its own column, and every listed model fills in every column.
101
+ * Nothing is derived from the model ID or from another column. Facts that
102
+ * depend on each other share one column, so a row cannot contradict itself.
103
+ */
104
+ export type AnthropicLanguageModelRow = {
105
+ /**
106
+ * `false` keeps a known model ID out of the exported catalog and the
107
+ * generated documentation. Its inputs, object generation, tools, and provider
108
+ * options are then reported as `'unknown'`.
109
+ */
110
+ documented: boolean;
111
+ /** Default maximum output tokens. */
92
112
  maxOutputTokens: number;
113
+ /** Whether the model ID belongs to a known model family. */
114
+ knownModel: boolean;
93
115
  nativeStructuredOutput: boolean;
94
- adaptiveThinking: boolean;
95
- samplingParameters: boolean;
96
- xhighEffort: boolean;
97
- thinkingCanBeDisabledAboveHighEffort: boolean;
98
- thinkingCanBeDisabled: boolean;
99
- budgetThinking: boolean;
116
+ /**
117
+ * Extended thinking. `false` means the model does not think. Otherwise the
118
+ * cell lists the thinking modes the model accepts (at least one) and when
119
+ * thinking can be turned off: never (`false`), only at efforts up to `high`,
120
+ * or always.
121
+ */
122
+ thinking:
123
+ | false
124
+ | {
125
+ modes: readonly [AnthropicThinkingMode, ...AnthropicThinkingMode[]];
126
+ canBeDisabled: false | 'up-to-high-effort' | 'always';
127
+ };
128
+ /**
129
+ * Declared reasoning efforts. `undefined` means no exhaustive list. `xhigh`
130
+ * is supported only when it is listed here.
131
+ */
132
+ reasoningEfforts: readonly string[] | undefined;
133
+ /** Temperature, topP, and topK support. */
134
+ sampling: ModelCapability;
100
135
  forcedToolUse: boolean;
101
- betweenToolsThinking: boolean;
102
- knownModel: boolean;
103
- };
104
-
105
- type DocumentedCapabilities = {
106
- toolSearch: boolean;
107
- compaction: boolean;
108
- /** `effort` was introduced with claude-opus-4-5. */
109
- effort: boolean;
136
+ toolSearch: ModelCapability;
137
+ compaction: ModelCapability;
138
+ /** `effort` provider option. It was introduced with claude-opus-4-5. */
139
+ effort: ModelCapability;
140
+ /** `speed` provider option (fast mode). */
141
+ speed: ModelCapability;
142
+ /** `taskBudget` provider option. */
143
+ taskBudget: ModelCapability;
110
144
  };
111
145
 
112
- const legacyClaude = defineRuntime({});
113
- const currentClaude = defineRuntime({
114
- maxOutputTokens: 128000,
115
- nativeStructuredOutput: true,
116
- adaptiveThinking: true,
117
- });
118
- const currentClaudeWithoutSampling = defineRuntime({
119
- ...currentClaude,
120
- samplingParameters: false,
121
- xhighEffort: true,
122
- });
123
-
124
- function defineRuntime(
125
- overrides: Partial<RuntimeDefinition>,
126
- ): RuntimeDefinition {
127
- return {
128
- maxOutputTokens: 4096,
129
- nativeStructuredOutput: false,
130
- adaptiveThinking: false,
131
- samplingParameters: true,
132
- xhighEffort: false,
133
- thinkingCanBeDisabledAboveHighEffort: true,
134
- thinkingCanBeDisabled: true,
135
- budgetThinking: true,
146
+ /**
147
+ * Language model matrix: model IDs by capability. To add a model, add a row and
148
+ * fill in every column.
149
+ */
150
+ const languageModelDefinitions = {
151
+ 'claude-opus-5-5': {
152
+ documented: true,
153
+ maxOutputTokens: 128000,
154
+ knownModel: true,
155
+ nativeStructuredOutput: true,
156
+ thinking: { modes: ['adaptive'], canBeDisabled: false },
157
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
158
+ sampling: onlyWithoutThinking,
159
+ forcedToolUse: false,
160
+ toolSearch: true,
161
+ compaction: true,
162
+ effort: true,
163
+ speed: false,
164
+ taskBudget: 'unknown',
165
+ },
166
+ 'claude-opus-5': {
167
+ documented: true,
168
+ maxOutputTokens: 128000,
169
+ knownModel: true,
170
+ nativeStructuredOutput: true,
171
+ thinking: {
172
+ modes: ['adaptive', 'budget'],
173
+ canBeDisabled: 'up-to-high-effort',
174
+ },
175
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
176
+ sampling: onlyWithoutThinking,
136
177
  forcedToolUse: true,
137
- betweenToolsThinking: false,
178
+ toolSearch: true,
179
+ compaction: true,
180
+ effort: true,
181
+ speed: false,
182
+ taskBudget: 'unknown',
183
+ },
184
+ 'claude-sonnet-5-5': {
185
+ documented: true,
186
+ maxOutputTokens: 128000,
138
187
  knownModel: true,
139
- ...overrides,
140
- };
141
- }
142
-
143
- const runtimeRules: readonly {
144
- matches: (modelId: string) => boolean;
145
- definition: RuntimeDefinition;
146
- }[] = [
147
- {
148
- matches: modelId => modelId.includes('claude-sonnet-5-5'),
149
- definition: defineRuntime({
150
- ...currentClaudeWithoutSampling,
151
- thinkingCanBeDisabledAboveHighEffort: false,
152
- thinkingCanBeDisabled: false,
153
- budgetThinking: false,
154
- forcedToolUse: false,
155
- betweenToolsThinking: true,
156
- }),
188
+ nativeStructuredOutput: true,
189
+ thinking: { modes: ['adaptive', 'between-tools'], canBeDisabled: false },
190
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
191
+ sampling: onlyWithoutThinking,
192
+ forcedToolUse: false,
193
+ toolSearch: true,
194
+ compaction: true,
195
+ effort: true,
196
+ speed: false,
197
+ taskBudget: 'unknown',
157
198
  },
158
- {
159
- matches: modelId => modelId.includes('claude-opus-5-5'),
160
- definition: defineRuntime({
161
- ...currentClaudeWithoutSampling,
162
- thinkingCanBeDisabledAboveHighEffort: false,
163
- thinkingCanBeDisabled: false,
164
- budgetThinking: false,
165
- forcedToolUse: false,
166
- }),
199
+ 'claude-sonnet-5': {
200
+ documented: true,
201
+ maxOutputTokens: 128000,
202
+ knownModel: true,
203
+ nativeStructuredOutput: true,
204
+ thinking: { modes: ['adaptive', 'budget'], canBeDisabled: 'always' },
205
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
206
+ sampling: onlyWithoutThinking,
207
+ forcedToolUse: true,
208
+ toolSearch: true,
209
+ compaction: true,
210
+ effort: true,
211
+ speed: false,
212
+ taskBudget: 'unknown',
167
213
  },
168
- {
169
- matches: modelId => modelId.includes('claude-haiku-5-5'),
170
- definition: defineRuntime({
171
- ...currentClaudeWithoutSampling,
172
- thinkingCanBeDisabledAboveHighEffort: false,
173
- budgetThinking: false,
174
- }),
214
+ 'claude-haiku-5-5': {
215
+ documented: true,
216
+ maxOutputTokens: 128000,
217
+ knownModel: true,
218
+ nativeStructuredOutput: true,
219
+ thinking: { modes: ['adaptive'], canBeDisabled: 'up-to-high-effort' },
220
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
221
+ sampling: onlyWithoutThinking,
222
+ forcedToolUse: true,
223
+ toolSearch: true,
224
+ compaction: true,
225
+ effort: true,
226
+ speed: false,
227
+ taskBudget: 'unknown',
175
228
  },
176
- {
177
- matches: modelId => modelId.includes('claude-opus-5'),
178
- definition: defineRuntime({
179
- ...currentClaudeWithoutSampling,
180
- thinkingCanBeDisabledAboveHighEffort: false,
181
- }),
229
+ 'claude-fable-5-2': {
230
+ documented: true,
231
+ maxOutputTokens: 128000,
232
+ knownModel: true,
233
+ nativeStructuredOutput: true,
234
+ thinking: { modes: ['adaptive'], canBeDisabled: false },
235
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
236
+ sampling: onlyWithoutThinking,
237
+ forcedToolUse: false,
238
+ toolSearch: true,
239
+ compaction: true,
240
+ effort: true,
241
+ speed: false,
242
+ taskBudget: 'unknown',
182
243
  },
183
- {
184
- matches: modelId =>
185
- modelId.includes('claude-fable-5-2') ||
186
- modelId.includes('claude-fable-5-1'),
187
- definition: defineRuntime({
188
- ...currentClaudeWithoutSampling,
189
- thinkingCanBeDisabled: false,
190
- budgetThinking: false,
191
- forcedToolUse: false,
192
- }),
244
+ 'claude-fable-5-1': {
245
+ documented: true,
246
+ maxOutputTokens: 128000,
247
+ knownModel: true,
248
+ nativeStructuredOutput: true,
249
+ thinking: { modes: ['adaptive'], canBeDisabled: false },
250
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
251
+ sampling: onlyWithoutThinking,
252
+ forcedToolUse: false,
253
+ toolSearch: true,
254
+ compaction: true,
255
+ effort: true,
256
+ speed: false,
257
+ taskBudget: 'unknown',
193
258
  },
194
- {
195
- matches: modelId => modelId.includes('claude-fable-5'),
196
- definition: defineRuntime({
197
- ...currentClaudeWithoutSampling,
198
- thinkingCanBeDisabled: false,
199
- budgetThinking: false,
200
- }),
259
+ 'claude-fable-5': {
260
+ documented: true,
261
+ maxOutputTokens: 128000,
262
+ knownModel: true,
263
+ nativeStructuredOutput: true,
264
+ thinking: { modes: ['adaptive'], canBeDisabled: false },
265
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
266
+ sampling: onlyWithoutThinking,
267
+ forcedToolUse: true,
268
+ toolSearch: true,
269
+ compaction: true,
270
+ effort: true,
271
+ speed: false,
272
+ taskBudget: 'unknown',
201
273
  },
202
- {
203
- matches: modelId =>
204
- modelId.includes('claude-opus-4-8') ||
205
- modelId.includes('claude-opus-4-7') ||
206
- modelId.includes('claude-sonnet-5'),
207
- definition: currentClaudeWithoutSampling,
274
+ 'claude-opus-4-8': {
275
+ documented: true,
276
+ maxOutputTokens: 128000,
277
+ knownModel: true,
278
+ nativeStructuredOutput: true,
279
+ thinking: { modes: ['adaptive', 'budget'], canBeDisabled: 'always' },
280
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
281
+ sampling: onlyWithoutThinking,
282
+ forcedToolUse: true,
283
+ toolSearch: true,
284
+ compaction: true,
285
+ effort: true,
286
+ speed: false,
287
+ taskBudget: 'unknown',
208
288
  },
209
- {
210
- matches: modelId =>
211
- modelId.includes('claude-sonnet-4-6') ||
212
- modelId.includes('claude-opus-4-6'),
213
- definition: currentClaude,
289
+ 'claude-opus-4-7': {
290
+ documented: true,
291
+ maxOutputTokens: 128000,
292
+ knownModel: true,
293
+ nativeStructuredOutput: true,
294
+ thinking: { modes: ['adaptive', 'budget'], canBeDisabled: 'always' },
295
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
296
+ sampling: onlyWithoutThinking,
297
+ forcedToolUse: true,
298
+ toolSearch: true,
299
+ compaction: true,
300
+ effort: true,
301
+ speed: false,
302
+ taskBudget: true,
214
303
  },
215
- {
216
- matches: modelId =>
217
- modelId.includes('claude-sonnet-4-5') ||
218
- modelId.includes('claude-opus-4-5') ||
219
- modelId.includes('claude-haiku-4-5'),
220
- definition: defineRuntime({
221
- maxOutputTokens: 64000,
222
- nativeStructuredOutput: true,
223
- }),
304
+ 'claude-opus-4-6': {
305
+ documented: true,
306
+ maxOutputTokens: 128000,
307
+ knownModel: true,
308
+ nativeStructuredOutput: true,
309
+ thinking: { modes: ['adaptive', 'budget'], canBeDisabled: 'always' },
310
+ reasoningEfforts: undefined,
311
+ sampling: true,
312
+ forcedToolUse: true,
313
+ toolSearch: true,
314
+ compaction: true,
315
+ effort: true,
316
+ speed: true,
317
+ taskBudget: 'unknown',
224
318
  },
225
- {
226
- matches: modelId => modelId.includes('claude-opus-4-1'),
227
- definition: defineRuntime({
228
- maxOutputTokens: 32000,
229
- nativeStructuredOutput: true,
230
- }),
319
+ 'claude-sonnet-4-6': {
320
+ documented: true,
321
+ maxOutputTokens: 128000,
322
+ knownModel: true,
323
+ nativeStructuredOutput: true,
324
+ thinking: { modes: ['adaptive', 'budget'], canBeDisabled: 'always' },
325
+ reasoningEfforts: undefined,
326
+ sampling: true,
327
+ forcedToolUse: true,
328
+ toolSearch: true,
329
+ compaction: true,
330
+ effort: true,
331
+ speed: false,
332
+ taskBudget: 'unknown',
231
333
  },
232
- {
233
- matches: modelId => /claude-sonnet-4(?:-|@)/.test(modelId),
234
- definition: defineRuntime({ maxOutputTokens: 64000 }),
334
+ 'claude-opus-4-5': {
335
+ documented: true,
336
+ maxOutputTokens: 64000,
337
+ knownModel: true,
338
+ nativeStructuredOutput: true,
339
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
340
+ reasoningEfforts: undefined,
341
+ sampling: true,
342
+ forcedToolUse: true,
343
+ toolSearch: true,
344
+ compaction: false,
345
+ effort: true,
346
+ speed: false,
347
+ taskBudget: 'unknown',
235
348
  },
236
- {
237
- matches: modelId => /claude-opus-4(?:-|@)/.test(modelId),
238
- definition: defineRuntime({ maxOutputTokens: 32000 }),
349
+ 'claude-haiku-4-5': {
350
+ documented: true,
351
+ maxOutputTokens: 64000,
352
+ knownModel: true,
353
+ nativeStructuredOutput: true,
354
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
355
+ reasoningEfforts: undefined,
356
+ sampling: true,
357
+ forcedToolUse: true,
358
+ toolSearch: true,
359
+ compaction: false,
360
+ effort: false,
361
+ speed: false,
362
+ taskBudget: 'unknown',
239
363
  },
240
- {
241
- matches: modelId => modelId.includes('claude-3-haiku'),
242
- definition: legacyClaude,
364
+ 'claude-sonnet-4-5': {
365
+ documented: true,
366
+ maxOutputTokens: 64000,
367
+ knownModel: true,
368
+ nativeStructuredOutput: true,
369
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
370
+ reasoningEfforts: undefined,
371
+ sampling: true,
372
+ forcedToolUse: true,
373
+ toolSearch: true,
374
+ compaction: false,
375
+ effort: false,
376
+ speed: false,
377
+ taskBudget: 'unknown',
243
378
  },
244
- {
245
- matches: modelId =>
246
- /claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId),
247
- definition: defineRuntime({ knownModel: false }),
379
+ 'claude-opus-4-1': {
380
+ documented: true,
381
+ maxOutputTokens: 32000,
382
+ knownModel: true,
383
+ nativeStructuredOutput: true,
384
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
385
+ reasoningEfforts: undefined,
386
+ sampling: true,
387
+ forcedToolUse: true,
388
+ toolSearch: false,
389
+ compaction: false,
390
+ effort: false,
391
+ speed: false,
392
+ taskBudget: 'unknown',
248
393
  },
249
- ];
394
+ 'claude-opus-4-0': {
395
+ documented: true,
396
+ maxOutputTokens: 32000,
397
+ knownModel: true,
398
+ nativeStructuredOutput: false,
399
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
400
+ reasoningEfforts: undefined,
401
+ sampling: true,
402
+ forcedToolUse: true,
403
+ toolSearch: false,
404
+ compaction: false,
405
+ effort: false,
406
+ speed: false,
407
+ taskBudget: 'unknown',
408
+ },
409
+ 'claude-sonnet-4-0': {
410
+ documented: true,
411
+ maxOutputTokens: 64000,
412
+ knownModel: true,
413
+ nativeStructuredOutput: false,
414
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
415
+ reasoningEfforts: undefined,
416
+ sampling: true,
417
+ forcedToolUse: true,
418
+ toolSearch: false,
419
+ compaction: false,
420
+ effort: false,
421
+ speed: false,
422
+ taskBudget: 'unknown',
423
+ },
424
+ 'claude-3-haiku-20240307': {
425
+ documented: false,
426
+ maxOutputTokens: 4096,
427
+ knownModel: true,
428
+ nativeStructuredOutput: false,
429
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
430
+ reasoningEfforts: undefined,
431
+ sampling: true,
432
+ forcedToolUse: true,
433
+ toolSearch: 'unknown',
434
+ compaction: 'unknown',
435
+ effort: 'unknown',
436
+ speed: 'unknown',
437
+ taskBudget: 'unknown',
438
+ },
439
+ 'claude-haiku-4-5-20251001': {
440
+ documented: false,
441
+ maxOutputTokens: 64000,
442
+ knownModel: true,
443
+ nativeStructuredOutput: true,
444
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
445
+ reasoningEfforts: undefined,
446
+ sampling: true,
447
+ forcedToolUse: true,
448
+ toolSearch: 'unknown',
449
+ compaction: 'unknown',
450
+ effort: 'unknown',
451
+ speed: 'unknown',
452
+ taskBudget: 'unknown',
453
+ },
454
+ 'claude-opus-4-1-20250805': {
455
+ documented: false,
456
+ maxOutputTokens: 32000,
457
+ knownModel: true,
458
+ nativeStructuredOutput: true,
459
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
460
+ reasoningEfforts: undefined,
461
+ sampling: true,
462
+ forcedToolUse: true,
463
+ toolSearch: 'unknown',
464
+ compaction: 'unknown',
465
+ effort: 'unknown',
466
+ speed: 'unknown',
467
+ taskBudget: 'unknown',
468
+ },
469
+ 'claude-opus-4-20250514': {
470
+ documented: false,
471
+ maxOutputTokens: 32000,
472
+ knownModel: true,
473
+ nativeStructuredOutput: false,
474
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
475
+ reasoningEfforts: undefined,
476
+ sampling: true,
477
+ forcedToolUse: true,
478
+ toolSearch: 'unknown',
479
+ compaction: 'unknown',
480
+ effort: 'unknown',
481
+ speed: 'unknown',
482
+ taskBudget: 'unknown',
483
+ },
484
+ 'claude-opus-4-5-20251101': {
485
+ documented: false,
486
+ maxOutputTokens: 64000,
487
+ knownModel: true,
488
+ nativeStructuredOutput: true,
489
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
490
+ reasoningEfforts: undefined,
491
+ sampling: true,
492
+ forcedToolUse: true,
493
+ toolSearch: 'unknown',
494
+ compaction: 'unknown',
495
+ effort: 'unknown',
496
+ speed: 'unknown',
497
+ taskBudget: 'unknown',
498
+ },
499
+ 'claude-sonnet-4-20250514': {
500
+ documented: false,
501
+ maxOutputTokens: 64000,
502
+ knownModel: true,
503
+ nativeStructuredOutput: false,
504
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
505
+ reasoningEfforts: undefined,
506
+ sampling: true,
507
+ forcedToolUse: true,
508
+ toolSearch: 'unknown',
509
+ compaction: 'unknown',
510
+ effort: 'unknown',
511
+ speed: 'unknown',
512
+ taskBudget: 'unknown',
513
+ },
514
+ 'claude-sonnet-4-5-20250929': {
515
+ documented: false,
516
+ maxOutputTokens: 64000,
517
+ knownModel: true,
518
+ nativeStructuredOutput: true,
519
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
520
+ reasoningEfforts: undefined,
521
+ sampling: true,
522
+ forcedToolUse: true,
523
+ toolSearch: 'unknown',
524
+ compaction: 'unknown',
525
+ effort: 'unknown',
526
+ speed: 'unknown',
527
+ taskBudget: 'unknown',
528
+ },
529
+ } satisfies Readonly<Record<string, AnthropicLanguageModelRow>>;
250
530
 
251
- const languageModelDefinitions = {
252
- 'claude-opus-5-5': { toolSearch: true, compaction: true, effort: true },
253
- 'claude-opus-5': { toolSearch: true, compaction: true, effort: true },
254
- 'claude-sonnet-5-5': { toolSearch: true, compaction: true, effort: true },
255
- 'claude-sonnet-5': { toolSearch: true, compaction: true, effort: true },
256
- 'claude-haiku-5-5': { toolSearch: true, compaction: true, effort: true },
257
- 'claude-fable-5-2': { toolSearch: true, compaction: true, effort: true },
258
- 'claude-fable-5-1': { toolSearch: true, compaction: true, effort: true },
259
- 'claude-fable-5': { toolSearch: true, compaction: true, effort: true },
260
- 'claude-opus-4-8': { toolSearch: true, compaction: true, effort: true },
261
- 'claude-opus-4-7': { toolSearch: true, compaction: true, effort: true },
262
- 'claude-opus-4-6': { toolSearch: true, compaction: true, effort: true },
263
- 'claude-sonnet-4-6': { toolSearch: true, compaction: true, effort: true },
264
- 'claude-opus-4-5': { toolSearch: true, compaction: false, effort: true },
265
- 'claude-haiku-4-5': { toolSearch: true, compaction: false, effort: false },
266
- 'claude-sonnet-4-5': { toolSearch: true, compaction: false, effort: false },
267
- 'claude-opus-4-1': { toolSearch: false, compaction: false, effort: false },
268
- 'claude-opus-4-0': { toolSearch: false, compaction: false, effort: false },
269
- 'claude-sonnet-4-0': { toolSearch: false, compaction: false, effort: false },
270
- // Known IDs without declared capabilities retain the custom-model fallback.
271
- 'claude-3-haiku-20240307': undefined,
272
- 'claude-haiku-4-5-20251001': undefined,
273
- 'claude-opus-4-1-20250805': undefined,
274
- 'claude-opus-4-20250514': undefined,
275
- 'claude-opus-4-5-20251101': undefined,
276
- 'claude-sonnet-4-20250514': undefined,
277
- 'claude-sonnet-4-5-20250929': undefined,
278
- } satisfies Readonly<Record<string, DocumentedCapabilities | undefined>>;
531
+ const languageModelRows = Object.entries<AnthropicLanguageModelRow>(
532
+ languageModelDefinitions,
533
+ );
534
+
535
+ /** Entries for every listed model ID, documented or not. */
536
+ const listedLanguageModelEntries: Readonly<
537
+ Record<string, AnthropicLanguageModelEntry>
538
+ > = Object.fromEntries(
539
+ languageModelRows.map(([modelId, row]) => [
540
+ modelId,
541
+ createAnthropicLanguageModelEntry(row),
542
+ ]),
543
+ );
279
544
 
280
545
  export const anthropicModelCatalog: Readonly<
281
546
  Record<string, AnthropicLanguageModelEntry>
282
547
  > = Object.fromEntries(
283
- Object.entries(languageModelDefinitions)
284
- .filter(([, definition]) => definition != null)
285
- .map(([modelId, capabilities]) => [
286
- modelId,
287
- createAnthropicLanguageModelEntry(modelId, capabilities),
288
- ]),
548
+ languageModelRows
549
+ .filter(([, row]) => row.documented)
550
+ .map(([modelId]) => [modelId, listedLanguageModelEntries[modelId]]),
289
551
  );
290
552
 
291
553
  export function getAnthropicLanguageModelEntry(
292
554
  modelId: string,
293
555
  ): AnthropicLanguageModelEntry {
294
- return Object.prototype.hasOwnProperty.call(anthropicModelCatalog, modelId)
295
- ? anthropicModelCatalog[modelId]
296
- : createAnthropicLanguageModelEntry(modelId);
556
+ return Object.prototype.hasOwnProperty.call(
557
+ listedLanguageModelEntries,
558
+ modelId,
559
+ )
560
+ ? listedLanguageModelEntries[modelId]
561
+ : createAnthropicLanguageModelEntry(getUnlistedModelRow(modelId));
297
562
  }
298
563
 
299
564
  function createAnthropicLanguageModelEntry(
300
- modelId: string,
301
- documented?: DocumentedCapabilities,
565
+ row: AnthropicLanguageModelRow,
302
566
  ): AnthropicLanguageModelEntry {
303
- const runtime = resolveRuntimeDefinition(modelId);
304
- const declared = documented != null;
305
- const samplingSupport = runtime.samplingParameters
306
- ? true
307
- : { condition: 'Only supported when thinking is disabled.' };
308
- const reasoningSupport = runtime.adaptiveThinking || runtime.budgetThinking;
567
+ const documentedSupport: ModelCapability = row.documented ? true : 'unknown';
568
+ const thinkingModes: readonly AnthropicThinkingMode[] =
569
+ row.thinking === false ? [] : row.thinking.modes;
570
+ const thinkingCanBeDisabled =
571
+ row.thinking === false ? false : row.thinking.canBeDisabled;
309
572
 
310
573
  return {
311
574
  capabilities: {
312
575
  language: {
313
576
  inputs: {
314
- image: declared ? true : 'unknown',
315
- audio: declared ? false : 'unknown',
577
+ image: documentedSupport,
578
+ audio: row.documented ? false : 'unknown',
316
579
  },
317
- objectGeneration: declared ? true : 'unknown',
580
+ objectGeneration: documentedSupport,
318
581
  tools: {
319
- usage: declared ? true : 'unknown',
320
- streaming: declared ? true : 'unknown',
321
- forcedChoice: runtime.forcedToolUse,
322
- computerUse: declared ? true : 'unknown',
323
- webSearch: declared ? true : 'unknown',
324
- toolSearch: documented?.toolSearch ?? 'unknown',
582
+ usage: documentedSupport,
583
+ streaming: documentedSupport,
584
+ forcedChoice: row.forcedToolUse,
585
+ computerUse: documentedSupport,
586
+ webSearch: documentedSupport,
587
+ toolSearch: row.toolSearch,
325
588
  },
326
589
  reasoning: {
327
- support: reasoningSupport,
328
- efforts: runtime.xhighEffort
329
- ? ['low', 'medium', 'high', 'xhigh', 'max']
330
- : undefined,
331
- adaptive: runtime.adaptiveThinking,
332
- budget: runtime.budgetThinking,
333
- canDisable: runtime.thinkingCanBeDisabled,
334
- canDisableAboveHighEffort:
335
- runtime.thinkingCanBeDisabledAboveHighEffort,
336
- supportsXhighEffort: runtime.xhighEffort,
337
- betweenTools: runtime.betweenToolsThinking,
590
+ support: row.thinking !== false,
591
+ efforts: row.reasoningEfforts,
592
+ adaptive: thinkingModes.includes('adaptive'),
593
+ budget: thinkingModes.includes('budget'),
594
+ canDisable: thinkingCanBeDisabled !== false,
595
+ canDisableAboveHighEffort: thinkingCanBeDisabled === 'always',
596
+ supportsXhighEffort: row.reasoningEfforts?.includes('xhigh') ?? false,
597
+ betweenTools: thinkingModes.includes('between-tools'),
338
598
  },
339
599
  sampling: {
340
- temperature: samplingSupport,
341
- topP: samplingSupport,
342
- topK: samplingSupport,
600
+ temperature: row.sampling,
601
+ topP: row.sampling,
602
+ topK: row.sampling,
343
603
  logprobs: false,
344
604
  },
345
- structuredOutput: { native: runtime.nativeStructuredOutput },
346
- compaction: documented?.compaction ?? 'unknown',
605
+ structuredOutput: { native: row.nativeStructuredOutput },
606
+ compaction: row.compaction,
347
607
  },
348
608
  },
349
609
  providerOptions: {
350
610
  language: declareProviderOptions(
351
611
  anthropicProviderOptions.language,
352
- declared ? true : 'unknown',
612
+ documentedSupport,
353
613
  {
354
614
  includePings: true,
355
- thinking: reasoningSupport,
356
- effort: documented?.effort ?? 'unknown',
357
- // Fast mode is documented for claude-opus-4-6 only.
358
- speed: declared ? modelId === 'claude-opus-4-6' : 'unknown',
359
- // Task budgets are documented for claude-opus-4-7; other models are
360
- // not documented either way.
361
- taskBudget: modelId === 'claude-opus-4-7' ? true : 'unknown',
615
+ thinking: row.thinking !== false,
616
+ effort: row.effort,
617
+ speed: row.speed,
618
+ taskBudget: row.taskBudget,
362
619
  },
363
620
  ),
364
621
  },
365
622
  requestConfig: {
366
623
  language: {
367
- maxOutputTokens: runtime.maxOutputTokens,
368
- knownModel: runtime.knownModel,
624
+ maxOutputTokens: row.maxOutputTokens,
625
+ knownModel: row.knownModel,
369
626
  },
370
627
  },
371
628
  };
@@ -385,17 +642,160 @@ function declareProviderOptions<Option extends string>(
385
642
  ) as Record<Option, ModelCapability>;
386
643
  }
387
644
 
388
- function resolveRuntimeDefinition(modelId: string): RuntimeDefinition {
389
- const rule = runtimeRules.find(rule => rule.matches(modelId));
390
- if (rule != null) return rule.definition;
645
+ /**
646
+ * Generic rows for model IDs that are not in the matrix and match no listed
647
+ * model family.
648
+ */
649
+ const unknownClaudeModel: AnthropicLanguageModelRow = {
650
+ documented: false,
651
+ maxOutputTokens: 128000,
652
+ knownModel: false,
653
+ nativeStructuredOutput: true,
654
+ thinking: {
655
+ modes: ['adaptive', 'budget'],
656
+ canBeDisabled: 'up-to-high-effort',
657
+ },
658
+ reasoningEfforts: ['low', 'medium', 'high', 'xhigh', 'max'],
659
+ sampling: onlyWithoutThinking,
660
+ forcedToolUse: true,
661
+ toolSearch: 'unknown',
662
+ compaction: 'unknown',
663
+ effort: 'unknown',
664
+ speed: 'unknown',
665
+ taskBudget: 'unknown',
666
+ };
391
667
 
392
- return modelId.includes('claude-')
393
- ? defineRuntime({
394
- ...currentClaudeWithoutSampling,
395
- thinkingCanBeDisabledAboveHighEffort: false,
396
- knownModel: false,
397
- })
398
- : defineRuntime({ knownModel: false });
668
+ /** Legacy Claude models (Claude Instant, 2, and 3) and non-Claude model IDs. */
669
+ const unknownLegacyModel: AnthropicLanguageModelRow = {
670
+ documented: false,
671
+ maxOutputTokens: 4096,
672
+ knownModel: false,
673
+ nativeStructuredOutput: false,
674
+ thinking: { modes: ['budget'], canBeDisabled: 'always' },
675
+ reasoningEfforts: undefined,
676
+ sampling: true,
677
+ forcedToolUse: true,
678
+ toolSearch: 'unknown',
679
+ compaction: 'unknown',
680
+ effort: 'unknown',
681
+ speed: 'unknown',
682
+ taskBudget: 'unknown',
683
+ };
684
+
685
+ /**
686
+ * Family rules, used only for model IDs that are not listed in the matrix,
687
+ * such as provider-prefixed, regional, or versioned IDs. The first match
688
+ * decides which listed row's request behavior the model ID uses.
689
+ */
690
+ const unlistedModelFamilies: readonly {
691
+ matches: (modelId: string) => boolean;
692
+ row: AnthropicLanguageModelRow;
693
+ }[] = [
694
+ {
695
+ matches: modelId => modelId.includes('claude-sonnet-5-5'),
696
+ row: languageModelDefinitions['claude-sonnet-5-5'],
697
+ },
698
+ {
699
+ matches: modelId => modelId.includes('claude-opus-5-5'),
700
+ row: languageModelDefinitions['claude-opus-5-5'],
701
+ },
702
+ {
703
+ matches: modelId => modelId.includes('claude-haiku-5-5'),
704
+ row: languageModelDefinitions['claude-haiku-5-5'],
705
+ },
706
+ {
707
+ matches: modelId => modelId.includes('claude-opus-5'),
708
+ row: languageModelDefinitions['claude-opus-5'],
709
+ },
710
+ {
711
+ matches: modelId => modelId.includes('claude-fable-5-2'),
712
+ row: languageModelDefinitions['claude-fable-5-2'],
713
+ },
714
+ {
715
+ matches: modelId => modelId.includes('claude-fable-5-1'),
716
+ row: languageModelDefinitions['claude-fable-5-1'],
717
+ },
718
+ {
719
+ matches: modelId => modelId.includes('claude-fable-5'),
720
+ row: languageModelDefinitions['claude-fable-5'],
721
+ },
722
+ {
723
+ matches: modelId => modelId.includes('claude-opus-4-8'),
724
+ row: languageModelDefinitions['claude-opus-4-8'],
725
+ },
726
+ {
727
+ matches: modelId => modelId.includes('claude-opus-4-7'),
728
+ row: languageModelDefinitions['claude-opus-4-7'],
729
+ },
730
+ {
731
+ matches: modelId => modelId.includes('claude-sonnet-5'),
732
+ row: languageModelDefinitions['claude-sonnet-5'],
733
+ },
734
+ {
735
+ matches: modelId => modelId.includes('claude-sonnet-4-6'),
736
+ row: languageModelDefinitions['claude-sonnet-4-6'],
737
+ },
738
+ {
739
+ matches: modelId => modelId.includes('claude-opus-4-6'),
740
+ row: languageModelDefinitions['claude-opus-4-6'],
741
+ },
742
+ {
743
+ matches: modelId => modelId.includes('claude-sonnet-4-5'),
744
+ row: languageModelDefinitions['claude-sonnet-4-5'],
745
+ },
746
+ {
747
+ matches: modelId => modelId.includes('claude-opus-4-5'),
748
+ row: languageModelDefinitions['claude-opus-4-5'],
749
+ },
750
+ {
751
+ matches: modelId => modelId.includes('claude-haiku-4-5'),
752
+ row: languageModelDefinitions['claude-haiku-4-5'],
753
+ },
754
+ {
755
+ matches: modelId => modelId.includes('claude-opus-4-1'),
756
+ row: languageModelDefinitions['claude-opus-4-1'],
757
+ },
758
+ {
759
+ matches: modelId => /claude-sonnet-4(?:-|@)/.test(modelId),
760
+ row: languageModelDefinitions['claude-sonnet-4-0'],
761
+ },
762
+ {
763
+ matches: modelId => /claude-opus-4(?:-|@)/.test(modelId),
764
+ row: languageModelDefinitions['claude-opus-4-0'],
765
+ },
766
+ {
767
+ matches: modelId => modelId.includes('claude-3-haiku'),
768
+ row: languageModelDefinitions['claude-3-haiku-20240307'],
769
+ },
770
+ {
771
+ matches: modelId =>
772
+ /claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId),
773
+ row: unknownLegacyModel,
774
+ },
775
+ {
776
+ matches: modelId => modelId.includes('claude-'),
777
+ row: unknownClaudeModel,
778
+ },
779
+ ];
780
+
781
+ /**
782
+ * Resolves an unlisted model ID to a row. A family match keeps that family's
783
+ * request behavior, but nothing is documented for the unlisted ID itself.
784
+ */
785
+ function getUnlistedModelRow(modelId: string): AnthropicLanguageModelRow {
786
+ const row =
787
+ unlistedModelFamilies.find(family => family.matches(modelId))?.row ??
788
+ unknownLegacyModel;
789
+
790
+ return {
791
+ ...row,
792
+ documented: false,
793
+ toolSearch: 'unknown',
794
+ compaction: 'unknown',
795
+ effort: 'unknown',
796
+ speed: 'unknown',
797
+ taskBudget: 'unknown',
798
+ };
399
799
  }
400
800
 
401
801
  /** Compatibility projection for the provider's existing request preparation. */