@fairyhunter13/ai-anthropic 3.0.58-fork.3 → 3.0.58-fork.30

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,140 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.0-beta.17
4
+
5
+ ### Patch Changes
6
+
7
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
8
+ - Updated dependencies [c29a26f]
9
+ - @ai-sdk/provider-utils@5.0.0-beta.10
10
+ - @ai-sdk/provider@4.0.0-beta.6
11
+
12
+ ## 4.0.0-beta.16
13
+
14
+ ### Patch Changes
15
+
16
+ - 38fc777: Add AI Gateway hint to provider READMEs
17
+
18
+ ## 4.0.0-beta.15
19
+
20
+ ### Patch Changes
21
+
22
+ - f57c702: fix(anthropic): allow both temperature and topP for non-Anthropic models using the Anthropic-compatible API
23
+
24
+ The temperature/topP mutual exclusivity check now only applies to known Anthropic models (model IDs starting with `claude-`). Non-Anthropic models using the Anthropic-compatible API (e.g. Minimax) can now send both parameters as required by their APIs.
25
+
26
+ ## 4.0.0-beta.14
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [2e17091]
31
+ - @ai-sdk/provider-utils@5.0.0-beta.9
32
+
33
+ ## 4.0.0-beta.13
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [986c6fd]
38
+ - Updated dependencies [493295c]
39
+ - @ai-sdk/provider-utils@5.0.0-beta.8
40
+
41
+ ## 4.0.0-beta.12
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies [1f509d4]
46
+ - @ai-sdk/provider-utils@5.0.0-beta.7
47
+ - @ai-sdk/provider@4.0.0-beta.5
48
+
49
+ ## 4.0.0-beta.11
50
+
51
+ ### Patch Changes
52
+
53
+ - 0ee8aec: feat (provider/anthropic): support passing metadata.user_id
54
+
55
+ ## 4.0.0-beta.10
56
+
57
+ ### Patch Changes
58
+
59
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
60
+ - Updated dependencies [3887c70]
61
+ - @ai-sdk/provider-utils@5.0.0-beta.6
62
+ - @ai-sdk/provider@4.0.0-beta.4
63
+
64
+ ## 4.0.0-beta.9
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [776b617]
69
+ - @ai-sdk/provider-utils@5.0.0-beta.5
70
+ - @ai-sdk/provider@4.0.0-beta.3
71
+
72
+ ## 4.0.0-beta.8
73
+
74
+ ### Patch Changes
75
+
76
+ - Updated dependencies [61753c3]
77
+ - @ai-sdk/provider-utils@5.0.0-beta.4
78
+
79
+ ## 4.0.0-beta.7
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies [f7d4f01]
84
+ - @ai-sdk/provider-utils@5.0.0-beta.3
85
+ - @ai-sdk/provider@4.0.0-beta.2
86
+
87
+ ## 4.0.0-beta.6
88
+
89
+ ### Patch Changes
90
+
91
+ - 21d1ee3: fix(anthropic): skip passing beta header for tool search tools
92
+
93
+ ## 4.0.0-beta.5
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies [5c2a5a2]
98
+ - @ai-sdk/provider@4.0.0-beta.1
99
+ - @ai-sdk/provider-utils@5.0.0-beta.2
100
+
101
+ ## 4.0.0-beta.4
102
+
103
+ ### Patch Changes
104
+
105
+ - f05a40d: fix(vertex): throw warning when strict: true for vertexAnthropic
106
+
107
+ ## 4.0.0-beta.3
108
+
109
+ ### Patch Changes
110
+
111
+ - e748b35: chore: update v3 specs to v4
112
+
113
+ ## 4.0.0-beta.2
114
+
115
+ ### Patch Changes
116
+
117
+ - 1fe058b: fix(anthropic): preserve the error code returned by model
118
+
119
+ ## 4.0.0-beta.1
120
+
121
+ ### Patch Changes
122
+
123
+ - Updated dependencies [531251e]
124
+ - @ai-sdk/provider-utils@5.0.0-beta.1
125
+
126
+ ## 4.0.0-beta.0
127
+
128
+ ### Major Changes
129
+
130
+ - 8359612: Start v7 pre-release
131
+
132
+ ### Patch Changes
133
+
134
+ - Updated dependencies [8359612]
135
+ - @ai-sdk/provider@4.0.0-beta.0
136
+ - @ai-sdk/provider-utils@5.0.0-beta.0
137
+
3
138
  ## 3.0.58
