Skip to content

Commit b7d6194

Browse files
feat: add claude-sonnet-4-6 model metadata to Anthropic adapter (TanStack#378)
Add CLAUDE_SONNET_4_6 with 1M native context window, 64k max output, and adaptive thinking support. Register in all model type maps and add to ts-react-chat example model selector. Co-authored-by: Alem Tuzlak <t.zlak@hotmail.com>
1 parent dc53e1b commit b7d6194

4 files changed

Lines changed: 119 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/ai-anthropic': minor
3+
---
4+
5+
Add `claude-sonnet-4-6` model metadata to the Anthropic adapter, including 1M native context window and adaptive thinking support.

examples/ts-react-chat/src/lib/model-selection.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export const MODEL_OPTIONS: Array<ModelOption> = [
2020
{ provider: 'openai', model: 'gpt-5', label: 'OpenAI - GPT-5' },
2121

2222
// Anthropic
23+
{
24+
provider: 'anthropic',
25+
model: 'claude-sonnet-4-6',
26+
label: 'Anthropic - Claude Sonnet 4.6',
27+
},
2328
{
2429
provider: 'anthropic',
2530
model: 'claude-sonnet-4-5-20250929',

packages/typescript/ai-anthropic/src/model-meta.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,37 @@ const CLAUDE_OPUS_4_5 = {
108108
AnthropicSamplingOptions
109109
>
110110

111+
const CLAUDE_SONNET_4_6 = {
112+
name: 'claude-sonnet-4-6',
113+
id: 'claude-sonnet-4-6',
114+
context_window: 1_000_000,
115+
max_output_tokens: 64_000,
116+
knowledge_cutoff: '2025-08-01',
117+
pricing: {
118+
input: {
119+
normal: 3,
120+
},
121+
output: {
122+
normal: 15,
123+
},
124+
},
125+
supports: {
126+
input: ['text', 'image', 'document'],
127+
extended_thinking: true,
128+
adaptive_thinking: true,
129+
priority_tier: true,
130+
},
131+
} as const satisfies ModelMeta<
132+
AnthropicContainerOptions &
133+
AnthropicContextManagementOptions &
134+
AnthropicMCPOptions &
135+
AnthropicServiceTierOptions &
136+
AnthropicStopSequencesOptions &
137+
AnthropicThinkingOptions &
138+
AnthropicToolChoiceOptions &
139+
AnthropicSamplingOptions
140+
>
141+
111142
const CLAUDE_SONNET_4_5 = {
112143
name: 'claude-sonnet-4-5',
113144
id: 'claude-sonnet-4-5',
@@ -395,6 +426,7 @@ const CLAUDE_HAIKU_3 = {
395426
export const ANTHROPIC_MODELS = [
396427
CLAUDE_OPUS_4_6.id,
397428
CLAUDE_OPUS_4_5.id,
429+
CLAUDE_SONNET_4_6.id,
398430
CLAUDE_SONNET_4_5.id,
399431
CLAUDE_HAIKU_4_5.id,
400432
CLAUDE_OPUS_4_1.id,
@@ -432,6 +464,14 @@ export type AnthropicChatModelProviderOptionsByName = {
432464
AnthropicThinkingOptions &
433465
AnthropicToolChoiceOptions &
434466
AnthropicSamplingOptions
467+
[CLAUDE_SONNET_4_6.id]: AnthropicContainerOptions &
468+
AnthropicContextManagementOptions &
469+
AnthropicMCPOptions &
470+
AnthropicServiceTierOptions &
471+
AnthropicStopSequencesOptions &
472+
AnthropicThinkingOptions &
473+
AnthropicToolChoiceOptions &
474+
AnthropicSamplingOptions
435475
[CLAUDE_SONNET_4_5.id]: AnthropicContainerOptions &
436476
AnthropicContextManagementOptions &
437477
AnthropicMCPOptions &
@@ -513,6 +553,7 @@ export type AnthropicChatModelProviderOptionsByName = {
513553
export type AnthropicModelInputModalitiesByName = {
514554
[CLAUDE_OPUS_4_6.id]: typeof CLAUDE_OPUS_4_6.supports.input
515555
[CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.input
556+
[CLAUDE_SONNET_4_6.id]: typeof CLAUDE_SONNET_4_6.supports.input
516557
[CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.input
517558
[CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.input
518559
[CLAUDE_OPUS_4_1.id]: typeof CLAUDE_OPUS_4_1.supports.input

packages/typescript/ai-anthropic/tests/model-meta.test.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,30 @@ type BaseOptions = AnthropicContainerOptions &
4343

4444
describe('Anthropic Model Provider Options Type Assertions', () => {
4545
describe('Models WITH extended_thinking support', () => {
46+
it('claude-sonnet-4-6 should support thinking options', () => {
47+
type Options =
48+
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-6']
49+
50+
// Should have thinking options
51+
expectTypeOf<Options>().toExtend<AnthropicThinkingOptions>()
52+
53+
// Should have service tier options (priority_tier support)
54+
expectTypeOf<Options>().toExtend<AnthropicServiceTierOptions>()
55+
56+
// Should have base options
57+
expectTypeOf<Options>().toExtend<BaseOptions>()
58+
59+
// Verify specific properties exist
60+
expectTypeOf<Options>().toHaveProperty('thinking')
61+
expectTypeOf<Options>().toHaveProperty('service_tier')
62+
expectTypeOf<Options>().toHaveProperty('container')
63+
expectTypeOf<Options>().toHaveProperty('context_management')
64+
expectTypeOf<Options>().toHaveProperty('mcp_servers')
65+
expectTypeOf<Options>().toHaveProperty('stop_sequences')
66+
expectTypeOf<Options>().toHaveProperty('tool_choice')
67+
expectTypeOf<Options>().toHaveProperty('top_k')
68+
})
69+
4670
it('claude-sonnet-4-5 should support thinking options', () => {
4771
type Options =
4872
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-5']
@@ -177,6 +201,7 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
177201
type Keys = keyof AnthropicChatModelProviderOptionsByName
178202

179203
expectTypeOf<'claude-opus-4-5'>().toExtend<Keys>()
204+
expectTypeOf<'claude-sonnet-4-6'>().toExtend<Keys>()
180205
expectTypeOf<'claude-sonnet-4-5'>().toExtend<Keys>()
181206
expectTypeOf<'claude-haiku-4-5'>().toExtend<Keys>()
182207
expectTypeOf<'claude-opus-4-1'>().toExtend<Keys>()
@@ -193,6 +218,9 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
193218
expectTypeOf<
194219
AnthropicChatModelProviderOptionsByName['claude-opus-4-5']
195220
>().toHaveProperty('container')
221+
expectTypeOf<
222+
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-6']
223+
>().toHaveProperty('container')
196224
expectTypeOf<
197225
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-5']
198226
>().toHaveProperty('container')
@@ -223,6 +251,9 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
223251
expectTypeOf<
224252
AnthropicChatModelProviderOptionsByName['claude-opus-4-5']
225253
>().toHaveProperty('context_management')
254+
expectTypeOf<
255+
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-6']
256+
>().toHaveProperty('context_management')
226257
expectTypeOf<
227258
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-5']
228259
>().toHaveProperty('context_management')
@@ -253,6 +284,9 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
253284
expectTypeOf<
254285
AnthropicChatModelProviderOptionsByName['claude-opus-4-5']
255286
>().toHaveProperty('mcp_servers')
287+
expectTypeOf<
288+
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-6']
289+
>().toHaveProperty('mcp_servers')
256290
expectTypeOf<
257291
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-5']
258292
>().toHaveProperty('mcp_servers')
@@ -283,6 +317,9 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
283317
expectTypeOf<
284318
AnthropicChatModelProviderOptionsByName['claude-opus-4-5']
285319
>().toHaveProperty('stop_sequences')
320+
expectTypeOf<
321+
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-6']
322+
>().toHaveProperty('stop_sequences')
286323
expectTypeOf<
287324
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-5']
288325
>().toHaveProperty('stop_sequences')
@@ -313,6 +350,9 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
313350
expectTypeOf<
314351
AnthropicChatModelProviderOptionsByName['claude-opus-4-5']
315352
>().toHaveProperty('tool_choice')
353+
expectTypeOf<
354+
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-6']
355+
>().toHaveProperty('tool_choice')
316356
expectTypeOf<
317357
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-5']
318358
>().toHaveProperty('tool_choice')
@@ -343,6 +383,9 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
343383
expectTypeOf<
344384
AnthropicChatModelProviderOptionsByName['claude-opus-4-5']
345385
>().toHaveProperty('top_k')
386+
expectTypeOf<
387+
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-6']
388+
>().toHaveProperty('top_k')
346389
expectTypeOf<
347390
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-5']
348391
>().toHaveProperty('top_k')
@@ -375,6 +418,9 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
375418
expectTypeOf<
376419
AnthropicChatModelProviderOptionsByName['claude-opus-4-5']
377420
>().toExtend<AnthropicThinkingOptions>()
421+
expectTypeOf<
422+
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-6']
423+
>().toExtend<AnthropicThinkingOptions>()
378424
expectTypeOf<
379425
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-5']
380426
>().toExtend<AnthropicThinkingOptions>()
@@ -408,6 +454,9 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
408454
expectTypeOf<
409455
AnthropicChatModelProviderOptionsByName['claude-opus-4-5']
410456
>().toExtend<AnthropicServiceTierOptions>()
457+
expectTypeOf<
458+
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-6']
459+
>().toExtend<AnthropicServiceTierOptions>()
411460
expectTypeOf<
412461
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-5']
413462
>().toExtend<AnthropicServiceTierOptions>()
@@ -441,6 +490,9 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
441490
expectTypeOf<
442491
AnthropicChatModelProviderOptionsByName['claude-opus-4-5']
443492
>().toExtend<BaseOptions>()
493+
expectTypeOf<
494+
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-6']
495+
>().toExtend<BaseOptions>()
444496
expectTypeOf<
445497
AnthropicChatModelProviderOptionsByName['claude-sonnet-4-5']
446498
>().toExtend<BaseOptions>()
@@ -498,6 +550,22 @@ describe('Anthropic Model Input Modality Type Assertions', () => {
498550
})
499551
})
500552

553+
describe('Claude Sonnet 4.6 (text + image + document)', () => {
554+
type Modalities = AnthropicModelInputModalitiesByName['claude-sonnet-4-6']
555+
type Message = ConstrainedModelMessage<Modalities>
556+
557+
it('should allow TextPart, ImagePart, and DocumentPart', () => {
558+
expectTypeOf<MessageWithContent<TextPart>>().toExtend<Message>()
559+
expectTypeOf<MessageWithContent<ImagePart>>().toExtend<Message>()
560+
expectTypeOf<MessageWithContent<DocumentPart>>().toExtend<Message>()
561+
})
562+
563+
it('should NOT allow AudioPart or VideoPart', () => {
564+
expectTypeOf<MessageWithContent<AudioPart>>().not.toExtend<Message>()
565+
expectTypeOf<MessageWithContent<VideoPart>>().not.toExtend<Message>()
566+
})
567+
})
568+
501569
describe('Claude Sonnet 4.5 (text + image + document)', () => {
502570
type Modalities = AnthropicModelInputModalitiesByName['claude-sonnet-4-5']
503571
type Message = ConstrainedModelMessage<Modalities>

0 commit comments

Comments
 (0)