Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-maps-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/ai-anthropic': patch
---

Added Claude Sonnet 5, Claude Fable 5, Opus 4.7 Fast, Opus 4.8, and Opus 4.8 Fast to `ANTHROPIC_COMBINED_TOOLS_AND_SCHEMA_MODELS` and `AnthropicChatModelToolCapabilitiesByName`
9 changes: 9 additions & 0 deletions packages/ai-anthropic/src/model-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,10 @@ export const ANTHROPIC_COMBINED_TOOLS_AND_SCHEMA_MODELS = new Set<string>([
CLAUDE_SONNET_4_5.id,
CLAUDE_SONNET_4_6.id,
CLAUDE_HAIKU_4_5.id,
CLAUDE_OPUS_4_8.id,
CLAUDE_OPUS_4_8_FAST.id,
CLAUDE_FABLE_5.id,
CLAUDE_SONNET_5.id,
])

// const ANTHROPIC_IMAGE_MODELS = [] as const
Expand Down Expand Up @@ -1004,6 +1008,11 @@ export type AnthropicChatModelToolCapabilitiesByName = {
[CLAUDE_HAIKU_3.id]: typeof CLAUDE_HAIKU_3.supports.tools
[CLAUDE_OPUS_4_6_FAST.id]: typeof CLAUDE_OPUS_4_6_FAST.supports.tools
[CLAUDE_OPUS_4_7.id]: typeof CLAUDE_OPUS_4_7.supports.tools
[CLAUDE_OPUS_4_7_FAST.id]: typeof CLAUDE_OPUS_4_7_FAST.supports.tools
[CLAUDE_OPUS_4_8.id]: typeof CLAUDE_OPUS_4_8.supports.tools
[CLAUDE_OPUS_4_8_FAST.id]: typeof CLAUDE_OPUS_4_8_FAST.supports.tools
[CLAUDE_FABLE_5.id]: typeof CLAUDE_FABLE_5.supports.tools
[CLAUDE_SONNET_5.id]: typeof CLAUDE_SONNET_5.supports.tools
}