4
139
 
5
140
  ### Patch Changes
@@ -415,13 +550,13 @@
415
550
  Before
416
551
 
417
552
  ```ts
418
- model.textEmbeddingModel('my-model-id');
553
+ model.textEmbeddingModel("my-model-id");
419
554
  ```
420
555
 
421
556
  After
422
557
 
423
558
  ```ts
424
- model.embeddingModel('my-model-id');
559
+ model.embeddingModel("my-model-id");
425
560
  ```
426
561
 
427
562
  - f33a018: chore: add model ID for Haiku 4.5
@@ -761,13 +896,13 @@
761
896
  Before
762
897
 
763
898
  ```ts
764
- model.textEmbeddingModel('my-model-id');
899
+ model.textEmbeddingModel("my-model-id");
765
900
  ```
766
901
 
767
902
  After
768
903
 
769
904
  ```ts
770
- model.embeddingModel('my-model-id');
905
+ model.embeddingModel("my-model-id");
771
906
  ```
772
907
 
773
908
  - Updated dependencies [8d9e8ad]
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  The **[Anthropic provider](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Anthropic Messages API](https://docs.anthropic.com/claude/reference/messages_post).
4
4
 
5
+ > **Deploying to Vercel?** With Vercel's AI Gateway you can access Anthropic (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
6
+
5
7
  ## Setup
6
8
 
7
9
  The Anthropic provider is available in the `@ai-sdk/anthropic` module. You can install it with
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { JSONObject, ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
1
+ import { JSONObject, ProviderV4, LanguageModelV4, FilesV4 } from '@ai-sdk/provider';
2
2
  import { z } from 'zod/v4';
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
@@ -157,6 +157,9 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
157
157
  type: z.ZodLiteral<"ephemeral">;
158
158
  ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
159
159
  }, z.core.$strip>>;
160
+ metadata: z.ZodOptional<z.ZodObject<{
161
+ userId: z.ZodOptional<z.ZodString>;
162
+ }, z.core.$strip>>;
160
163
  mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
161
164
  type: z.ZodLiteral<"url">;
162
165
  name: z.ZodString;
@@ -188,6 +191,9 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
188
191
  }>>;
189
192
  anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
190
193
  prefill: z.ZodOptional<z.ZodString>;
