Open History to see the last commit
1import type {
2 MidConversationChannels,
3 Modality,
4 ModelReasoning,
5} from '@tanstack/ai'
6import type { ModelReasoningCapability } from '@tanstack/ai/adapter-internals'
7import type {
8 AnthropicCacheControlOptions,
9 AnthropicContainerOptions,
10 AnthropicContextManagementOptions,
11 AnthropicMCPOptions,
12 AnthropicMaxTokensOptions,
13 AnthropicSamplingOptions,
14 AnthropicServiceTierOptions,
15 AnthropicStopSequencesOptions,
16 AnthropicToolChoiceOptions,
17} from './text/text-provider-options'
18
19// Reasoning shapes: the levels a model has for `chat({ reasoning })`, and
20// the provider value to send for each. Each model points at one of them.
21const BUDGET_LOW_TO_HIGH = {
22 levels: { low: 'low', medium: 'medium', high: 'high' },
23 budget: true,
24} as const
25const BUDGET_LOW_TO_HIGH_MAX = {
26 levels: { low: 'low', medium: 'medium', high: 'high', max: 'max' },
27 budget: true,
28} as const
29const BUDGET_NONE_LOW_TO_MAX = {
30 levels: {
31 off: 'none',
32 low: 'low',
33 medium: 'medium',
34 high: 'high',
35 xhigh: 'xhigh',
36 max: 'max',
37 },
38 budget: true,
39} as const
40const BUDGET_OFF_TO_HIGH = {
41 levels: {
42 off: 'off',
43 minimal: 'minimal',
44 low: 'low',
45 medium: 'medium',
46 high: 'high',
47 },
48 budget: true,
49} as const
50const EFFORT_LOW_TO_MAX = {
51 levels: {
52 low: 'low',
53 medium: 'medium',
54 high: 'high',
55 xhigh: 'xhigh',
56 max: 'max',
57 },
58 budget: false,
59} as const
60const EFFORT_NONE_LOW_TO_MAX = {
61 levels: {
62 off: 'none',
63 low: 'low',
64 medium: 'medium',
65 high: 'high',
66 xhigh: 'xhigh',
67 max: 'max',
68 },
69 budget: false,
70} as const
71
72interface ModelMeta<
73 TProviderOptions = unknown,
74 TToolCapabilities = unknown,
75 TMessageCapabilities = unknown,
76> {
77 name: string
78 id: string
79 supports: {
80 input: Array<'text' | 'image' | 'audio' | 'video' | 'document'>
81 /**
82 * The mid-conversation channels (from pi 0.87.1): added tools use the
83 * `mid-conversation-tool-changes-2026-07-01` beta, and added prompts go
84 * in a mid-conversation `system` message.
85 */
86 mid_conversation_channels?: MidConversationChannels
87 extended_thinking?: boolean
88 adaptive_thinking?: boolean
89 priority_tier?: boolean
90 /**
91 * `false`: the model rejects a forced tool (`any` or a named `tool`) on
92 * every request, with or without thinking. Absent: it accepts one.
93 */
94 forced_tool_choice?: false
95 /**
96 * Computer use has three kinds, one for each version that a model
97 * accepts: `computer_use` (`computer_20241022` and `computer_20250124`),
98 * `computer_use_20251124`, and `computer_toolset`
99 * (`computer_toolset_20260801`). `computer` is the generic tool from
100 * `@tanstack/ai-computer-use`. Every model with a computer version has it.
101 */
102 tools?: Array<
103 | 'web_search'
104 | 'web_fetch'
105 | 'code_execution'
106 | 'computer'
107 | 'computer_use'
108 | 'computer_use_20251124'
109 | 'computer_toolset'
110 | 'bash'
111 | 'text_editor'
112 | 'memory'
113 >
114 }
115 context_window?: number
116 max_output_tokens?: number
117 knowledge_cutoff?: string
118 pricing: {
119 input: {
120 normal: number
121 cached?: number
122 }
123 output: {
124 normal: number
125 }
126 }
127 /**
128 * Type-level description of which provider options this model supports.
129 */
130 providerOptions?: TProviderOptions
131 /**
132 * Type-level description of which tool capabilities this model supports.
133 */
134 toolCapabilities?: TToolCapabilities
135 /**
136 * Type-level description of which message/input capabilities this model supports.
137 */
138 messageCapabilities?: TMessageCapabilities
139 /** The model's data for `chat({ reasoning })`. None: it does not reason. */
140 reasoning?: ModelReasoning
141}
142
143// Claude Opus 4.6 accepts adaptive thinking alongside the deprecated
144// budget-based extended thinking, and still accepts sampling parameters.
145const CLAUDE_OPUS_4_6 = {
146 name: 'claude-opus-4-6',
147 id: 'claude-opus-4-6',
148 context_window: 200_000,
149 max_output_tokens: 128_000,
150 knowledge_cutoff: '2025-05-01',
151 pricing: {
152 input: {
153 normal: 5,
154 },
155 output: {
156 normal: 25,
157 },
158 },
159 supports: {
160 input: ['text', 'image', 'document'],
161 extended_thinking: true,
162 adaptive_thinking: true,
163 priority_tier: true,
164 tools: [
165 'web_search',
166 'web_fetch',
167 'code_execution',
168 'computer',
169 'computer_use_20251124',
170 'bash',
171 'text_editor',
172 'memory',
173 ],
174 },
175 reasoning: BUDGET_LOW_TO_HIGH_MAX,
176} as const satisfies ModelMeta<
177 AnthropicCacheControlOptions &
178 AnthropicContainerOptions &
179 AnthropicContextManagementOptions &
180 AnthropicMCPOptions &
181 AnthropicServiceTierOptions &
182 AnthropicStopSequencesOptions &
183 AnthropicToolChoiceOptions &
184 AnthropicSamplingOptions
185>
186
187const CLAUDE_OPUS_4_5 = {
188 name: 'claude-opus-4-5',
189 id: 'claude-opus-4-5',
190 context_window: 200_000,
191 max_output_tokens: 32_000,
192 knowledge_cutoff: '2025-11-01',
193 pricing: {
194 input: {
195 normal: 15,
196 },
197 output: {
198 normal: 75,
199 },
200 },
201 supports: {
202 input: ['text', 'image', 'document'],
203 extended_thinking: true,
204 priority_tier: true,
205 tools: [
206 'web_search',
207 'web_fetch',
208 'code_execution',
209 'computer',
210 'computer_use_20251124',
211 'bash',
212 'text_editor',
213 'memory',
214 ],
215 },
216 reasoning: BUDGET_LOW_TO_HIGH,
217} as const satisfies ModelMeta<
218 AnthropicCacheControlOptions &
219 AnthropicContainerOptions &
220 AnthropicContextManagementOptions &
221 AnthropicMCPOptions &
222 AnthropicServiceTierOptions &
223 AnthropicStopSequencesOptions &
224 AnthropicToolChoiceOptions &
225 AnthropicSamplingOptions
226>
227
228// Claude Sonnet 4.6 accepts adaptive thinking alongside the deprecated
229// budget-based extended thinking, and still accepts sampling parameters.
230const CLAUDE_SONNET_4_6 = {
231 name: 'claude-sonnet-4-6',
232 id: 'claude-sonnet-4-6',
233 context_window: 1_000_000,
234 max_output_tokens: 64_000,
235 knowledge_cutoff: '2025-08-01',
236 pricing: {
237 input: {
238 normal: 3,
239 },
240 output: {
241 normal: 15,
242 },
243 },
244 supports: {
245 input: ['text', 'image', 'document'],
246 extended_thinking: true,
247 adaptive_thinking: true,
248 priority_tier: true,
249 tools: [
250 'web_search',
251 'web_fetch',
252 'code_execution',
253 'computer',
254 'computer_use_20251124',
255 'bash',
256 'text_editor',
257 'memory',
258 ],
259 },
260 reasoning: BUDGET_LOW_TO_HIGH_MAX,
261} as const satisfies ModelMeta<
262 AnthropicCacheControlOptions &
263 AnthropicContainerOptions &
264 AnthropicContextManagementOptions &
265 AnthropicMCPOptions &
266 AnthropicServiceTierOptions &
267 AnthropicStopSequencesOptions &
268 AnthropicToolChoiceOptions &
269 AnthropicSamplingOptions
270>
271
272const CLAUDE_SONNET_4_5 = {
273 name: 'claude-sonnet-4-5',
274 id: 'claude-sonnet-4-5',
275 context_window: 200_000,
276 max_output_tokens: 64_000,
277 knowledge_cutoff: '2025-09-29',
278 pricing: {
279 input: {
280 normal: 3,
281 },
282 output: {
283 normal: 15,
284 },
285 },
286 supports: {
287 input: ['text', 'image', 'document'],
288 extended_thinking: true,
289 priority_tier: true,
290 tools: [
291 'web_search',
292 'web_fetch',
293 'code_execution',
294 'computer',
295 'computer_use',
296 'bash',
297 'text_editor',
298 'memory',
299 ],
300 },
301 reasoning: BUDGET_OFF_TO_HIGH,
302} as const satisfies ModelMeta<
303 AnthropicCacheControlOptions &
304 AnthropicContainerOptions &
305 AnthropicContextManagementOptions &
306 AnthropicMCPOptions &
307 AnthropicServiceTierOptions &
308 AnthropicStopSequencesOptions &
309 AnthropicToolChoiceOptions &
310 AnthropicSamplingOptions
311>
312
313const CLAUDE_HAIKU_4_5 = {
314 name: 'claude-haiku-4-5',
315 id: 'claude-haiku-4-5',
316 context_window: 200_000,
317 max_output_tokens: 64_000,
318 knowledge_cutoff: '2025-10-01',
319 pricing: {
320 input: {
321 normal: 1,
322 },
323 output: {
324 normal: 5,
325 },
326 },
327 supports: {
328 input: ['text', 'image', 'document'],
329 extended_thinking: true,
330 priority_tier: true,
331 tools: [
332 'web_search',
333 'web_fetch',
334 'code_execution',
335 'computer',
336 'computer_use',
337 'bash',
338 'text_editor',
339 'memory',
340 ],
341 },
342 reasoning: BUDGET_OFF_TO_HIGH,
343} as const satisfies ModelMeta<
344 AnthropicCacheControlOptions &
345 AnthropicContainerOptions &
346 AnthropicContextManagementOptions &
347 AnthropicMCPOptions &
348 AnthropicServiceTierOptions &
349 AnthropicStopSequencesOptions &
350 AnthropicToolChoiceOptions &
351 AnthropicSamplingOptions
352>
353
354const CLAUDE_OPUS_4_1 = {
355 name: 'claude-opus-4-1',
356 id: 'claude-opus-4-1',
357 context_window: 200_000,
358 max_output_tokens: 64_000,
359 knowledge_cutoff: '2025-08-05',
360 pricing: {
361 input: {
362 normal: 15,
363 },
364 output: {
365 normal: 75,
366 },
367 },
368 supports: {
369 input: ['text', 'image', 'document'],
370 extended_thinking: true,
371 priority_tier: true,
372 tools: [
373 'web_search',
374 'web_fetch',
375 'code_execution',
376 'computer',
377 'computer_use',
378 'bash',
379 'text_editor',
380 'memory',
381 ],
382 },
383 reasoning: BUDGET_OFF_TO_HIGH,
384} as const satisfies ModelMeta<
385 AnthropicCacheControlOptions &
386 AnthropicContainerOptions &
387 AnthropicContextManagementOptions &
388 AnthropicMCPOptions &
389 AnthropicServiceTierOptions &
390 AnthropicStopSequencesOptions &
391 AnthropicToolChoiceOptions &
392 AnthropicSamplingOptions
393>
394
395// Claude Opus 4.7 removed budget-based extended thinking and the sampling
396// parameters (`temperature`, `top_p`, `top_k`) — sending either returns a
397// 400. Use adaptive thinking with `output_config.effort` instead.
398const CLAUDE_OPUS_4_7 = {
399 name: 'claude-opus-4-7',
400 id: 'claude-opus-4-7',
401 context_window: 1_000_000,
402 max_output_tokens: 128_000,
403 supports: {
404 input: ['text', 'image', 'document'],
405 extended_thinking: false,
406 adaptive_thinking: true,
407 priority_tier: true,
408 tools: [
409 'web_search',
410 'web_fetch',
411 'code_execution',
412 'computer',
413 'computer_use_20251124',
414 'bash',
415 'text_editor',
416 'memory',
417 ],
418 },
419 pricing: {
420 input: {
421 normal: 5,
422 cached: 0.5,
423 },
424 output: {
425 normal: 25,
426 },
427 },
428 reasoning: EFFORT_LOW_TO_MAX,
429} as const satisfies ModelMeta<
430 AnthropicCacheControlOptions &
431 AnthropicContainerOptions &
432 AnthropicContextManagementOptions &
433 AnthropicMCPOptions &
434 AnthropicServiceTierOptions &
435 AnthropicStopSequencesOptions &
436 AnthropicToolChoiceOptions &
437 AnthropicMaxTokensOptions
438>
439
440// Claude Opus 4.8 keeps the same request surface as Opus 4.7: adaptive
441// thinking only (budget_tokens 400s), no sampling parameters.
442const CLAUDE_OPUS_4_8 = {
443 name: 'claude-opus-4-8',
444 id: 'claude-opus-4-8',
445 context_window: 1_000_000,
446 max_output_tokens: 128_000,
447 supports: {
448 input: ['text', 'image', 'document'],
449 mid_conversation_channels: { tools: true, systemPrompts: true },
450 extended_thinking: false,
451 adaptive_thinking: true,
452 priority_tier: true,
453 tools: [
454 'web_search',
455 'web_fetch',
456 'code_execution',
457 'computer',
458 'computer_use_20251124',
459 'computer_toolset',
460 'bash',
461 'text_editor',
462 'memory',
463 ],
464 },
465 pricing: {
466 input: {
467 normal: 5,
468 cached: 0.5,
469 },
470 output: {
471 normal: 25,
472 },
473 },
474 reasoning: EFFORT_LOW_TO_MAX,
475} as const satisfies ModelMeta<
476 AnthropicCacheControlOptions &
477 AnthropicContainerOptions &
478 AnthropicContextManagementOptions &
479 AnthropicMCPOptions &
480 AnthropicServiceTierOptions &
481 AnthropicStopSequencesOptions &
482 AnthropicToolChoiceOptions &
483 AnthropicMaxTokensOptions
484>
485
486// Claude Fable 5: thinking is always on — the only accepted explicit
487// `thinking` config is `{type: 'adaptive'}` (disabled/budget_tokens 400),
488// and the sampling parameters (`temperature`, `top_p`, `top_k`) are
489// rejected. Its provider options therefore use the adaptive-only thinking
490// shape and `max_tokens` without the sampling knobs.
491const CLAUDE_FABLE_5 = {
492 name: 'claude-fable-5',
493 id: 'claude-fable-5',
494 context_window: 1_000_000,
495 max_output_tokens: 128_000,
496 supports: {
497 input: ['text', 'image', 'document'],
498 mid_conversation_channels: { tools: true, systemPrompts: true },
499 extended_thinking: false,
500 adaptive_thinking: true,
501 priority_tier: true,
502 tools: [
503 'web_search',
504 'web_fetch',
505 'code_execution',
506 'computer',
507 'computer_use_20251124',
508 'computer_toolset',
509 'bash',
510 'text_editor',
511 'memory',
512 ],
513 },
514 pricing: {
515 input: {
516 normal: 10,
517 cached: 1,
518 },
519 output: {
520 normal: 50,
521 },
522 },
523 reasoning: EFFORT_LOW_TO_MAX,
524} as const satisfies ModelMeta<
525 AnthropicCacheControlOptions &
526 AnthropicContainerOptions &
527 AnthropicContextManagementOptions &
528 AnthropicMCPOptions &
529 AnthropicServiceTierOptions &
530 AnthropicStopSequencesOptions &
531 AnthropicToolChoiceOptions &
532 AnthropicMaxTokensOptions
533>
534
535// Claude Sonnet 5: adaptive thinking is the default (omitting `thinking`
536// runs adaptive); `{type: 'disabled'}` opts out, but the manual
537// `{type: 'enabled', budget_tokens}` shape and non-default sampling
538// parameters (`temperature`, `top_p`, `top_k`) are rejected with a 400.
539// No Priority Tier. $2/$10 per MTok is the standard price.
540const CLAUDE_SONNET_5 = {
541 name: 'claude-sonnet-5',
542 id: 'claude-sonnet-5',
543 context_window: 1_000_000,
544 max_output_tokens: 128_000,
545 supports: {
546 input: ['text', 'image', 'document'],
547 extended_thinking: false,
548 adaptive_thinking: true,
549 tools: [
550 'web_search',
551 'web_fetch',
552 'code_execution',
553 'computer',
554 'computer_use_20251124',
555 'computer_toolset',
556 'bash',
557 'text_editor',
558 'memory',
559 ],
560 },
561 pricing: {
562 input: {
563 normal: 2,
564 cached: 0.2,
565 },
566 output: {
567 normal: 10,
568 },
569 },
570 reasoning: EFFORT_NONE_LOW_TO_MAX,
571} as const satisfies ModelMeta<
572 AnthropicCacheControlOptions &
573 AnthropicContainerOptions &
574 AnthropicContextManagementOptions &
575 AnthropicMCPOptions &
576 AnthropicServiceTierOptions &
577 AnthropicStopSequencesOptions &
578 AnthropicToolChoiceOptions &
579 AnthropicMaxTokensOptions
580>
581
582/**
583 * Model ids accepted by the Anthropic text adapter.
584 *
585 * Every id here resolves against the first-party Anthropic API
586 * (`GET /v1/models/{id}`). Retired models (Claude 3.x, Sonnet 3.7,
587 * Opus 4 / Sonnet 4) and the `-fast` variant ids (fast mode is requested
588 * via the `speed` parameter, not a model id) were removed after Anthropic
589 * turned them off.
590 */
591const CLAUDE_OPUS_5 = {
592 name: 'claude-opus-5',
593 id: 'claude-opus-5',
594 context_window: 1_000_000,
595 max_output_tokens: 128_000,
596 supports: {
597 input: ['text', 'image', 'document'],
598 mid_conversation_channels: { tools: true, systemPrompts: true },
599 tools: [
600 'web_search',
601 'web_fetch',
602 'code_execution',
603 'computer',
604 'computer_use_20251124',
605 'computer_toolset',
606 'bash',
607 'text_editor',
608 'memory',
609 ],
610 },
611 pricing: {
612 input: {
613 normal: 5,
614 cached: 0.5,
615 },
616 output: {
617 normal: 25,
618 },
619 },
620 reasoning: EFFORT_LOW_TO_MAX,
621} as const satisfies ModelMeta<
622 AnthropicContainerOptions &
623 AnthropicContextManagementOptions &
624 AnthropicMCPOptions &
625 AnthropicServiceTierOptions &
626 AnthropicStopSequencesOptions &
627 AnthropicToolChoiceOptions &
628 AnthropicSamplingOptions
629>
630
631const CLAUDE_OPUS_5_FAST = {
632 name: 'claude-opus-5-fast',
633 id: 'claude-opus-5-fast',
634 context_window: 1_000_000,
635 max_output_tokens: 128_000,
636 supports: {
637 input: ['text', 'image', 'document'],
638 tools: [],
639 },
640 pricing: {
641 input: {
642 normal: 10,
643 cached: 1,
644 },
645 output: {
646 normal: 50,
647 },
648 },
649 reasoning: BUDGET_NONE_LOW_TO_MAX,
650} as const satisfies ModelMeta<
651 AnthropicContainerOptions &
652 AnthropicContextManagementOptions &
653 AnthropicMCPOptions &
654 AnthropicServiceTierOptions &
655 AnthropicStopSequencesOptions &
656 AnthropicToolChoiceOptions &
657 AnthropicSamplingOptions
658>
659
660const CLAUDE_FABLE_5_1 = {
661 name: 'claude-fable-5-1',
662 id: 'claude-fable-5-1',
663 context_window: 1_000_000,
664 max_output_tokens: 128_000,
665 supports: {
666 input: ['text', 'image', 'document'],
667 forced_tool_choice: false,
668 mid_conversation_channels: { tools: true, systemPrompts: true },
669 tools: [
670 'web_search',
671 'web_fetch',
672 'code_execution',
673 'computer',
674 'computer_use_20251124',
675 'computer_toolset',
676 'bash',
677 'text_editor',
678 'memory',
679 ],
680 },
681 pricing: {
682 input: {
683 normal: 10,
684 cached: 0.25,
685 },
686 output: {
687 normal: 50,
688 },
689 },
690 reasoning: EFFORT_LOW_TO_MAX,
691} as const satisfies ModelMeta<
692 AnthropicCacheControlOptions &
693 AnthropicContainerOptions &
694 AnthropicContextManagementOptions &
695 AnthropicMCPOptions &
696 AnthropicServiceTierOptions &
697 AnthropicStopSequencesOptions &
698 AnthropicToolChoiceOptions &
699 AnthropicMaxTokensOptions
700>
701
702const CLAUDE_OPUS_5_5 = {
703 name: 'claude-opus-5-5',
704 id: 'claude-opus-5-5',
705 context_window: 1_000_000,
706 max_output_tokens: 128_000,
707 supports: {
708 input: ['text', 'image', 'document'],
709 forced_tool_choice: false,
710 mid_conversation_channels: { tools: true, systemPrompts: true },
711 // Computer use only through `computer_toolset_20260801`.
712 tools: [
713 'web_search',
714 'web_fetch',
715 'code_execution',
716 'computer',
717 'computer_toolset',
718 'bash',
719 'text_editor',
720 'memory',
721 ],
722 },
723 pricing: {
724 input: {
725 normal: 4,
726 cached: 0.2,
727 },
728 output: {
729 normal: 20,
730 },
731 },
732 reasoning: EFFORT_LOW_TO_MAX,
733} as const satisfies ModelMeta<
734 AnthropicCacheControlOptions &
735 AnthropicContainerOptions &
736 AnthropicContextManagementOptions &
737 AnthropicMCPOptions &
738 AnthropicServiceTierOptions &
739 AnthropicStopSequencesOptions &
740 AnthropicToolChoiceOptions &
741 AnthropicSamplingOptions
742>
743
744// Claude Sonnet 5.5: adaptive thinking is the default. `{type: 'disabled'}`
745// and the manual `{type: 'enabled', budget_tokens}` shape return a 400, and
746// so do non-default sampling parameters (`temperature`, `top_p`, `top_k`).
747// Its provider options therefore use the adaptive-only thinking shape and
748// `max_tokens` without the sampling knobs.
749const CLAUDE_SONNET_5_5 = {
750 name: 'claude-sonnet-5-5',
751 id: 'claude-sonnet-5-5',
752 context_window: 1_000_000,
753 max_output_tokens: 128_000,
754 supports: {
755 input: ['text', 'image', 'document'],
756 forced_tool_choice: false,
757 extended_thinking: false,
758 adaptive_thinking: true,
759 // Computer use only through `computer_toolset_20260801`.
760 tools: [
761 'web_search',
762 'web_fetch',
763 'code_execution',
764 'computer',
765 'computer_toolset',
766 'bash',
767 'text_editor',
768 'memory',
769 ],
770 },
771 pricing: {
772 input: {
773 normal: 2,
774 cached: 0.1,
775 },
776 output: {
777 normal: 10,
778 },
779 },
780 reasoning: EFFORT_LOW_TO_MAX,
781} as const satisfies ModelMeta<
782 AnthropicCacheControlOptions &
783 AnthropicContainerOptions &
784 AnthropicContextManagementOptions &
785 AnthropicMCPOptions &
786 AnthropicServiceTierOptions &
787 AnthropicStopSequencesOptions &
788 AnthropicToolChoiceOptions &
789 AnthropicMaxTokensOptions
790>
791
792// Claude Haiku 5.5: `disabled` thinking 400s at xhigh/max (the types cannot
793// say so). Pricing is the <=100K-token tier.
794const CLAUDE_HAIKU_5_5 = {
795 name: 'claude-haiku-5-5',
796 id: 'claude-haiku-5-5',
797 context_window: 1_000_000,
798 max_output_tokens: 128_000,
799 supports: {
800 input: ['text', 'image', 'document'],
801 extended_thinking: false,
802 adaptive_thinking: true,
803 // Computer use only through `computer_toolset_20260801`.
804 tools: [
805 'web_search',
806 'web_fetch',
807 'code_execution',
808 'computer',
809 'computer_toolset',
810 'bash',
811 'text_editor',
812 'memory',
813 ],
814 },
815 pricing: {
816 input: {
817 normal: 0.1,
818 cached: 0.01,
819 },
820 output: {
821 normal: 0.5,
822 },
823 },
824 reasoning: EFFORT_NONE_LOW_TO_MAX,
825} as const satisfies ModelMeta<
826 AnthropicCacheControlOptions &
827 AnthropicContainerOptions &
828 AnthropicContextManagementOptions &
829 AnthropicMCPOptions &
830 AnthropicServiceTierOptions &
831 AnthropicStopSequencesOptions &
832 AnthropicToolChoiceOptions &
833 AnthropicMaxTokensOptions
834>
835
836export const ANTHROPIC_MODELS = [
837 CLAUDE_HAIKU_5_5.id,
838 CLAUDE_SONNET_5_5.id,
839 CLAUDE_OPUS_5_5.id,
840 CLAUDE_FABLE_5_1.id,
841 CLAUDE_OPUS_5.id,
842 CLAUDE_OPUS_5_FAST.id,
843 CLAUDE_OPUS_4_6.id,
844 CLAUDE_OPUS_4_5.id,
845 CLAUDE_SONNET_4_6.id,
846 CLAUDE_SONNET_4_5.id,
847 CLAUDE_HAIKU_4_5.id,
848 CLAUDE_OPUS_4_1.id,
849
850 CLAUDE_OPUS_4_7.id,
851 CLAUDE_OPUS_4_8.id,
852
853 CLAUDE_FABLE_5.id,
854 CLAUDE_SONNET_5.id,
855] as const
856
857/**
858 * Claude chat models on Vertex AI / Gemini Enterprise Agent Platform.
859 * This list is the Google partner catalog, not the full Anthropic API catalog.
860 * Source: https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/partner-models/use-partner-models
861 */
862export const ANTHROPIC_VERTEX_CHAT_MODELS = [
863 CLAUDE_OPUS_5.id,
864 CLAUDE_SONNET_5.id,
865 CLAUDE_FABLE_5.id,
866 CLAUDE_OPUS_4_8.id,
867 CLAUDE_OPUS_4_7.id,
868 CLAUDE_OPUS_4_6.id,
869 CLAUDE_SONNET_4_6.id,
870 CLAUDE_OPUS_4_5.id,
871 CLAUDE_SONNET_4_5.id,
872 CLAUDE_OPUS_4_1.id,
873 CLAUDE_HAIKU_4_5.id,
874] as const
875
876export type AnthropicVertexChatModel =
877 (typeof ANTHROPIC_VERTEX_CHAT_MODELS)[number]
878
879/**
880 * Fallback `max_tokens` ceiling for a model whose metadata carries no
881 * `max_output_tokens` (e.g. an unrecognized model id). Anthropic's Messages
882 * API *requires* `max_tokens`, so the adapter must always send a value. 64K is
883 * the output ceiling of the current mainstream Claude tier (Sonnet/Haiku 4.5),
884 * so it's a sane default for an unknown — almost certainly modern — model and
885 * avoids silently truncating long generations (issue #849). Recognized models
886 * use their exact `max_output_tokens` from {@link ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS}
887 * (e.g. 128K for Opus), so this fallback only ever applies to ids not in the
888 * map.
889 */
890export const ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS = 64_000
891
892/**
893 * Runtime lookup of each model's maximum output-token ceiling, keyed by model
894 * id. Lets the text adapter default the required `max_tokens` request field to
895 * the model's real ceiling when the caller doesn't specify one, rather than a
896 * low constant that truncates responses mid-stream (issue #849).
897 *
898 * Kept in sync with {@link ANTHROPIC_MODELS} by `scripts/sync-provider-models.ts`
899 * — when that script adds a model it also inserts the model's `max_output_tokens`
900 * here, so a freshly-synced model resolves to its real ceiling rather than the
901 * fallback above.
902 */
903const ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS: Record<string, number> = {
904 [CLAUDE_OPUS_4_6.id]: CLAUDE_OPUS_4_6.max_output_tokens,
905 [CLAUDE_OPUS_4_5.id]: CLAUDE_OPUS_4_5.max_output_tokens,
906 [CLAUDE_SONNET_4_6.id]: CLAUDE_SONNET_4_6.max_output_tokens,
907 [CLAUDE_SONNET_4_5.id]: CLAUDE_SONNET_4_5.max_output_tokens,
908 [CLAUDE_HAIKU_4_5.id]: CLAUDE_HAIKU_4_5.max_output_tokens,
909 [CLAUDE_OPUS_4_1.id]: CLAUDE_OPUS_4_1.max_output_tokens,
910 [CLAUDE_OPUS_4_7.id]: CLAUDE_OPUS_4_7.max_output_tokens,
911 [CLAUDE_OPUS_4_8.id]: CLAUDE_OPUS_4_8.max_output_tokens,
912 [CLAUDE_FABLE_5.id]: CLAUDE_FABLE_5.max_output_tokens,
913 [CLAUDE_SONNET_5.id]: CLAUDE_SONNET_5.max_output_tokens,
914 [CLAUDE_OPUS_5.id]: CLAUDE_OPUS_5.max_output_tokens,
915 [CLAUDE_OPUS_5_FAST.id]: CLAUDE_OPUS_5_FAST.max_output_tokens,
916 [CLAUDE_FABLE_5_1.id]: CLAUDE_FABLE_5_1.max_output_tokens,
917 [CLAUDE_OPUS_5_5.id]: CLAUDE_OPUS_5_5.max_output_tokens,
918 [CLAUDE_SONNET_5_5.id]: CLAUDE_SONNET_5_5.max_output_tokens,
919 [CLAUDE_HAIKU_5_5.id]: CLAUDE_HAIKU_5_5.max_output_tokens,
920}
921
922/**
923 * Largest `max_tokens` the Anthropic SDK permits on a **non-streaming**
924 * request. The SDK refuses to make a non-streaming call it estimates could
925 * exceed its 10-minute timeout, computed as
926 * `(60min * max_tokens) / 128_000 > 10min` — i.e. it throws
927 * `"Streaming is required for operations that may take longer than 10 minutes"`
928 * once `max_tokens > 128_000 * 10 / 60 ≈ 21_333`
929 * (`@anthropic-ai/sdk`'s `calculateNonstreamingTimeout`). The text adapter's
930 * only non-streaming call is the forced-tool `structuredOutput()` request, so
931 * its defaulted ceiling must stay at or below this; the streaming chat path
932 * keeps the model's full {@link getAnthropicDefaultMaxTokens} ceiling. We sit
933 * just under the boundary (`21_333` would round-trip to exactly 10min). This
934 * caps only the *default* — an explicit oversized `max_tokens` from the caller
935 * still surfaces the SDK's "use streaming" error, which is the correct signal.
936 */
937export const ANTHROPIC_MAX_NONSTREAMING_TOKENS = 21_000
938
939/**
940 * Resolve the default `max_tokens` for a model: its known `max_output_tokens`
941 * ceiling, or {@link ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS} for unknown models.
942 * Callers that pass an explicit `max_tokens` bypass this entirely.
943 *
944 * Pass `stream: false` for non-streaming requests (the `structuredOutput()`
945 * path): the result is then clamped to {@link ANTHROPIC_MAX_NONSTREAMING_TOKENS}
946 * so the defaulted ceiling doesn't trip the SDK's non-streaming 10-minute guard
947 * (issue #849). Streaming requests (the default) are unaffected and get the
948 * model's full ceiling.
949 */
950export function getAnthropicDefaultMaxTokens(
951 model: string,
952 { stream = true }: { stream?: boolean } = {},
953): number {
954 const ceiling =
955 ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS[model] ??
956 ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS
957 return stream ? ceiling : Math.min(ceiling, ANTHROPIC_MAX_NONSTREAMING_TOKENS)
958}
959
960/**
961 * Anthropic models that support combining `tools` + JSON-Schema-constrained
962 * output in a single streaming Messages request (per issue #605). GA'd
963 * 2026-01-29 for Claude 4.5+ via `output_format` on the beta messages
964 * endpoint. Older Claude models still need the forced-tool-use workaround
965 * in `structuredOutput`.
966 */
967export const ANTHROPIC_COMBINED_TOOLS_AND_SCHEMA_MODELS = new Set<string>([
968 CLAUDE_HAIKU_5_5.id,
969 CLAUDE_SONNET_5_5.id,
970 CLAUDE_OPUS_4_5.id,
971 CLAUDE_OPUS_4_6.id,
972 CLAUDE_OPUS_4_7.id,
973 CLAUDE_OPUS_4_8.id,
974 CLAUDE_OPUS_5.id,
975 CLAUDE_FABLE_5.id,
976 CLAUDE_FABLE_5_1.id,
977 CLAUDE_OPUS_5_5.id,
978 CLAUDE_SONNET_5.id,
979 CLAUDE_SONNET_4_5.id,
980 CLAUDE_SONNET_4_6.id,
981 CLAUDE_HAIKU_4_5.id,
982])
983
984/**
985 * The mid-conversation channels of each model, from
986 * `supports.mid_conversation_channels`. An unknown id gives `undefined`, so
987 * the adapter has no channels.
988 */
989export const ANTHROPIC_MODEL_MID_CONVERSATION_CHANNELS: Readonly<
990 Record<string, MidConversationChannels>
991> = {
992 [CLAUDE_OPUS_4_8.id]: CLAUDE_OPUS_4_8.supports.mid_conversation_channels,
993 [CLAUDE_OPUS_5.id]: CLAUDE_OPUS_5.supports.mid_conversation_channels,
994 [CLAUDE_OPUS_5_5.id]: CLAUDE_OPUS_5_5.supports.mid_conversation_channels,
995 [CLAUDE_FABLE_5.id]: CLAUDE_FABLE_5.supports.mid_conversation_channels,
996 [CLAUDE_FABLE_5_1.id]: CLAUDE_FABLE_5_1.supports.mid_conversation_channels,
997}
998
999// const ANTHROPIC_IMAGE_MODELS = [] as const
1000// const ANTHROPIC_EMBEDDING_MODELS = [] as const
1001// const ANTHROPIC_AUDIO_MODELS = [] as const
1002// const ANTHROPIC_VIDEO_MODELS = [] as const
1003
1004export type AnthropicChatModel = (typeof ANTHROPIC_MODELS)[number]
1005// Manual type map for per-model provider options
1006// Models are differentiated by which thinking shapes and sampling
1007// parameters the API accepts.
1008export type AnthropicChatModelProviderOptionsByName = {
1009 // 4.6 generation: adaptive thinking plus the deprecated budget-based
1010 // shape; sampling parameters still accepted.
1011 [CLAUDE_OPUS_4_6.id]: AnthropicCacheControlOptions &
1012 AnthropicContainerOptions &
1013 AnthropicContextManagementOptions &
1014 AnthropicMCPOptions &
1015 AnthropicServiceTierOptions &
1016 AnthropicStopSequencesOptions &
1017 AnthropicToolChoiceOptions &
1018 AnthropicSamplingOptions
1019 [CLAUDE_SONNET_4_6.id]: AnthropicCacheControlOptions &
1020 AnthropicContainerOptions &
1021 AnthropicContextManagementOptions &
1022 AnthropicMCPOptions &
1023 AnthropicServiceTierOptions &
1024 AnthropicStopSequencesOptions &
1025 AnthropicToolChoiceOptions &
1026 AnthropicSamplingOptions
1027
1028 // Pre-4.6 models: budget-based extended thinking and sampling parameters.
1029 [CLAUDE_OPUS_4_5.id]: AnthropicCacheControlOptions &
1030 AnthropicContainerOptions &
1031 AnthropicContextManagementOptions &
1032 AnthropicMCPOptions &
1033 AnthropicServiceTierOptions &
1034 AnthropicStopSequencesOptions &
1035 AnthropicToolChoiceOptions &
1036 AnthropicSamplingOptions
1037 [CLAUDE_SONNET_4_5.id]: AnthropicCacheControlOptions &
1038 AnthropicContainerOptions &
1039 AnthropicContextManagementOptions &
1040 AnthropicMCPOptions &
1041 AnthropicServiceTierOptions &
1042 AnthropicStopSequencesOptions &
1043 AnthropicToolChoiceOptions &
1044 AnthropicSamplingOptions
1045 [CLAUDE_HAIKU_4_5.id]: AnthropicCacheControlOptions &
1046 AnthropicContainerOptions &
1047 AnthropicContextManagementOptions &
1048 AnthropicMCPOptions &
1049 AnthropicServiceTierOptions &
1050 AnthropicStopSequencesOptions &
1051 AnthropicToolChoiceOptions &
1052 AnthropicSamplingOptions
1053 [CLAUDE_OPUS_4_1.id]: AnthropicCacheControlOptions &
1054 AnthropicContainerOptions &
1055 AnthropicContextManagementOptions &
1056 AnthropicMCPOptions &
1057 AnthropicServiceTierOptions &
1058 AnthropicStopSequencesOptions &
1059 AnthropicToolChoiceOptions &
1060 AnthropicSamplingOptions
1061
1062 // Opus 4.7/4.8: adaptive thinking (or explicit disable), no
1063 // budget_tokens, no sampling parameters — see the constants above.
1064 [CLAUDE_OPUS_4_7.id]: AnthropicCacheControlOptions &
1065 AnthropicContainerOptions &
1066 AnthropicContextManagementOptions &
1067 AnthropicMCPOptions &
1068 AnthropicServiceTierOptions &
1069 AnthropicStopSequencesOptions &
1070 AnthropicToolChoiceOptions &
1071 AnthropicMaxTokensOptions
1072 [CLAUDE_OPUS_4_8.id]: AnthropicCacheControlOptions &
1073 AnthropicContainerOptions &
1074 AnthropicContextManagementOptions &
1075 AnthropicMCPOptions &
1076 AnthropicServiceTierOptions &
1077 AnthropicStopSequencesOptions &
1078 AnthropicToolChoiceOptions &
1079 AnthropicMaxTokensOptions
1080
1081 // Claude Fable 5: thinking always on (adaptive-only config); sampling
1082 // parameters removed — see the CLAUDE_FABLE_5 constant above.
1083 [CLAUDE_FABLE_5.id]: AnthropicCacheControlOptions &
1084 AnthropicContainerOptions &
1085 AnthropicContextManagementOptions &
1086 AnthropicMCPOptions &
1087 AnthropicServiceTierOptions &
1088 AnthropicStopSequencesOptions &
1089 AnthropicToolChoiceOptions &
1090 AnthropicMaxTokensOptions
1091 // Claude Sonnet 5: adaptive thinking by default, explicit disable
1092 // allowed; no budget_tokens, no sampling parameters — see the
1093 // CLAUDE_SONNET_5 constant above.
1094 [CLAUDE_SONNET_5.id]: AnthropicCacheControlOptions &
1095 AnthropicContainerOptions &
1096 AnthropicContextManagementOptions &
1097 AnthropicMCPOptions &
1098 AnthropicServiceTierOptions &
1099 AnthropicStopSequencesOptions &
1100 AnthropicToolChoiceOptions &
1101 AnthropicMaxTokensOptions
1102 [CLAUDE_OPUS_5.id]: AnthropicContainerOptions &
1103 AnthropicContextManagementOptions &
1104 AnthropicMCPOptions &
1105 AnthropicServiceTierOptions &
1106 AnthropicStopSequencesOptions &
1107 AnthropicToolChoiceOptions &
1108 AnthropicSamplingOptions
1109 [CLAUDE_OPUS_5_FAST.id]: AnthropicContainerOptions &
1110 AnthropicContextManagementOptions &
1111 AnthropicMCPOptions &
1112 AnthropicServiceTierOptions &
1113 AnthropicStopSequencesOptions &
1114 AnthropicToolChoiceOptions &
1115 AnthropicSamplingOptions
1116 [CLAUDE_FABLE_5_1.id]: AnthropicCacheControlOptions &
1117 AnthropicContainerOptions &
1118 AnthropicContextManagementOptions &
1119 AnthropicMCPOptions &
1120 AnthropicServiceTierOptions &
1121 AnthropicStopSequencesOptions &
1122 AnthropicToolChoiceOptions &
1123 AnthropicMaxTokensOptions
1124 [CLAUDE_OPUS_5_5.id]: AnthropicCacheControlOptions &
1125 AnthropicContainerOptions &
1126 AnthropicContextManagementOptions &
1127 AnthropicMCPOptions &
1128 AnthropicServiceTierOptions &
1129 AnthropicStopSequencesOptions &
1130 AnthropicToolChoiceOptions &
1131 AnthropicSamplingOptions
1132 // Claude Sonnet 5.5: adaptive-only thinking config, no sampling
1133 // parameters — see the CLAUDE_SONNET_5_5 constant above.
1134 [CLAUDE_SONNET_5_5.id]: AnthropicCacheControlOptions &
1135 AnthropicContainerOptions &
1136 AnthropicContextManagementOptions &
1137 AnthropicMCPOptions &
1138 AnthropicServiceTierOptions &
1139 AnthropicStopSequencesOptions &
1140 AnthropicToolChoiceOptions &
1141 AnthropicMaxTokensOptions
1142 // Claude Haiku 5.5: adaptive or disabled thinking, no budget_tokens, no
1143 // sampling parameters.
1144 [CLAUDE_HAIKU_5_5.id]: AnthropicCacheControlOptions &
1145 AnthropicContainerOptions &
1146 AnthropicContextManagementOptions &
1147 AnthropicMCPOptions &
1148 AnthropicServiceTierOptions &
1149 AnthropicStopSequencesOptions &
1150 AnthropicToolChoiceOptions &
1151 AnthropicMaxTokensOptions
1152}
1153
1154export type AnthropicChatModelToolCapabilitiesByName = {
1155 [CLAUDE_OPUS_4_6.id]: typeof CLAUDE_OPUS_4_6.supports.tools
1156 [CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.tools
1157 [CLAUDE_SONNET_4_6.id]: typeof CLAUDE_SONNET_4_6.supports.tools
1158 [CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.tools
1159 [CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.tools
1160 [CLAUDE_OPUS_4_1.id]: typeof CLAUDE_OPUS_4_1.supports.tools
1161 [CLAUDE_OPUS_4_7.id]: typeof CLAUDE_OPUS_4_7.supports.tools
1162 [CLAUDE_OPUS_4_8.id]: typeof CLAUDE_OPUS_4_8.supports.tools
1163 [CLAUDE_FABLE_5.id]: typeof CLAUDE_FABLE_5.supports.tools
1164 [CLAUDE_SONNET_5.id]: typeof CLAUDE_SONNET_5.supports.tools
1165 [CLAUDE_OPUS_5.id]: typeof CLAUDE_OPUS_5.supports.tools
1166 [CLAUDE_OPUS_5_FAST.id]: typeof CLAUDE_OPUS_5_FAST.supports.tools
1167 [CLAUDE_FABLE_5_1.id]: typeof CLAUDE_FABLE_5_1.supports.tools
1168 [CLAUDE_OPUS_5_5.id]: typeof CLAUDE_OPUS_5_5.supports.tools
1169 [CLAUDE_SONNET_5_5.id]: typeof CLAUDE_SONNET_5_5.supports.tools
1170 [CLAUDE_HAIKU_5_5.id]: typeof CLAUDE_HAIKU_5_5.supports.tools
1171}
1172
1173/**
1174 * Runtime map from chat model name to its tool kinds, for the text adapter.
1175 * `satisfies` keeps it equal to {@link AnthropicChatModelToolCapabilitiesByName}.
1176 * An unknown name gives `undefined`.
1177 */
1178export const ANTHROPIC_MODEL_TOOLS: Readonly<
1179 Record<string, ReadonlyArray<string>>
1180> = {
1181 [CLAUDE_OPUS_4_6.id]: CLAUDE_OPUS_4_6.supports.tools,
1182 [CLAUDE_OPUS_4_5.id]: CLAUDE_OPUS_4_5.supports.tools,
1183 [CLAUDE_SONNET_4_6.id]: CLAUDE_SONNET_4_6.supports.tools,
1184 [CLAUDE_SONNET_4_5.id]: CLAUDE_SONNET_4_5.supports.tools,
1185 [CLAUDE_HAIKU_4_5.id]: CLAUDE_HAIKU_4_5.supports.tools,
1186 [CLAUDE_OPUS_4_1.id]: CLAUDE_OPUS_4_1.supports.tools,
1187 [CLAUDE_OPUS_4_7.id]: CLAUDE_OPUS_4_7.supports.tools,
1188 [CLAUDE_OPUS_4_8.id]: CLAUDE_OPUS_4_8.supports.tools,
1189 [CLAUDE_FABLE_5.id]: CLAUDE_FABLE_5.supports.tools,
1190 [CLAUDE_SONNET_5.id]: CLAUDE_SONNET_5.supports.tools,
1191 [CLAUDE_OPUS_5.id]: CLAUDE_OPUS_5.supports.tools,
1192 [CLAUDE_OPUS_5_FAST.id]: CLAUDE_OPUS_5_FAST.supports.tools,
1193 [CLAUDE_FABLE_5_1.id]: CLAUDE_FABLE_5_1.supports.tools,
1194 [CLAUDE_OPUS_5_5.id]: CLAUDE_OPUS_5_5.supports.tools,
1195 [CLAUDE_SONNET_5_5.id]: CLAUDE_SONNET_5_5.supports.tools,
1196 [CLAUDE_HAIKU_5_5.id]: CLAUDE_HAIKU_5_5.supports.tools,
1197} satisfies AnthropicChatModelToolCapabilitiesByName
1198
1199/**
1200 * Type-only map from chat model name to its supported input modalities.
1201 * All Anthropic Claude models support text, image, and document (PDF) input.
1202 * Used by the core AI types to constrain ContentPart types based on the selected model.
1203 * Note: These must be inlined as readonly arrays (not typeof) because the model
1204 * constants are not exported and typeof references don't work in .d.ts files
1205 * when consumed by external packages.
1206 *
1207 * @see https://docs.anthropic.com/claude/docs/vision
1208 * @see https://docs.anthropic.com/claude/docs/pdf-support
1209 */
1210export type AnthropicModelInputModalitiesByName = {
1211 [CLAUDE_OPUS_4_6.id]: typeof CLAUDE_OPUS_4_6.supports.input
1212 [CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.input
1213 [CLAUDE_SONNET_4_6.id]: typeof CLAUDE_SONNET_4_6.supports.input
1214 [CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.input
1215 [CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.input
1216 [CLAUDE_OPUS_4_1.id]: typeof CLAUDE_OPUS_4_1.supports.input
1217 [CLAUDE_OPUS_4_7.id]: typeof CLAUDE_OPUS_4_7.supports.input
1218 [CLAUDE_OPUS_4_8.id]: typeof CLAUDE_OPUS_4_8.supports.input
1219 [CLAUDE_FABLE_5.id]: typeof CLAUDE_FABLE_5.supports.input
1220 [CLAUDE_SONNET_5.id]: typeof CLAUDE_SONNET_5.supports.input
1221 [CLAUDE_OPUS_5.id]: typeof CLAUDE_OPUS_5.supports.input
1222 [CLAUDE_OPUS_5_FAST.id]: typeof CLAUDE_OPUS_5_FAST.supports.input
1223 [CLAUDE_FABLE_5_1.id]: typeof CLAUDE_FABLE_5_1.supports.input
1224 [CLAUDE_OPUS_5_5.id]: typeof CLAUDE_OPUS_5_5.supports.input
1225 [CLAUDE_SONNET_5_5.id]: typeof CLAUDE_SONNET_5_5.supports.input
1226 [CLAUDE_HAIKU_5_5.id]: typeof CLAUDE_HAIKU_5_5.supports.input
1227}
1228
1229/**
1230 * Runtime map from chat model name to its supported input modalities, for the
1231 * text adapter's `inputModalities`. `satisfies` keeps it equal to
1232 * {@link AnthropicModelInputModalitiesByName}. An unknown name gives `undefined`.
1233 */
1234export const ANTHROPIC_MODEL_INPUT_MODALITIES: Readonly<
1235 Record<string, ReadonlyArray<Modality>>
1236> = {
1237 [CLAUDE_OPUS_4_6.id]: CLAUDE_OPUS_4_6.supports.input,
1238 [CLAUDE_OPUS_4_5.id]: CLAUDE_OPUS_4_5.supports.input,
1239 [CLAUDE_SONNET_4_6.id]: CLAUDE_SONNET_4_6.supports.input,
1240 [CLAUDE_SONNET_4_5.id]: CLAUDE_SONNET_4_5.supports.input,
1241 [CLAUDE_HAIKU_4_5.id]: CLAUDE_HAIKU_4_5.supports.input,
1242 [CLAUDE_OPUS_4_1.id]: CLAUDE_OPUS_4_1.supports.input,
1243 [CLAUDE_OPUS_4_7.id]: CLAUDE_OPUS_4_7.supports.input,
1244 [CLAUDE_OPUS_4_8.id]: CLAUDE_OPUS_4_8.supports.input,
1245 [CLAUDE_FABLE_5.id]: CLAUDE_FABLE_5.supports.input,
1246 [CLAUDE_SONNET_5.id]: CLAUDE_SONNET_5.supports.input,
1247 [CLAUDE_OPUS_5.id]: CLAUDE_OPUS_5.supports.input,
1248 [CLAUDE_OPUS_5_FAST.id]: CLAUDE_OPUS_5_FAST.supports.input,
1249 [CLAUDE_FABLE_5_1.id]: CLAUDE_FABLE_5_1.supports.input,
1250 [CLAUDE_OPUS_5_5.id]: CLAUDE_OPUS_5_5.supports.input,
1251 [CLAUDE_SONNET_5_5.id]: CLAUDE_SONNET_5_5.supports.input,
1252 [CLAUDE_HAIKU_5_5.id]: CLAUDE_HAIKU_5_5.supports.input,
1253} satisfies AnthropicModelInputModalitiesByName
1254
1255/**
1256 * The chat models that reject a forced tool (`any` or a named `tool`) on
1257 * every request. Derived from `supports.forced_tool_choice`. Thinking also
1258 * blocks a forced tool, so the text adapter checks that per request.
1259 */
1260export const ANTHROPIC_NO_FORCED_TOOL_MODELS: ReadonlySet<string> = new Set(
1261 [
1262 CLAUDE_OPUS_4_6,
1263 CLAUDE_OPUS_4_5,
1264 CLAUDE_SONNET_4_6,
1265 CLAUDE_SONNET_4_5,
1266 CLAUDE_HAIKU_4_5,
1267 CLAUDE_OPUS_4_1,
1268 CLAUDE_OPUS_4_7,
1269 CLAUDE_OPUS_4_8,
1270 CLAUDE_FABLE_5,
1271 CLAUDE_SONNET_5,
1272 CLAUDE_OPUS_5,
1273 CLAUDE_OPUS_5_FAST,
1274 CLAUDE_FABLE_5_1,
1275 CLAUDE_OPUS_5_5,
1276 CLAUDE_SONNET_5_5,
1277 CLAUDE_HAIKU_5_5,
1278 ]
1279 .filter((model) => 'forced_tool_choice' in model.supports)
1280 .map((model) => model.id),
1281)
1282
1283// Reasoning
1284//
1285// Each model's `reasoning` field holds its data for `chat({ reasoning })`: the
1286// levels it has, with the provider value for each, and whether it takes a
1287// thinking token budget. The data comes from models.dev. The generator that
1288// writes it comes with the model catalog later. Until then, the sync scripts
1289// keep these fields as they are.
1290
1291const ANTHROPIC_REASONING = {
1292 [CLAUDE_OPUS_4_6.id]: CLAUDE_OPUS_4_6.reasoning,
1293 [CLAUDE_OPUS_4_5.id]: CLAUDE_OPUS_4_5.reasoning,
1294 [CLAUDE_SONNET_4_6.id]: CLAUDE_SONNET_4_6.reasoning,
1295 [CLAUDE_SONNET_4_5.id]: CLAUDE_SONNET_4_5.reasoning,
1296 [CLAUDE_HAIKU_4_5.id]: CLAUDE_HAIKU_4_5.reasoning,
1297 [CLAUDE_OPUS_4_1.id]: CLAUDE_OPUS_4_1.reasoning,
1298 [CLAUDE_OPUS_4_7.id]: CLAUDE_OPUS_4_7.reasoning,
1299 [CLAUDE_OPUS_4_8.id]: CLAUDE_OPUS_4_8.reasoning,
1300 [CLAUDE_FABLE_5.id]: CLAUDE_FABLE_5.reasoning,
1301 [CLAUDE_SONNET_5.id]: CLAUDE_SONNET_5.reasoning,
1302 [CLAUDE_OPUS_5.id]: CLAUDE_OPUS_5.reasoning,
1303 [CLAUDE_OPUS_5_FAST.id]: CLAUDE_OPUS_5_FAST.reasoning,
1304 [CLAUDE_FABLE_5_1.id]: CLAUDE_FABLE_5_1.reasoning,
1305 [CLAUDE_OPUS_5_5.id]: CLAUDE_OPUS_5_5.reasoning,
1306 [CLAUDE_SONNET_5_5.id]: CLAUDE_SONNET_5_5.reasoning,
1307 [CLAUDE_HAIKU_5_5.id]: CLAUDE_HAIKU_5_5.reasoning,
1308}
1309
1310/**
1311 * Each chat model's reasoning levels, and whether it takes a token budget,
1312 * for `chat({ reasoning })`. Derived from the `reasoning` field. A model
1313 * that is not here does not reason.
1314 */
1315export type AnthropicModelReasoningByName = {
1316 [K in keyof typeof ANTHROPIC_REASONING]: ModelReasoningCapability<
1317 (typeof ANTHROPIC_REASONING)[K]
1318 >
1319}
1320
1321/**
1322 * Runtime map from chat model name to its reasoning data, for the text adapter.
1323 * An unknown name gives `undefined`: the adapter sends no reasoning field.
1324 */
1325export const ANTHROPIC_MODEL_REASONING: Readonly<
1326 Record<string, ModelReasoning>
1327> = ANTHROPIC_REASONING