/**
Expand Down
134 changes: 134 additions & 0 deletions packages/ai-anthropic/tests/model-meta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,40 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<Options>().toHaveProperty('tool_choice')
expectTypeOf<Options>().toHaveProperty('top_k')
})

it('claude-sonnet-5 should support thinking options', () => {
type Options = AnthropicChatModelProviderOptionsByName['claude-sonnet-5']

expectTypeOf<Options>().toExtend<AnthropicThinkingOptions>()
expectTypeOf<Options>().toExtend<AnthropicServiceTierOptions>()
expectTypeOf<Options>().toExtend<BaseOptions>()

expectTypeOf<Options>().toHaveProperty('thinking')
expectTypeOf<Options>().toHaveProperty('service_tier')
expectTypeOf<Options>().toHaveProperty('container')
expectTypeOf<Options>().toHaveProperty('context_management')
expectTypeOf<Options>().toHaveProperty('mcp_servers')
expectTypeOf<Options>().toHaveProperty('stop_sequences')
expectTypeOf<Options>().toHaveProperty('tool_choice')
expectTypeOf<Options>().toHaveProperty('top_k')
})

it('claude-fable-5 should support thinking options', () => {
type Options = AnthropicChatModelProviderOptionsByName['claude-fable-5']

expectTypeOf<Options>().toExtend<AnthropicThinkingOptions>()
expectTypeOf<Options>().toExtend<AnthropicServiceTierOptions>()
expectTypeOf<Options>().toExtend<BaseOptions>()

expectTypeOf<Options>().toHaveProperty('thinking')
expectTypeOf<Options>().toHaveProperty('service_tier')
expectTypeOf<Options>().toHaveProperty('container')
expectTypeOf<Options>().toHaveProperty('context_management')
expectTypeOf<Options>().toHaveProperty('mcp_servers')
expectTypeOf<Options>().toHaveProperty('stop_sequences')
expectTypeOf<Options>().toHaveProperty('tool_choice')
expectTypeOf<Options>().toHaveProperty('top_k')
})
})

describe('Models WITHOUT extended_thinking support', () => {
Expand Down Expand Up @@ -221,6 +255,8 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<'claude-opus-4'>().toExtend<Keys>()
expectTypeOf<'claude-3-5-haiku'>().toExtend<Keys>()
expectTypeOf<'claude-3-haiku'>().toExtend<Keys>()
expectTypeOf<'claude-sonnet-5'>().toExtend<Keys>()
expectTypeOf<'claude-fable-5'>().toExtend<Keys>()
})
})

Expand Down Expand Up @@ -256,6 +292,12 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-3-haiku']
>().toHaveProperty('container')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-sonnet-5']
>().toHaveProperty('container')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-fable-5']
>().toHaveProperty('container')
})

it('all models should have context management options', () => {
Expand Down Expand Up @@ -289,6 +331,12 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-3-haiku']
>().toHaveProperty('context_management')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-sonnet-5']
>().toHaveProperty('context_management')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-fable-5']
>().toHaveProperty('context_management')
})

it('all models should have MCP options', () => {
Expand Down Expand Up @@ -322,6 +370,12 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-3-haiku']
>().toHaveProperty('mcp_servers')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-sonnet-5']
>().toHaveProperty('mcp_servers')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-fable-5']
>().toHaveProperty('mcp_servers')
})

it('all models should have stop sequences options', () => {
Expand Down Expand Up @@ -355,6 +409,12 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-3-haiku']
>().toHaveProperty('stop_sequences')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-sonnet-5']
>().toHaveProperty('stop_sequences')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-fable-5']
>().toHaveProperty('stop_sequences')
})

it('all models should have tool choice options', () => {
Expand Down Expand Up @@ -388,6 +448,12 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-3-haiku']
>().toHaveProperty('tool_choice')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-sonnet-5']
>().toHaveProperty('tool_choice')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-fable-5']
>().toHaveProperty('tool_choice')
})

it('all models should have sampling options (top_k)', () => {
Expand Down Expand Up @@ -421,6 +487,12 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-3-haiku']
>().toHaveProperty('top_k')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-sonnet-5']
>().toHaveProperty('top_k')
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-fable-5']
>().toHaveProperty('top_k')
})
})

Expand Down Expand Up @@ -450,6 +522,12 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-opus-4']
>().toExtend<AnthropicThinkingOptions>()
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-sonnet-5']
>().toExtend<AnthropicThinkingOptions>()
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-fable-5']
>().toExtend<AnthropicThinkingOptions>()
})

it('models without extended_thinking should NOT extend AnthropicThinkingOptions', () => {
Expand Down Expand Up @@ -489,6 +567,12 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-3-5-haiku']
>().toExtend<AnthropicServiceTierOptions>()
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-sonnet-5']
>().toExtend<AnthropicServiceTierOptions>()
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-fable-5']
>().toExtend<AnthropicServiceTierOptions>()
})

it('models without priority_tier should NOT extend AnthropicServiceTierOptions', () => {
Expand Down Expand Up @@ -528,6 +612,12 @@ describe('Anthropic Model Provider Options Type Assertions', () => {
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-3-haiku']
>().toExtend<BaseOptions>()
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-sonnet-5']
>().toExtend<BaseOptions>()
expectTypeOf<
AnthropicChatModelProviderOptionsByName['claude-fable-5']
>().toExtend<BaseOptions>()
})
})
})
Expand Down Expand Up @@ -779,4 +869,48 @@ describe('Anthropic Model Input Modality Type Assertions', () => {
>().not.toExtend<Message>()
})
})

describe('Claude Sonnet 5 (text + image + document)', () => {
type Modalities = AnthropicModelInputModalitiesByName['claude-sonnet-5']
type Message = ConstrainedModelMessage<MakeInputModalitiesTypes<Modalities>>

it('should allow TextPart, ImagePart, and DocumentPart', () => {
expectTypeOf<MessageWithContent<AnthropicTextPart>>().toExtend<Message>()
expectTypeOf<MessageWithContent<AnthropicImagePart>>().toExtend<Message>()
expectTypeOf<
MessageWithContent<AnthropicDocumentPart>
>().toExtend<Message>()
})

it('should NOT allow AudioPart or VideoPart', () => {
expectTypeOf<
MessageWithContent<AnthropicAudioPart>
>().not.toExtend<Message>()
expectTypeOf<
MessageWithContent<AnthropicVideoPart>
>().not.toExtend<Message>()
})
})

describe('Claude Fable 5 (text + image + document)', () => {
type Modalities = AnthropicModelInputModalitiesByName['claude-fable-5']
type Message = ConstrainedModelMessage<MakeInputModalitiesTypes<Modalities>>

it('should allow TextPart, ImagePart, and DocumentPart', () => {
expectTypeOf<MessageWithContent<AnthropicTextPart>>().toExtend<Message>()
expectTypeOf<MessageWithContent<AnthropicImagePart>>().toExtend<Message>()
expectTypeOf<
MessageWithContent<AnthropicDocumentPart>
>().toExtend<Message>()
})

it('should NOT allow AudioPart or VideoPart', () => {
expectTypeOf<
MessageWithContent<AnthropicAudioPart>
>().not.toExtend<Message>()
expectTypeOf<
MessageWithContent<AnthropicVideoPart>
>().not.toExtend<Message>()
})
})
})
Loading