@ai-sdk/anthropic 4.0.0-beta.3 → 4.0.0-beta.32

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,13 +1,13 @@
1
- import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, JSONSchema7, SharedV4ProviderMetadata, SharedV4Warning } from '@ai-sdk/provider';
1
+ import { LanguageModelV4, JSONObject, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, JSONSchema7, SharedV4ProviderMetadata, SharedV4Warning } from '@ai-sdk/provider';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
- import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
- type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | (string & {});
5
+ type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | (string & {});
6
6
 
7
7
  type AnthropicMessagesConfig = {
8
8
  provider: string;
9
9
  baseURL: string;
10
- headers: Resolvable<Record<string, string | undefined>>;
10
+ headers?: Resolvable<Record<string, string | undefined>>;
11
11
  fetch?: FetchFunction;
12
12
  buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
13
13
  transformRequestBody?: (args: Record<string, any>, betas: Set<string>) => Record<string, any>;
@@ -17,12 +17,25 @@ type AnthropicMessagesConfig = {
17
17
  * When false, the model will use JSON tool fallback for structured outputs.
18
18
  */
19
19
  supportsNativeStructuredOutput?: boolean;
20
+ /**
21
+ * When false, `strict` on tool definitions will be ignored and a warning emitted.
22
+ * Defaults to true.
23
+ */
24
+ supportsStrictTools?: boolean;
20
25
  };
21
26
  declare class AnthropicMessagesLanguageModel implements LanguageModelV4 {
22
27
  readonly specificationVersion = "v4";
23
28
  readonly modelId: AnthropicMessagesModelId;
24
29
  private readonly config;
25
30
  private readonly generateId;
31
+ static [WORKFLOW_SERIALIZE](model: AnthropicMessagesLanguageModel): {
32
+ modelId: string;
33
+ config: JSONObject;
34
+ };
35
+ static [WORKFLOW_DESERIALIZE](options: {
36
+ modelId: AnthropicMessagesModelId;
37
+ config: AnthropicMessagesConfig;
38
+ }): AnthropicMessagesLanguageModel;
26
39
  constructor(modelId: AnthropicMessagesModelId, config: AnthropicMessagesConfig);
27
40
  supportsUrl(url: URL): boolean;
28
41
  get provider(): string;
@@ -41,6 +54,20 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV4 {
41
54
  doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
42
55
  doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
43
56
  }
57
+ /**
58
+ * Returns the capabilities of a Claude model that are used for defaults and feature selection.
59
+ *
60
+ * @see https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
61
+ * @see https://platform.claude.com/docs/en/build-with-claude/structured-outputs
62
+ */
63
+ declare function getModelCapabilities(modelId: string): {
64
+ maxOutputTokens: number;
65
+ supportsStructuredOutput: boolean;
66
+ supportsAdaptiveThinking: boolean;
67
+ rejectsSamplingParameters: boolean;
68
+ supportsXhighEffort: boolean;
69
+ isKnownModel: boolean;
70
+ };
44
71
 
45
72
  declare const anthropicTools: {
46
73
  /**
@@ -52,7 +79,7 @@ declare const anthropicTools: {
52
79
  bash_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
53
80
  command: string;
54
81
  restart?: boolean;
55
- }, {}>;
82
+ }, {}, {}>;
56
83
  /**
57
84
  * The bash tool enables Claude to execute shell commands in a persistent bash session,
58
85
  * allowing system operations, script execution, and command-line automation.
@@ -62,7 +89,7 @@ declare const anthropicTools: {
62
89
  bash_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{
63
90
  command: string;
64
91
  restart?: boolean;
65
- }, {}>;
92
+ }, {}, {}>;
66
93
  /**
67
94
  * Claude can analyze data, create visualizations, perform complex calculations,
68
95
  * run system commands, create and edit files, and process uploaded files directly within
@@ -82,7 +109,7 @@ declare const anthropicTools: {
82
109
  type: "code_execution_output";
83
110
  file_id: string;
84
111
  }>;
85
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
112
+ }, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
86
113
  code: string;
87
114
  }, {
88
115
  type: "code_execution_result";
@@ -93,7 +120,7 @@ declare const anthropicTools: {
93
120
  type: "code_execution_output";
94
121
  file_id: string;
95
122
  }>;
96
- }>;
123
+ }, {}>;
97
124
  /**
98
125
  * Claude can analyze data, create visualizations, perform complex calculations,
99
126
  * run system commands, create and edit files, and process uploaded files directly within
@@ -166,7 +193,7 @@ declare const anthropicTools: {
166
193
  new_start: number | null;
167
194
  old_lines: number | null;
168
195
  old_start: number | null;
169
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
196
+ }, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
170
197
  type: "programmatic-tool-call";
171
198
  code: string;
172
199
  } | {
@@ -228,7 +255,7 @@ declare const anthropicTools: {
228
255
  new_start: number | null;
229
256
  old_lines: number | null;
230
257
  old_start: number | null;
231
- }>;
258
+ }, {}>;
232
259
  /**
233
260
  * Claude can analyze data, create visualizations, perform complex calculations,
234
261
  * run system commands, create and edit files, and process uploaded files directly within
@@ -312,7 +339,7 @@ declare const anthropicTools: {
312
339
  new_start: number | null;
313
340
  old_lines: number | null;
314
341
  old_start: number | null;
315
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
342
+ }, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
316
343
  type: "programmatic-tool-call";
317
344
  code: string;
318
345
  } | {
@@ -383,7 +410,7 @@ declare const anthropicTools: {
383
410
  new_start: number | null;
384
411
  old_lines: number | null;
385
412
  old_start: number | null;
386
- }>;
413
+ }, {}>;
387
414
  /**
388
415
  * Claude can interact with computer environments through the computer use tool, which
389
416
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -402,7 +429,7 @@ declare const anthropicTools: {
402
429
  displayWidthPx: number;
403
430
  displayHeightPx: number;
404
431
  displayNumber?: number;
405
- }>;
432
+ }, {}>;
406
433
  /**
407
434
  * Claude can interact with computer environments through the computer use tool, which
408
435
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -425,7 +452,7 @@ declare const anthropicTools: {
425
452
  displayWidthPx: number;
426
453
  displayHeightPx: number;
427
454
  displayNumber?: number;
428
- }>;
455
+ }, {}>;
429
456
  /**
430
457
  * Claude can interact with computer environments through the computer use tool, which
431
458
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -455,7 +482,7 @@ declare const anthropicTools: {
455
482
  displayHeightPx: number;
456
483
  displayNumber?: number;
457
484
  enableZoom?: boolean;
458
- }>;
485
+ }, {}>;
459
486
  /**
460
487
  * The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
461
488
  * Claude can create, read, update, and delete files that persist between sessions,
@@ -489,7 +516,7 @@ declare const anthropicTools: {
489
516
  command: "rename";
490
517
  old_path: string;
491
518
  new_path: string;
492
- }, {}>;
519
+ }, {}, {}>;
493
520
  /**
494
521
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
495
522
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -506,7 +533,7 @@ declare const anthropicTools: {
506
533
  insert_text?: string;
507
534
  old_str?: string;
508
535
  view_range?: number[];
509
- }, {}>;
536
+ }, {}, {}>;
510
537
  /**
511
538
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
512
539
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -523,7 +550,7 @@ declare const anthropicTools: {
523
550
  insert_text?: string;
524
551
  old_str?: string;
525
552
  view_range?: number[];
526
- }, {}>;
553
+ }, {}, {}>;
527
554
  /**
528
555
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
529
556
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -542,7 +569,7 @@ declare const anthropicTools: {
542
569
  insert_text?: string;
543
570
  old_str?: string;
544
571
  view_range?: number[];
545
- }, {}>;
572
+ }, {}, {}>;
546
573
  /**
547
574
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
548
575
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -565,7 +592,7 @@ declare const anthropicTools: {
565
592
  view_range?: number[];
566
593
  }, {
567
594
  maxCharacters?: number;
568
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
595
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
569
596
  command: "view" | "create" | "str_replace" | "insert";
570
597
  path: string;
571
598
  file_text?: string;
@@ -574,7 +601,7 @@ declare const anthropicTools: {
574
601
  insert_text?: string;
575
602
  old_str?: string;
576
603
  view_range?: number[];
577
- }, unknown>;
604
+ }, unknown, {}>;
578
605
  /**
579
606
  * Creates a web fetch tool that gives Claude direct access to real-time web content.
580
607
  *
@@ -614,7 +641,7 @@ declare const anthropicTools: {
614
641
  enabled: boolean;
615
642
  };
616
643
  maxContentTokens?: number;
617
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
644
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
618
645
  url: string;
619
646
  }, {
620
647
  type: "web_fetch_result";
@@ -636,7 +663,7 @@ declare const anthropicTools: {
636
663
  };
637
664
  };
638
665
  retrievedAt: string | null;
639
- }>;
666
+ }, {}>;
640
667
  /**
641
668
  * Creates a web fetch tool that gives Claude direct access to real-time web content.
642
669
  *
@@ -676,7 +703,7 @@ declare const anthropicTools: {
676
703
  enabled: boolean;
677
704
  };
678
705
  maxContentTokens?: number;
679
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
706
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
680
707
  url: string;
681
708
  }, {
682
709
  type: "web_fetch_result";
@@ -698,7 +725,7 @@ declare const anthropicTools: {
698
725
  };
699
726
  };
700
727
  retrievedAt: string | null;
701
- }>;
728
+ }, {}>;
702
729
  /**
703
730
  * Creates a web search tool that gives Claude direct access to real-time web content.
704
731
  *
@@ -726,7 +753,7 @@ declare const anthropicTools: {
726
753
  country?: string;
727
754
  timezone?: string;
728
755
  };
729
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
756
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
730
757
  query: string;
731
758
  }, {
732
759
  type: "web_search_result";
@@ -734,7 +761,7 @@ declare const anthropicTools: {
734
761
  title: string | null;
735
762
  pageAge: string | null;
736
763
  encryptedContent: string;
737
- }[]>;
764
+ }[], {}>;
738
765
  /**
739
766
  * Creates a web search tool that gives Claude direct access to real-time web content.
740
767
  *
@@ -762,7 +789,7 @@ declare const anthropicTools: {
762
789
  country?: string;
763
790
  timezone?: string;
764
791
  };
765
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
792
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
766
793
  query: string;
767
794
  }, {
768
795
  type: "web_search_result";
@@ -770,7 +797,7 @@ declare const anthropicTools: {
770
797
  title: string | null;
771
798
  pageAge: string | null;
772
799
  encryptedContent: string;
773
- }[]>;
800
+ }[], {}>;
774
801
  /**
775
802
  * Creates a tool search tool that uses regex patterns to find tools.
776
803
  *
@@ -790,13 +817,13 @@ declare const anthropicTools: {
790
817
  }, {
791
818
  type: "tool_reference";
792
819
  toolName: string;
793
- }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
820
+ }[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
794
821
  pattern: string;
795
822
  limit?: number;
796
823
  }, {
797
824
  type: "tool_reference";
798
825
  toolName: string;
799
- }[]>;
826
+ }[], {}>;
800
827
  /**
801
828
  * Creates a tool search tool that uses BM25 (natural language) to find tools.
802
829
  *
@@ -816,13 +843,13 @@ declare const anthropicTools: {
816
843
  }, {
817
844
  type: "tool_reference";
818
845
  toolName: string;
819
- }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
846
+ }[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
820
847
  query: string;
821
848
  limit?: number;
822
849
  }, {
823
850
  type: "tool_reference";
824
851
  toolName: string;
825
- }[]>;
852
+ }[], {}>;
826
853
  };
827
854
 
828
855
  type AnthropicCacheControl = {
@@ -941,15 +968,24 @@ declare class CacheControlValidator {
941
968
  getWarnings(): SharedV4Warning[];
942
969
  }
943
970
 
944
- declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, }: {
971
+ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming, }: {
945
972
  tools: LanguageModelV4CallOptions['tools'];
946
973
  toolChoice: LanguageModelV4CallOptions['toolChoice'] | undefined;
947
974
  disableParallelToolUse?: boolean;
948
975
  cacheControlValidator?: CacheControlValidator;
949
976
  /**
950
- * Whether the model supports structured output.
977
+ * Whether the model supports native structured output response format.
951
978
  */
952
979
  supportsStructuredOutput: boolean;
980
+ /**
981
+ * Whether the model supports strict mode on tool definitions.
982
+ */
983
+ supportsStrictTools: boolean;
984
+ /**
985
+ * Default for `eager_input_streaming` on function tools that do not set
986
+ * it explicitly. Driven by the model-level `toolStreaming` option.
987
+ */
988
+ defaultEagerInputStreaming?: boolean;
953
989
  }): Promise<{
954
990
  tools: Array<AnthropicTool> | undefined;
955
991
  toolChoice: AnthropicToolChoice | undefined;
@@ -957,4 +993,4 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
957
993
  betas: Set<string>;
958
994
  }>;
959
995
 
960
- export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools };
996
+ export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, getModelCapabilities, prepareTools };