@tanstack/ai-anthropic 0.4.1 → 0.4.2

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.
@@ -1,6 +1,7 @@
1
1
  export { AnthropicTextAdapter, anthropicText, createAnthropicChat, type AnthropicTextConfig, type AnthropicTextProviderOptions, } from './adapters/text.js';
2
2
  export { AnthropicSummarizeAdapter, anthropicSummarize, createAnthropicSummarize, type AnthropicSummarizeConfig, type AnthropicSummarizeProviderOptions, } from './adapters/summarize.js';
3
- export type { AnthropicChatModelProviderOptionsByName, AnthropicModelInputModalitiesByName, } from './model-meta.js';
3
+ export { ANTHROPIC_MODELS } from './model-meta.js';
4
+ export type { AnthropicChatModelProviderOptionsByName, AnthropicModelInputModalitiesByName, AnthropicChatModel, } from './model-meta.js';
4
5
  export type { AnthropicTextMetadata, AnthropicImageMetadata, AnthropicDocumentMetadata, AnthropicAudioMetadata, AnthropicVideoMetadata, AnthropicMessageMetadataByModality, } from './message-types.js';
5
6
  export { convertToolsToProviderFormat } from './tools/tool-converter.js';
6
7
  export type { AnthropicTool, CustomTool } from './tools.js';
package/dist/esm/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import { AnthropicTextAdapter, anthropicText, createAnthropicChat } from "./adapters/text.js";
2
2
  import { AnthropicSummarizeAdapter, anthropicSummarize, createAnthropicSummarize } from "./adapters/summarize.js";
3
+ import { ANTHROPIC_MODELS } from "./model-meta.js";
3
4
  import { convertToolsToProviderFormat } from "./tools/tool-converter.js";