194
+ serviceTier: z.ZodOptional<z.ZodEnum<{
195
+ auto: "auto";
196
+ }>>;
191
197
  contextManagement: z.ZodOptional<z.ZodObject<{
192
198
  edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
193
199
  type: z.ZodLiteral<"clear_tool_uses_20250919">;
@@ -243,7 +249,7 @@ declare const anthropicTools: {
243
249
  bash_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
244
250
  command: string;
245
251
  restart?: boolean;
246
- }, {}>;
252
+ }, {}, {}>;
247
253
  /**
248
254
  * The bash tool enables Claude to execute shell commands in a persistent bash session,
249
255
  * allowing system operations, script execution, and command-line automation.
@@ -253,7 +259,7 @@ declare const anthropicTools: {
253
259
  bash_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{
254
260
  command: string;
255
261
  restart?: boolean;
256
- }, {}>;
262
+ }, {}, {}>;
257
263
  /**
258
264
  * Claude can analyze data, create visualizations, perform complex calculations,
259
265
  * run system commands, create and edit files, and process uploaded files directly within
@@ -273,7 +279,7 @@ declare const anthropicTools: {
273
279
  type: "code_execution_output";
274
280
  file_id: string;
275
281
  }>;
276
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
282
+ }, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
277
283
  code: string;
278
284
  }, {
279
285
  type: "code_execution_result";
@@ -284,7 +290,7 @@ declare const anthropicTools: {
284
290
  type: "code_execution_output";
285
291
  file_id: string;
286
292
  }>;
287
- }>;
293
+ }, {}>;
288
294
  /**
289
295
  * Claude can analyze data, create visualizations, perform complex calculations,
290
296
  * run system commands, create and edit files, and process uploaded files directly within
@@ -357,7 +363,7 @@ declare const anthropicTools: {
357
363
  new_start: number | null;
358
364
  old_lines: number | null;
359
365
  old_start: number | null;
360
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
366
+ }, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
361
367
  type: "programmatic-tool-call";
362
368
  code: string;
363
369
  } | {
@@ -419,7 +425,7 @@ declare const anthropicTools: {
419
425
  new_start: number | null;
420
426
  old_lines: number | null;
421
427
  old_start: number | null;
422
- }>;
428
+ }, {}>;
423
429
  /**
424
430
  * Claude can analyze data, create visualizations, perform complex calculations,
425
431
  * run system commands, create and edit files, and process uploaded files directly within
@@ -503,7 +509,7 @@ declare const anthropicTools: {
503
509
  new_start: number | null;
504
510
  old_lines: number | null;
505
511
  old_start: number | null;
506
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
512
+ }, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
507
513
  type: "programmatic-tool-call";
508
514
  code: string;
509
515
  } | {
@@ -574,7 +580,7 @@ declare const anthropicTools: {
574
580
  new_start: number | null;
575
581
  old_lines: number | null;
576
582
  old_start: number | null;
577
- }>;
583
+ }, {}>;
578
584
  /**
579
585
  * Claude can interact with computer environments through the computer use tool, which
580
586
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -593,7 +599,7 @@ declare const anthropicTools: {
593
599
  displayWidthPx: number;
594
600
  displayHeightPx: number;
595
601
  displayNumber?: number;
596
- }>;
602
+ }, {}>;
597
603
  /**
598
604
  * Claude can interact with computer environments through the computer use tool, which
599
605
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -616,7 +622,7 @@ declare const anthropicTools: {
616
622
  displayWidthPx: number;
617
623
  displayHeightPx: number;
618
624
  displayNumber?: number;
619
- }>;
625
+ }, {}>;
620
626
  /**
621
627
  * Claude can interact with computer environments through the computer use tool, which
622
628
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -646,7 +652,7 @@ declare const anthropicTools: {
646
652
  displayHeightPx: number;
647
653
  displayNumber?: number;
648
654
  enableZoom?: boolean;
649
- }>;
655
+ }, {}>;
650
656
  /**
651
657
  * The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
652
658
  * Claude can create, read, update, and delete files that persist between sessions,
@@ -680,7 +686,7 @@ declare const anthropicTools: {
680
686
  command: "rename";
681
687
  old_path: string;
682
688
  new_path: string;
683
- }, {}>;
689
+ }, {}, {}>;
684
690
  /**
685
691
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
686
692
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -697,7 +703,7 @@ declare const anthropicTools: {
697
703
  insert_text?: string;
698
704
  old_str?: string;
699
705
  view_range?: number[];
700
- }, {}>;
706
+ }, {}, {}>;
701
707
  /**
702
708
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
703
709
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -714,7 +720,7 @@ declare const anthropicTools: {
714
720
  insert_text?: string;
715
721
  old_str?: string;
716
722
  view_range?: number[];
717
- }, {}>;
723
+ }, {}, {}>;
718
724
  /**
719
725
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
720
726
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -733,7 +739,7 @@ declare const anthropicTools: {
733
739
  insert_text?: string;
734
740
  old_str?: string;
735
741
  view_range?: number[];
736
- }, {}>;
742
+ }, {}, {}>;
737
743
  /**
738
744
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
739
745
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -756,7 +762,7 @@ declare const anthropicTools: {
756
762
  view_range?: number[];
757
763
  }, {
758
764
  maxCharacters?: number;
759
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
765
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
760
766
  command: "view" | "create" | "str_replace" | "insert";
761
767
  path: string;
762
768
  file_text?: string;
@@ -765,7 +771,7 @@ declare const anthropicTools: {
765
771
  insert_text?: string;
766
772
  old_str?: string;
767
773
  view_range?: number[];
768
- }, unknown>;
774
+ }, unknown, {}>;
769
775
  /**
770
776
  * Creates a web fetch tool that gives Claude direct access to real-time web content.
771
777
  *
@@ -805,7 +811,7 @@ declare const anthropicTools: {
805
811
  enabled: boolean;
806
812
  };
807
813
  maxContentTokens?: number;
808
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
814
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
809
815
  url: string;
810
816
  }, {
811
817
  type: "web_fetch_result";
@@ -827,7 +833,7 @@ declare const anthropicTools: {
827
833
  };
828
834
  };
829
835
  retrievedAt: string | null;
830
- }>;
836
+ }, {}>;
831
837
  /**
832
838
  * Creates a web fetch tool that gives Claude direct access to real-time web content.
833
839
  *
@@ -867,7 +873,7 @@ declare const anthropicTools: {
867
873
  enabled: boolean;
868
874
  };
869
875
  maxContentTokens?: number;
870
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
876
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
871
877
  url: string;
872
878
  }, {
873
879
  type: "web_fetch_result";
@@ -889,7 +895,79 @@ declare const anthropicTools: {
889
895
  };
890
896
  };
891
897
  retrievedAt: string | null;
892
- }>;
898
+ }, {}>;
899
+ /**
900
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
901
+ * GA version (no beta header required). Includes caller restrictions, cache control,
902
+ * deferred loading, and strict mode.
903
+ *
904
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
905
+ * @param allowedDomains - Only fetch from these domains
906
+ * @param blockedDomains - Never fetch from these domains
907
+ * @param citations - Citations configuration for fetched documents
908
+ * @param maxContentTokens - Max content tokens included in context
909
+ * @param allowedCallers - Restrict callers (e.g. ["direct"] to prevent code_execution usage)
910
+ * @param useCache - Whether to use cached content (set false for fresh content)
911
+ * @param deferLoading - Defer loading until tool_search discovers it
912
+ * @param strict - Enable strict schema validation
913
+ */
914
+ webFetch_20260309: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
915
+ url: string;
916
+ }, {
917
+ type: "web_fetch_result";
918
+ url: string;
919
+ content: {
920
+ type: "document";
921
+ title: string | null;
922
+ citations?: {
923
+ enabled: boolean;
924
+ };
925
+ source: {
926
+ type: "base64";
927
+ mediaType: "application/pdf";
928
+ data: string;
929
+ } | {
930
+ type: "text";
931
+ mediaType: "text/plain";
932
+ data: string;
933
+ };
934
+ };
935
+ retrievedAt: string | null;
936
+ }, {
937
+ maxUses?: number;
938
+ allowedDomains?: string[];
939
+ blockedDomains?: string[];
940
+ citations?: {
941
+ enabled: boolean;
942
+ };
943
+ maxContentTokens?: number;
944
+ allowedCallers?: Array<"direct" | "code_execution_20250825" | "code_execution_20260120">;
945
+ useCache?: boolean;
946
+ deferLoading?: boolean;
947
+ strict?: boolean;
948
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
949
+ url: string;
950
+ }, {
951
+ type: "web_fetch_result";
952
+ url: string;
953
+ content: {
954
+ type: "document";
955
+ title: string | null;
956
+ citations?: {
957
+ enabled: boolean;
958
+ };
959
+ source: {
960
+ type: "base64";
961
+ mediaType: "application/pdf";
962
+ data: string;
963
+ } | {
964
+ type: "text";
965
+ mediaType: "text/plain";
966
+ data: string;
967
+ };
968
+ };
969
+ retrievedAt: string | null;
970
+ }, {}>;
893
971
  /**
894
972
  * Creates a web search tool that gives Claude direct access to real-time web content.
895
973
  *
@@ -917,7 +995,7 @@ declare const anthropicTools: {
917
995
  country?: string;
918
996
  timezone?: string;
919
997
  };
920
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
998
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
921
999
  query: string;
922
1000
  }, {
923
1001
  type: "web_search_result";
@@ -925,7 +1003,7 @@ declare const anthropicTools: {
925
1003
  title: string | null;
926
1004
  pageAge: string | null;
927
1005
  encryptedContent: string;
928
- }[]>;
1006
+ }[], {}>;
929
1007
  /**
930
1008
  * Creates a web search tool that gives Claude direct access to real-time web content.
931
1009
  *
@@ -953,7 +1031,8 @@ declare const anthropicTools: {
953
1031
  country?: string;
954
1032
  timezone?: string;
955
1033
  };
956
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
1034
+ allowedCallers?: Array<"direct" | "code_execution_20250825" | "code_execution_20260120">;
1035
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
957
1036
  query: string;
958
1037
  }, {
959
1038
  type: "web_search_result";
@@ -961,7 +1040,7 @@ declare const anthropicTools: {
961
1040
  title: string | null;
962
1041
  pageAge: string | null;
963
1042
  encryptedContent: string;
964
- }[]>;
1043
+ }[], {}>;
965
1044
  /**
966
1045
  * Creates a tool search tool that uses regex patterns to find tools.
967
1046
  *
@@ -981,13 +1060,13 @@ declare const anthropicTools: {
981
1060
  }, {
982
1061
  type: "tool_reference";
983
1062
  toolName: string;
984
- }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
1063
+ }[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
985
1064
  pattern: string;
986
1065
  limit?: number;
987
1066
  }, {
988
1067
  type: "tool_reference";
989
1068
  toolName: string;
990
- }[]>;
1069
+ }[], {}>;
991
1070
  /**
992
1071
  * Creates a tool search tool that uses BM25 (natural language) to find tools.
993
1072
  *
@@ -1007,30 +1086,31 @@ declare const anthropicTools: {
1007
1086
  }, {
1008
1087
  type: "tool_reference";
1009
1088
  toolName: string;
1010
- }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
1089
+ }[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
1011
1090
  query: string;
1012
1091
  limit?: number;
1013
1092
  }, {
1014
1093
  type: "tool_reference";
1015
1094
  toolName: string;
1016
- }[]>;
1095
+ }[], {}>;
1017
1096
  };
1018
1097
 
1019
- interface AnthropicProvider extends ProviderV3 {
1098
+ interface AnthropicProvider extends ProviderV4 {
1020
1099
  /**
1021
1100
  * Creates a model for text generation.
1022
1101
  */
1023
- (modelId: AnthropicMessagesModelId): LanguageModelV3;
1102
+ (modelId: AnthropicMessagesModelId): LanguageModelV4;
1024
1103
  /**
1025
1104
  * Creates a model for text generation.
1026
1105
  */
1027
- languageModel(modelId: AnthropicMessagesModelId): LanguageModelV3;
1028
- chat(modelId: AnthropicMessagesModelId): LanguageModelV3;
1029
- messages(modelId: AnthropicMessagesModelId): LanguageModelV3;
1106
+ languageModel(modelId: AnthropicMessagesModelId): LanguageModelV4;
1107
+ chat(modelId: AnthropicMessagesModelId): LanguageModelV4;
1108
+ messages(modelId: AnthropicMessagesModelId): LanguageModelV4;
1030
1109
  /**
1031
1110
  * @deprecated Use `embeddingModel` instead.
1032
1111
  */
1033
1112
  textEmbeddingModel(modelId: string): never;
1113
+ files(): FilesV4;
1034
1114
  /**
1035
1115
  * Anthropic-specific computer use tool.
1036
1116
  */