4
5
  export {
6
+ ANTHROPIC_MODELS,
5
7
  AnthropicSummarizeAdapter,
6
8
  AnthropicTextAdapter,
7
9
  anthropicSummarize,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,4 +1,44 @@
1
1
  import { AnthropicContainerOptions, AnthropicContextManagementOptions, AnthropicMCPOptions, AnthropicSamplingOptions, AnthropicServiceTierOptions, AnthropicStopSequencesOptions, AnthropicThinkingOptions, AnthropicToolChoiceOptions } from './text/text-provider-options.js';
2
+ declare const CLAUDE_OPUS_4_6: {
3
+ readonly name: "claude-opus-4-6";
4
+ readonly id: "claude-opus-4-6";
5
+ readonly context_window: 200000;
6
+ readonly max_output_tokens: 128000;
7
+ readonly knowledge_cutoff: "2025-05-01";
8
+ readonly pricing: {
9
+ readonly input: {
10
+ readonly normal: 5;
11
+ };
12
+ readonly output: {
13
+ readonly normal: 25;
14
+ };
15
+ };
16
+ readonly supports: {
17
+ readonly input: ["text", "image", "document"];
18
+ readonly extended_thinking: true;
19
+ readonly priority_tier: true;
20
+ };
21
+ };
22
+ declare const CLAUDE_OPUS_4_5: {
23
+ readonly name: "claude-opus-4-5";
24
+ readonly id: "claude-opus-4-5";
25
+ readonly context_window: 200000;
26
+ readonly max_output_tokens: 32000;
27
+ readonly knowledge_cutoff: "2025-11-01";
28
+ readonly pricing: {
29
+ readonly input: {
30
+ readonly normal: 15;
31
+ };
32
+ readonly output: {
33
+ readonly normal: 75;
34
+ };
35
+ };
36
+ readonly supports: {
37
+ readonly input: ["text", "image", "document"];
38
+ readonly extended_thinking: true;
39
+ readonly priority_tier: true;
40
+ };
41
+ };
2
42
  declare const CLAUDE_SONNET_4_5: {
3
43
  readonly name: "claude-sonnet-4-5";
4
44
  readonly id: "claude-sonnet-4-5";
@@ -59,26 +99,6 @@ declare const CLAUDE_OPUS_4_1: {
59
99
  readonly priority_tier: true;
60
100
  };
61
101
  };
62
- declare const CLAUDE_OPUS_4_5: {
63
- readonly name: "claude-opus-4-5";
64
- readonly id: "claude-opus-4-5";
65
- readonly context_window: 200000;
66
- readonly max_output_tokens: 32000;
67
- readonly knowledge_cutoff: "2025-11-01";
68
- readonly pricing: {
69
- readonly input: {
70
- readonly normal: 15;
71
- };
72
- readonly output: {
73
- readonly normal: 75;
74
- };
75
- };
76
- readonly supports: {
77
- readonly input: ["text", "image", "document"];
78
- readonly extended_thinking: true;
79
- readonly priority_tier: true;
80
- };
81
- };
82
102
  declare const CLAUDE_SONNET_4: {
83
103
  readonly name: "claude-sonnet-4";
84
104
  readonly id: "claude-sonnet-4";
@@ -178,8 +198,10 @@ declare const CLAUDE_HAIKU_3: {
178
198
  readonly priority_tier: false;
179
199
  };
180
200
  };
181
- export declare const ANTHROPIC_MODELS: readonly ["claude-opus-4-5", "claude-sonnet-4-5", "claude-haiku-4-5", "claude-opus-4-1", "claude-sonnet-4", "claude-3-7-sonnet", "claude-opus-4", "claude-3-5-haiku", "claude-3-haiku"];
201
+ export declare const ANTHROPIC_MODELS: readonly ["claude-opus-4-6", "claude-opus-4-5", "claude-sonnet-4-5", "claude-haiku-4-5", "claude-opus-4-1", "claude-sonnet-4", "claude-3-7-sonnet", "claude-opus-4", "claude-3-5-haiku", "claude-3-haiku"];
202
+ export type AnthropicChatModel = (typeof ANTHROPIC_MODELS)[number];
182
203
  export type AnthropicChatModelProviderOptionsByName = {
204
+ [CLAUDE_OPUS_4_6.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
183
205
  [CLAUDE_OPUS_4_5.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
184
206
  [CLAUDE_SONNET_4_5.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
185
207
  [CLAUDE_HAIKU_4_5.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
@@ -202,6 +224,7 @@ export type AnthropicChatModelProviderOptionsByName = {
202
224
  * @see https://docs.anthropic.com/claude/docs/pdf-support
203
225
  */
204
226
  export type AnthropicModelInputModalitiesByName = {
227
+ [CLAUDE_OPUS_4_6.id]: typeof CLAUDE_OPUS_4_6.supports.input;
205
228
  [CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.input;
206
229
  [CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.input;
207
230
  [CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.input;
@@ -0,0 +1,46 @@
1
+ const CLAUDE_OPUS_4_6 = {
2
+ id: "claude-opus-4-6"
3
+ };
4
+ const CLAUDE_OPUS_4_5 = {
5
+ id: "claude-opus-4-5"
6
+ };
7
+ const CLAUDE_SONNET_4_5 = {
8
+ id: "claude-sonnet-4-5"
9
+ };
10
+ const CLAUDE_HAIKU_4_5 = {
11
+ id: "claude-haiku-4-5"
12
+ };
13
+ const CLAUDE_OPUS_4_1 = {
14
+ id: "claude-opus-4-1"
15
+ };
16
+ const CLAUDE_SONNET_4 = {
17
+ id: "claude-sonnet-4"
18
+ };
19
+ const CLAUDE_SONNET_3_7 = {
20
+ id: "claude-3-7-sonnet"
21
+ };
22
+ const CLAUDE_OPUS_4 = {
23
+ id: "claude-opus-4"
24
+ };
25
+ const CLAUDE_HAIKU_3_5 = {
26
+ id: "claude-3-5-haiku"
27
+ };
28
+ const CLAUDE_HAIKU_3 = {
29
+ id: "claude-3-haiku"
30
+ };
31
+ const ANTHROPIC_MODELS = [
32
+ CLAUDE_OPUS_4_6.id,
33
+ CLAUDE_OPUS_4_5.id,
34
+ CLAUDE_SONNET_4_5.id,
35
+ CLAUDE_HAIKU_4_5.id,
36
+ CLAUDE_OPUS_4_1.id,
37
+ CLAUDE_SONNET_4.id,
38
+ CLAUDE_SONNET_3_7.id,
39
+ CLAUDE_OPUS_4.id,
40
+ CLAUDE_HAIKU_3_5.id,
41
+ CLAUDE_HAIKU_3.id
42
+ ];
43
+ export {
44
+ ANTHROPIC_MODELS
45
+ };
46
+ //# sourceMappingURL=model-meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-meta.js","sources":["../../src/model-meta.ts"],"sourcesContent":["import type {\n AnthropicContainerOptions,\n AnthropicContextManagementOptions,\n AnthropicMCPOptions,\n AnthropicSamplingOptions,\n AnthropicServiceTierOptions,\n AnthropicStopSequencesOptions,\n AnthropicThinkingOptions,\n AnthropicToolChoiceOptions,\n} from './text/text-provider-options'\n\ninterface ModelMeta<\n TProviderOptions = unknown,\n TToolCapabilities = unknown,\n TMessageCapabilities = unknown,\n> {\n name: string\n id: string\n supports: {\n input: Array<'text' | 'image' | 'audio' | 'video' | 'document'>\n extended_thinking?: boolean\n priority_tier?: boolean\n }\n context_window?: number\n max_output_tokens?: number\n knowledge_cutoff?: string\n pricing: {\n input: {\n normal: number\n cached?: number\n }\n output: {\n normal: number\n }\n }\n /**\n * Type-level description of which provider options this model supports.\n */\n providerOptions?: TProviderOptions\n /**\n * Type-level description of which tool capabilities this model supports.\n */\n toolCapabilities?: TToolCapabilities\n /**\n * Type-level description of which message/input capabilities this model supports.\n */\n messageCapabilities?: TMessageCapabilities\n}\n\nconst CLAUDE_OPUS_4_6 = {\n name: 'claude-opus-4-6',\n id: 'claude-opus-4-6',\n context_window: 200_000,\n max_output_tokens: 128_000,\n knowledge_cutoff: '2025-05-01',\n pricing: {\n input: {\n normal: 5,\n },\n output: {\n normal: 25,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_4_5 = {\n name: 'claude-opus-4-5',\n id: 'claude-opus-4-5',\n context_window: 200_000,\n max_output_tokens: 32_000,\n knowledge_cutoff: '2025-11-01',\n pricing: {\n input: {\n normal: 15,\n },\n output: {\n normal: 75,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_SONNET_4_5 = {\n name: 'claude-sonnet-4-5',\n id: 'claude-sonnet-4-5',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-09-29',\n pricing: {\n input: {\n normal: 3,\n },\n output: {\n normal: 15,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_HAIKU_4_5 = {\n name: 'claude-haiku-4-5',\n id: 'claude-haiku-4-5',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-10-01',\n pricing: {\n input: {\n normal: 1,\n },\n output: {\n normal: 5,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_4_1 = {\n name: 'claude-opus-4-1',\n id: 'claude-opus-4-1',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-08-05',\n pricing: {\n input: {\n normal: 15,\n },\n output: {\n normal: 75,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_SONNET_4 = {\n name: 'claude-sonnet-4',\n id: 'claude-sonnet-4',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-05-14',\n pricing: {\n input: {\n normal: 3,\n },\n output: {\n normal: 15,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_SONNET_3_7 = {\n name: 'claude-sonnet-3-7',\n id: 'claude-3-7-sonnet',\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-05-14',\n pricing: {\n input: {\n normal: 3,\n },\n output: {\n normal: 15,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_4 = {\n name: 'claude-opus-4',\n id: 'claude-opus-4',\n context_window: 200_000,\n max_output_tokens: 32_000,\n knowledge_cutoff: '2025-05-14',\n pricing: {\n input: {\n normal: 15,\n },\n output: {\n normal: 75,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_HAIKU_3_5 = {\n name: 'claude-haiku-3-5',\n id: 'claude-3-5-haiku',\n context_window: 200_000,\n max_output_tokens: 8_000,\n knowledge_cutoff: '2025-10-22',\n pricing: {\n input: {\n normal: 0.8,\n },\n output: {\n normal: 4,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_HAIKU_3 = {\n name: 'claude-haiku-3',\n id: 'claude-3-haiku',\n context_window: 200_000,\n max_output_tokens: 4_000,\n knowledge_cutoff: '2024-03-07',\n pricing: {\n input: {\n normal: 0.25,\n },\n output: {\n normal: 1.25,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n priority_tier: false,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\n/* const ANTHROPIC_MODEL_META = {\n [CLAUDE_OPUS_4_5.name]: CLAUDE_OPUS_4_5,\n [CLAUDE_SONNET_4_5.name]: CLAUDE_SONNET_4_5,\n [CLAUDE_HAIKU_4_5.name]: CLAUDE_HAIKU_4_5,\n [CLAUDE_OPUS_4_1.name]: CLAUDE_OPUS_4_1,\n [CLAUDE_SONNET_4.name]: CLAUDE_SONNET_4,\n [CLAUDE_SONNET_3_7.name]: CLAUDE_SONNET_3_7,\n [CLAUDE_OPUS_4.name]: CLAUDE_OPUS_4,\n [CLAUDE_HAIKU_3_5.name]: CLAUDE_HAIKU_3_5,\n [CLAUDE_HAIKU_3.name]: CLAUDE_HAIKU_3,\n} as const */\n\n/* export type AnthropicModelProviderOptions<\n TModel extends keyof AnthropicModelMetaMap,\n> =\n AnthropicModelMetaMap[TModel] extends ModelMeta<\n infer TProviderOptions,\n any,\n any\n >\n ? TProviderOptions\n : unknown */\n\n/* export type AnthropicModelToolCapabilities<\n TModel extends keyof AnthropicModelMetaMap,\n> =\n AnthropicModelMetaMap[TModel] extends ModelMeta<\n any,\n infer TToolCapabilities,\n any\n >\n ? TToolCapabilities\n : unknown\n */\n/* export type AnthropicModelMessageCapabilities<\n TModel extends keyof AnthropicModelMetaMap,\n> =\n AnthropicModelMetaMap[TModel] extends ModelMeta<\n any,\n any,\n infer TMessageCapabilities\n >\n ? TMessageCapabilities\n : unknown */\n\nexport const ANTHROPIC_MODELS = [\n CLAUDE_OPUS_4_6.id,\n CLAUDE_OPUS_4_5.id,\n CLAUDE_SONNET_4_5.id,\n CLAUDE_HAIKU_4_5.id,\n CLAUDE_OPUS_4_1.id,\n CLAUDE_SONNET_4.id,\n CLAUDE_SONNET_3_7.id,\n CLAUDE_OPUS_4.id,\n CLAUDE_HAIKU_3_5.id,\n CLAUDE_HAIKU_3.id,\n] as const\n\n// const ANTHROPIC_IMAGE_MODELS = [] as const\n// const ANTHROPIC_EMBEDDING_MODELS = [] as const\n// const ANTHROPIC_AUDIO_MODELS = [] as const\n// const ANTHROPIC_VIDEO_MODELS = [] as const\n\n/* type AnthropicModel = (typeof ANTHROPIC_MODELS)[number] */\nexport type AnthropicChatModel = (typeof ANTHROPIC_MODELS)[number]\n// Manual type map for per-model provider options\n// Models are differentiated by extended_thinking and priority_tier support\nexport type AnthropicChatModelProviderOptionsByName = {\n // Models with both extended_thinking and priority_tier\n [CLAUDE_OPUS_4_6.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_OPUS_4_5.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_SONNET_4_5.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_HAIKU_4_5.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_OPUS_4_1.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_SONNET_4.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_SONNET_3_7.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_OPUS_4.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n\n // Model with priority_tier but NO extended_thinking\n [CLAUDE_HAIKU_3_5.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n\n // Model with neither extended_thinking nor priority_tier\n [CLAUDE_HAIKU_3.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicStopSequencesOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n}\n\n/**\n * Type-only map from chat model name to its supported input modalities.\n * All Anthropic Claude models support text, image, and document (PDF) input.\n * Used by the core AI types to constrain ContentPart types based on the selected model.\n * Note: These must be inlined as readonly arrays (not typeof) because the model\n * constants are not exported and typeof references don't work in .d.ts files\n * when consumed by external packages.\n *\n * @see https://docs.anthropic.com/claude/docs/vision\n * @see https://docs.anthropic.com/claude/docs/pdf-support\n */\nexport type AnthropicModelInputModalitiesByName = {\n [CLAUDE_OPUS_4_6.id]: typeof CLAUDE_OPUS_4_6.supports.input\n [CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.input\n [CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.input\n [CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.input\n [CLAUDE_OPUS_4_1.id]: typeof CLAUDE_OPUS_4_1.supports.input\n [CLAUDE_SONNET_4.id]: typeof CLAUDE_SONNET_4.supports.input\n [CLAUDE_SONNET_3_7.id]: typeof CLAUDE_SONNET_3_7.supports.input\n [CLAUDE_OPUS_4.id]: typeof CLAUDE_OPUS_4.supports.input\n [CLAUDE_HAIKU_3_5.id]: typeof CLAUDE_HAIKU_3_5.supports.input\n [CLAUDE_HAIKU_3.id]: typeof CLAUDE_HAIKU_3.supports.input\n}\n"],"names":[],"mappings":"AAiDA,MAAM,kBAAkB;AAAA,EAEtB,IAAI;AAiBN;AAWA,MAAM,kBAAkB;AAAA,EAEtB,IAAI;AAiBN;AAWA,MAAM,oBAAoB;AAAA,EAExB,IAAI;AAiBN;AAWA,MAAM,mBAAmB;AAAA,EAEvB,IAAI;AAiBN;AAWA,MAAM,kBAAkB;AAAA,EAEtB,IAAI;AAiBN;AAWA,MAAM,kBAAkB;AAAA,EAEtB,IAAI;AAiBN;AAWA,MAAM,oBAAoB;AAAA,EAExB,IAAI;AAgBN;AAWA,MAAM,gBAAgB;AAAA,EAEpB,IAAI;AAiBN;AAWA,MAAM,mBAAmB;AAAA,EAEvB,IAAI;AAiBN;AAWA,MAAM,iBAAiB;AAAA,EAErB,IAAI;AAiBN;AAwDO,MAAM,mBAAmB;AAAA,EAC9B,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,eAAe;AACjB;"}
@@ -1,5 +1,5 @@
1
- import { default as Anthropic_SDK } from '@anthropic-ai/sdk';
2
- export interface AnthropicClientConfig {
1
+ import { default as Anthropic_SDK, ClientOptions } from '@anthropic-ai/sdk';
2
+ export interface AnthropicClientConfig extends ClientOptions {
3
3
  apiKey: string;
4
4
  }
5
5
  /**
@@ -1,6 +1,7 @@
1
1
  import Anthropic_SDK from "@anthropic-ai/sdk";
2
2
  function createAnthropicClient(config) {
3
3
  return new Anthropic_SDK({
4
+ ...config,
4
5
  apiKey: config.apiKey
5
6
  });
6
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sources":["../../../src/utils/client.ts"],"sourcesContent":["import Anthropic_SDK from '@anthropic-ai/sdk'\n\nexport interface AnthropicClientConfig {\n apiKey: string\n}\n\n/**\n * Creates an Anthropic SDK client instance\n */\nexport function createAnthropicClient(\n config: AnthropicClientConfig,\n): Anthropic_SDK {\n return new Anthropic_SDK({\n apiKey: config.apiKey,\n })\n}\n\n/**\n * Gets Anthropic API key from environment variables\n * @throws Error if ANTHROPIC_API_KEY is not found\n */\nexport function getAnthropicApiKeyFromEnv(): string {\n const env =\n typeof globalThis !== 'undefined' && (globalThis as any).window?.env\n ? (globalThis as any).window.env\n : typeof process !== 'undefined'\n ? process.env\n : undefined\n const key = env?.ANTHROPIC_API_KEY\n\n if (!key) {\n throw new Error(\n 'ANTHROPIC_API_KEY is required. Please set it in your environment variables or use the factory function with an explicit API key.',\n )\n }\n\n return key\n}\n\n/**\n * Generates a unique ID with a prefix\n */\nexport function generateId(prefix: string): string {\n return `${prefix}-${Date.now()}-${Math.random().toString(36).substring(7)}`\n}\n"],"names":[],"mappings":";AASO,SAAS,sBACd,QACe;AACf,SAAO,IAAI,cAAc;AAAA,IACvB,QAAQ,OAAO;AAAA,EAAA,CAChB;AACH;AAMO,SAAS,4BAAoC;AAClD,QAAM,MACJ,OAAO,eAAe,eAAgB,WAAmB,QAAQ,MAC5D,WAAmB,OAAO,MAC3B,OAAO,YAAY,cACjB,QAAQ,MACR;AACR,QAAM,MAAM,KAAK;AAEjB,MAAI,CAAC,KAAK;AACR,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AAEA,SAAO;AACT;AAKO,SAAS,WAAW,QAAwB;AACjD,SAAO,GAAG,MAAM,IAAI,KAAK,KAAK,IAAI,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC;AAC3E;"}
1
+ {"version":3,"file":"client.js","sources":["../../../src/utils/client.ts"],"sourcesContent":["import Anthropic_SDK from '@anthropic-ai/sdk'\nimport type { ClientOptions } from '@anthropic-ai/sdk'\n\nexport interface AnthropicClientConfig extends ClientOptions {\n apiKey: string\n}\n\n/**\n * Creates an Anthropic SDK client instance\n */\nexport function createAnthropicClient(\n config: AnthropicClientConfig,\n): Anthropic_SDK {\n return new Anthropic_SDK({\n ...config,\n apiKey: config.apiKey,\n })\n}\n\n/**\n * Gets Anthropic API key from environment variables\n * @throws Error if ANTHROPIC_API_KEY is not found\n */\nexport function getAnthropicApiKeyFromEnv(): string {\n const env =\n typeof globalThis !== 'undefined' && (globalThis as any).window?.env\n ? (globalThis as any).window.env\n : typeof process !== 'undefined'\n ? process.env\n : undefined\n const key = env?.ANTHROPIC_API_KEY\n\n if (!key) {\n throw new Error(\n 'ANTHROPIC_API_KEY is required. Please set it in your environment variables or use the factory function with an explicit API key.',\n )\n }\n\n return key\n}\n\n/**\n * Generates a unique ID with a prefix\n */\nexport function generateId(prefix: string): string {\n return `${prefix}-${Date.now()}-${Math.random().toString(36).substring(7)}`\n}\n"],"names":[],"mappings":";AAUO,SAAS,sBACd,QACe;AACf,SAAO,IAAI,cAAc;AAAA,IACvB,GAAG;AAAA,IACH,QAAQ,OAAO;AAAA,EAAA,CAChB;AACH;AAMO,SAAS,4BAAoC;AAClD,QAAM,MACJ,OAAO,eAAe,eAAgB,WAAmB,QAAQ,MAC5D,WAAmB,OAAO,MAC3B,OAAO,YAAY,cACjB,QAAQ,MACR;AACR,QAAM,MAAM,KAAK;AAEjB,MAAI,CAAC,KAAK;AACR,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AAEA,SAAO;AACT;AAKO,SAAS,WAAW,QAAwB;AACjD,SAAO,GAAG,MAAM,IAAI,KAAK,KAAK,IAAI,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC;AAC3E;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai-anthropic",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Anthropic Claude adapter for TanStack AI",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -30,16 +30,16 @@
30
30
  "src"
31
31
  ],
32
32
  "dependencies": {
33
- "@anthropic-ai/sdk": "^0.71.0"
33
+ "@anthropic-ai/sdk": "^0.71.2"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "zod": "^4.0.0",
37
- "@tanstack/ai": "^0.4.1"
37
+ "@tanstack/ai": "^0.4.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@vitest/coverage-v8": "4.0.14",
41
41
  "zod": "^4.2.0",
42
- "@tanstack/ai": "0.4.1"
42
+ "@tanstack/ai": "0.4.2"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "vite build",
package/src/index.ts CHANGED
@@ -19,7 +19,7 @@ export {
19
19
  type AnthropicSummarizeConfig,
20
20
  type AnthropicSummarizeProviderOptions,
21
21
  } from './adapters/summarize'
22
-
22
+ export { ANTHROPIC_MODELS } from './model-meta'
23
23
  // ============================================================================
24
24
  // Type Exports
25
25
  // ============================================================================
@@ -27,6 +27,7 @@ export {
27
27
  export type {
28
28
  AnthropicChatModelProviderOptionsByName,
29
29
  AnthropicModelInputModalitiesByName,
30
+ AnthropicChatModel,
30
31
  } from './model-meta'
31
32
  export type {
32
33
  AnthropicTextMetadata,
package/src/model-meta.ts CHANGED
@@ -46,19 +46,50 @@ interface ModelMeta<
46
46
  */
47
47
  messageCapabilities?: TMessageCapabilities
48
48
  }
49
- const CLAUDE_SONNET_4_5 = {
50
- name: 'claude-sonnet-4-5',
51
- id: 'claude-sonnet-4-5',
49
+
50
+ const CLAUDE_OPUS_4_6 = {
51
+ name: 'claude-opus-4-6',
52
+ id: 'claude-opus-4-6',
52
53
  context_window: 200_000,
53
- max_output_tokens: 64_000,
54
- knowledge_cutoff: '2025-09-29',
54
+ max_output_tokens: 128_000,
55
+ knowledge_cutoff: '2025-05-01',
55
56
  pricing: {
56
57
  input: {
57
- normal: 3,
58
+ normal: 5,
58
59
  },
59
60
  output: {
61
+ normal: 25,
62
+ },
63
+ },
64
+ supports: {
65
+ input: ['text', 'image', 'document'],
66
+ extended_thinking: true,
67
+ priority_tier: true,
68
+ },
69
+ } as const satisfies ModelMeta<
70
+ AnthropicContainerOptions &
71
+ AnthropicContextManagementOptions &
72
+ AnthropicMCPOptions &
73
+ AnthropicServiceTierOptions &
74
+ AnthropicStopSequencesOptions &
75
+ AnthropicThinkingOptions &
76
+ AnthropicToolChoiceOptions &
77
+ AnthropicSamplingOptions
78
+ >
79
+
80
+ const CLAUDE_OPUS_4_5 = {
81
+ name: 'claude-opus-4-5',
82
+ id: 'claude-opus-4-5',
83
+ context_window: 200_000,
84
+ max_output_tokens: 32_000,
85
+ knowledge_cutoff: '2025-11-01',
86
+ pricing: {
87
+ input: {
60
88
  normal: 15,
61
89
  },
90
+ output: {
91
+ normal: 75,
92
+ },
62
93
  },
63
94
  supports: {
64
95
  input: ['text', 'image', 'document'],
@@ -76,18 +107,18 @@ const CLAUDE_SONNET_4_5 = {
76
107
  AnthropicSamplingOptions
77
108
  >
78
109
 
79
- const CLAUDE_HAIKU_4_5 = {
80
- name: 'claude-haiku-4-5',
81
- id: 'claude-haiku-4-5',
110
+ const CLAUDE_SONNET_4_5 = {
111
+ name: 'claude-sonnet-4-5',
112
+ id: 'claude-sonnet-4-5',
82
113
  context_window: 200_000,
83
114
  max_output_tokens: 64_000,
84
- knowledge_cutoff: '2025-10-01',
115
+ knowledge_cutoff: '2025-09-29',
85
116
  pricing: {
86
117
  input: {
87
- normal: 1,
118
+ normal: 3,
88
119
  },
89
120
  output: {
90
- normal: 5,
121
+ normal: 15,
91
122
  },
92
123
  },
93
124
  supports: {
@@ -106,18 +137,18 @@ const CLAUDE_HAIKU_4_5 = {
106
137
  AnthropicSamplingOptions
107
138
  >
108
139
 
109
- const CLAUDE_OPUS_4_1 = {
110
- name: 'claude-opus-4-1',
111
- id: 'claude-opus-4-1',
140
+ const CLAUDE_HAIKU_4_5 = {
141
+ name: 'claude-haiku-4-5',
142
+ id: 'claude-haiku-4-5',
112
143
  context_window: 200_000,
113
144
  max_output_tokens: 64_000,
114
- knowledge_cutoff: '2025-08-05',
145
+ knowledge_cutoff: '2025-10-01',
115
146
  pricing: {
116
147
  input: {
117
- normal: 15,
148
+ normal: 1,
118
149
  },
119
150
  output: {
120
- normal: 75,
151
+ normal: 5,
121
152
  },
122
153
  },
123
154
  supports: {
@@ -136,12 +167,12 @@ const CLAUDE_OPUS_4_1 = {
136
167
  AnthropicSamplingOptions
137
168
  >
138
169
 
139
- const CLAUDE_OPUS_4_5 = {
140
- name: 'claude-opus-4-5',
141
- id: 'claude-opus-4-5',
170
+ const CLAUDE_OPUS_4_1 = {
171
+ name: 'claude-opus-4-1',
172
+ id: 'claude-opus-4-1',
142
173
  context_window: 200_000,
143
- max_output_tokens: 32_000,
144
- knowledge_cutoff: '2025-11-01',
174
+ max_output_tokens: 64_000,
175
+ knowledge_cutoff: '2025-08-05',
145
176
  pricing: {
146
177
  input: {
147
178
  normal: 15,
@@ -361,6 +392,7 @@ const CLAUDE_HAIKU_3 = {
361
392
  : unknown */
362
393
 
363
394
  export const ANTHROPIC_MODELS = [
395
+ CLAUDE_OPUS_4_6.id,
364
396
  CLAUDE_OPUS_4_5.id,
365
397
  CLAUDE_SONNET_4_5.id,
366
398
  CLAUDE_HAIKU_4_5.id,
@@ -378,11 +410,19 @@ export const ANTHROPIC_MODELS = [
378
410
  // const ANTHROPIC_VIDEO_MODELS = [] as const
379
411
 
380
412
  /* type AnthropicModel = (typeof ANTHROPIC_MODELS)[number] */
381
-
413
+ export type AnthropicChatModel = (typeof ANTHROPIC_MODELS)[number]
382
414
  // Manual type map for per-model provider options
383
415
  // Models are differentiated by extended_thinking and priority_tier support
384
416
  export type AnthropicChatModelProviderOptionsByName = {
385
417
  // Models with both extended_thinking and priority_tier
418
+ [CLAUDE_OPUS_4_6.id]: AnthropicContainerOptions &
419
+ AnthropicContextManagementOptions &
420
+ AnthropicMCPOptions &
421
+ AnthropicServiceTierOptions &
422
+ AnthropicStopSequencesOptions &
423
+ AnthropicThinkingOptions &
424
+ AnthropicToolChoiceOptions &
425
+ AnthropicSamplingOptions
386
426
  [CLAUDE_OPUS_4_5.id]: AnthropicContainerOptions &
387
427
  AnthropicContextManagementOptions &
388
428
  AnthropicMCPOptions &
@@ -470,6 +510,7 @@ export type AnthropicChatModelProviderOptionsByName = {
470
510
  * @see https://docs.anthropic.com/claude/docs/pdf-support
471
511
  */
472
512
  export type AnthropicModelInputModalitiesByName = {
513
+ [CLAUDE_OPUS_4_6.id]: typeof CLAUDE_OPUS_4_6.supports.input
473
514
  [CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.input
474
515
  [CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.input
475
516
  [CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.input
@@ -1,6 +1,7 @@
1
1
  import Anthropic_SDK from '@anthropic-ai/sdk'
2
+ import type { ClientOptions } from '@anthropic-ai/sdk'
2
3
 
3
- export interface AnthropicClientConfig {
4
+ export interface AnthropicClientConfig extends ClientOptions {
4
5
  apiKey: string
5
6
  }
6
7
 
@@ -11,6 +12,7 @@ export function createAnthropicClient(
11
12
  config: AnthropicClientConfig,
12
13
  ): Anthropic_SDK {
13
14
  return new Anthropic_SDK({
15
+ ...config,
14
16
  apiKey: config.apiKey,
15
17
  })
16
18
  }