@ai-sdk/anthropic 4.0.0-beta.2 → 4.0.0-beta.22

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,158 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.0-beta.22
4
+
5
+ ### Patch Changes
6
+
7
+ - e311194: feat(ai): allow passing provider instance to `uploadFile` and `uploadSkill` as shorthand
8
+ - Updated dependencies [e311194]
9
+ - @ai-sdk/provider@4.0.0-beta.9
10
+ - @ai-sdk/provider-utils@5.0.0-beta.15
11
+
12
+ ## 4.0.0-beta.21
13
+
14
+ ### Patch Changes
15
+
16
+ - 34bd95d: feat(ai): add support for uploading provider skills using the provider references abstraction
17
+ - Updated dependencies [34bd95d]
18
+ - Updated dependencies [008271d]
19
+ - @ai-sdk/provider@4.0.0-beta.8
20
+ - @ai-sdk/provider-utils@5.0.0-beta.14
21
+
22
+ ## 4.0.0-beta.20
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [b0c2869]
27
+ - Updated dependencies [7e26e81]
28
+ - @ai-sdk/provider-utils@5.0.0-beta.13
29
+
30
+ ## 4.0.0-beta.19
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [46d1149]
35
+ - @ai-sdk/provider-utils@5.0.0-beta.12
36
+
37
+ ## 4.0.0-beta.18
38
+
39
+ ### Patch Changes
40
+
41
+ - 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
42
+ - Updated dependencies [6fd51c0]
43
+ - @ai-sdk/provider-utils@5.0.0-beta.11
44
+ - @ai-sdk/provider@4.0.0-beta.7
45
+
46
+ ## 4.0.0-beta.17
47
+
48
+ ### Patch Changes
49
+
50
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
51
+ - Updated dependencies [c29a26f]
52
+ - @ai-sdk/provider-utils@5.0.0-beta.10
53
+ - @ai-sdk/provider@4.0.0-beta.6
54
+
55
+ ## 4.0.0-beta.16
56
+
57
+ ### Patch Changes
58
+
59
+ - 38fc777: Add AI Gateway hint to provider READMEs
60
+
61
+ ## 4.0.0-beta.15
62
+
63
+ ### Patch Changes
64
+
65
+ - f57c702: fix(anthropic): allow both temperature and topP for non-Anthropic models using the Anthropic-compatible API
66
+
67
+ 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.
68
+
69
+ ## 4.0.0-beta.14
70
+
71
+ ### Patch Changes
72
+
73
+ - Updated dependencies [2e17091]
74
+ - @ai-sdk/provider-utils@5.0.0-beta.9
75
+
76
+ ## 4.0.0-beta.13
77
+
78
+ ### Patch Changes
79
+
80
+ - Updated dependencies [986c6fd]
81
+ - Updated dependencies [493295c]
82
+ - @ai-sdk/provider-utils@5.0.0-beta.8
83
+
84
+ ## 4.0.0-beta.12
85
+
86
+ ### Patch Changes
87
+
88
+ - Updated dependencies [1f509d4]
89
+ - @ai-sdk/provider-utils@5.0.0-beta.7
90
+ - @ai-sdk/provider@4.0.0-beta.5
91
+
92
+ ## 4.0.0-beta.11
93
+
94
+ ### Patch Changes
95
+
96
+ - 0ee8aec: feat (provider/anthropic): support passing metadata.user_id
97
+
98
+ ## 4.0.0-beta.10
99
+
100
+ ### Patch Changes
101
+
102
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
103
+ - Updated dependencies [3887c70]
104
+ - @ai-sdk/provider-utils@5.0.0-beta.6
105
+ - @ai-sdk/provider@4.0.0-beta.4
106
+
107
+ ## 4.0.0-beta.9
108
+
109
+ ### Patch Changes
110
+
111
+ - Updated dependencies [776b617]
112
+ - @ai-sdk/provider-utils@5.0.0-beta.5
113
+ - @ai-sdk/provider@4.0.0-beta.3
114
+
115
+ ## 4.0.0-beta.8
116
+
117
+ ### Patch Changes
118
+
119
+ - Updated dependencies [61753c3]
120
+ - @ai-sdk/provider-utils@5.0.0-beta.4
121
+
122
+ ## 4.0.0-beta.7
123
+
124
+ ### Patch Changes
125
+
126
+ - Updated dependencies [f7d4f01]
127
+ - @ai-sdk/provider-utils@5.0.0-beta.3
128
+ - @ai-sdk/provider@4.0.0-beta.2
129
+
130
+ ## 4.0.0-beta.6
131
+
132
+ ### Patch Changes
133
+
134
+ - 21d1ee3: fix(anthropic): skip passing beta header for tool search tools
135
+
136
+ ## 4.0.0-beta.5
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [5c2a5a2]
141
+ - @ai-sdk/provider@4.0.0-beta.1
142
+ - @ai-sdk/provider-utils@5.0.0-beta.2
143
+
144
+ ## 4.0.0-beta.4
145
+
146
+ ### Patch Changes
147
+
148
+ - f05a40d: fix(vertex): throw warning when strict: true for vertexAnthropic
149
+
150
+ ## 4.0.0-beta.3
151
+
152
+ ### Patch Changes
153
+
154
+ - e748b35: chore: update v3 specs to v4
155
+
3
156
  ## 4.0.0-beta.2
4
157
 
5
158
  ### Patch Changes
@@ -440,13 +593,13 @@
440
593
  Before
441
594
 
442
595
  ```ts
443
- model.textEmbeddingModel('my-model-id');
596
+ model.textEmbeddingModel("my-model-id");
444
597
  ```
445
598
 
446
599
  After
447
600
 
448
601
  ```ts
449
- model.embeddingModel('my-model-id');
602
+ model.embeddingModel("my-model-id");
450
603
  ```
451
604
 
452
605
  - f33a018: chore: add model ID for Haiku 4.5
@@ -786,13 +939,13 @@
786
939
  Before
787
940
 
788
941
  ```ts
789
- model.textEmbeddingModel('my-model-id');
942
+ model.textEmbeddingModel("my-model-id");
790
943
  ```
791
944
 
792
945
  After
793
946
 
794
947
  ```ts
795
- model.embeddingModel('my-model-id');
948
+ model.embeddingModel("my-model-id");
796
949
  ```
797
950
 
798
951
  - 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, SkillsV4 } 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';
@@ -149,6 +149,9 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
149
149
  type: z.ZodLiteral<"ephemeral">;
150
150
  ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
151
151
  }, z.core.$strip>>;
152
+ metadata: z.ZodOptional<z.ZodObject<{
153
+ userId: z.ZodOptional<z.ZodString>;
154
+ }, z.core.$strip>>;
152
155
  mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
153
156
  type: z.ZodLiteral<"url">;
154
157
  name: z.ZodString;
@@ -161,11 +164,15 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
161
164
  }, z.core.$strip>>>;
162
165
  container: z.ZodOptional<z.ZodObject<{
163
166
  id: z.ZodOptional<z.ZodString>;
164
- skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
165
- type: z.ZodUnion<readonly [z.ZodLiteral<"anthropic">, z.ZodLiteral<"custom">]>;
167
+ skills: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
168
+ type: z.ZodLiteral<"anthropic">;
166
169
  skillId: z.ZodString;
167
170
  version: z.ZodOptional<z.ZodString>;
168
- }, z.core.$strip>>>;
171
+ }, z.core.$strip>, z.ZodObject<{
172
+ type: z.ZodLiteral<"custom">;
173
+ providerReference: z.ZodRecord<z.ZodString, z.ZodString>;
174
+ version: z.ZodOptional<z.ZodString>;
175
+ }, z.core.$strip>]>>>;
169
176
  }, z.core.$strip>>;
170
177
  toolStreaming: z.ZodOptional<z.ZodBoolean>;
171
178
  effort: z.ZodOptional<z.ZodEnum<{
@@ -234,7 +241,7 @@ declare const anthropicTools: {
234
241
  bash_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
235
242
  command: string;
236
243
  restart?: boolean;
237
- }, {}>;
244
+ }, {}, {}>;
238
245
  /**
239
246
  * The bash tool enables Claude to execute shell commands in a persistent bash session,
240
247
  * allowing system operations, script execution, and command-line automation.
@@ -244,7 +251,7 @@ declare const anthropicTools: {
244
251
  bash_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{
245
252
  command: string;
246
253
  restart?: boolean;
247
- }, {}>;
254
+ }, {}, {}>;
248
255
  /**
249
256
  * Claude can analyze data, create visualizations, perform complex calculations,
250
257
  * run system commands, create and edit files, and process uploaded files directly within
@@ -264,7 +271,7 @@ declare const anthropicTools: {
264
271
  type: "code_execution_output";
265
272
  file_id: string;
266
273
  }>;
267
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
274
+ }, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
268
275
  code: string;
269
276
  }, {
270
277
  type: "code_execution_result";
@@ -275,7 +282,7 @@ declare const anthropicTools: {
275
282
  type: "code_execution_output";
276
283
  file_id: string;
277
284
  }>;
278
- }>;
285
+ }, {}>;
279
286
  /**
280
287
  * Claude can analyze data, create visualizations, perform complex calculations,
281
288
  * run system commands, create and edit files, and process uploaded files directly within
@@ -348,7 +355,7 @@ declare const anthropicTools: {
348
355
  new_start: number | null;
349
356
  old_lines: number | null;
350
357
  old_start: number | null;
351
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
358
+ }, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
352
359
  type: "programmatic-tool-call";
353
360
  code: string;
354
361
  } | {
@@ -410,7 +417,7 @@ declare const anthropicTools: {
410
417
  new_start: number | null;
411
418
  old_lines: number | null;
412
419
  old_start: number | null;
413
- }>;
420
+ }, {}>;
414
421
  /**
415
422
  * Claude can analyze data, create visualizations, perform complex calculations,
416
423
  * run system commands, create and edit files, and process uploaded files directly within
@@ -494,7 +501,7 @@ declare const anthropicTools: {
494
501
  new_start: number | null;
495
502
  old_lines: number | null;
496
503
  old_start: number | null;
497
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
504
+ }, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
498
505
  type: "programmatic-tool-call";
499
506
  code: string;
500
507
  } | {
@@ -565,7 +572,7 @@ declare const anthropicTools: {
565
572
  new_start: number | null;
566
573
  old_lines: number | null;
567
574
  old_start: number | null;
568
- }>;
575
+ }, {}>;
569
576
  /**
570
577
  * Claude can interact with computer environments through the computer use tool, which
571
578
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -584,7 +591,7 @@ declare const anthropicTools: {
584
591
  displayWidthPx: number;
585
592
  displayHeightPx: number;
586
593
  displayNumber?: number;
587
- }>;
594
+ }, {}>;
588
595
  /**
589
596
  * Claude can interact with computer environments through the computer use tool, which
590
597
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -607,7 +614,7 @@ declare const anthropicTools: {
607
614
  displayWidthPx: number;
608
615
  displayHeightPx: number;
609
616
  displayNumber?: number;
610
- }>;
617
+ }, {}>;
611
618
  /**
612
619
  * Claude can interact with computer environments through the computer use tool, which
613
620
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -637,7 +644,7 @@ declare const anthropicTools: {
637
644
  displayHeightPx: number;
638
645
  displayNumber?: number;
639
646
  enableZoom?: boolean;
640
- }>;
647
+ }, {}>;
641
648
  /**
642
649
  * The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
643
650
  * Claude can create, read, update, and delete files that persist between sessions,
@@ -671,7 +678,7 @@ declare const anthropicTools: {
671
678
  command: "rename";
672
679
  old_path: string;
673
680
  new_path: string;
674
- }, {}>;
681
+ }, {}, {}>;
675
682
  /**
676
683
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
677
684
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -688,7 +695,7 @@ declare const anthropicTools: {
688
695
  insert_text?: string;
689
696
  old_str?: string;
690
697
  view_range?: number[];
691
- }, {}>;
698
+ }, {}, {}>;
692
699
  /**
693
700
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
694
701
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -705,7 +712,7 @@ declare const anthropicTools: {
705
712
  insert_text?: string;
706
713
  old_str?: string;
707
714
  view_range?: number[];
708
- }, {}>;
715
+ }, {}, {}>;
709
716
  /**
710
717
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
711
718
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -724,7 +731,7 @@ declare const anthropicTools: {
724
731
  insert_text?: string;
725
732
  old_str?: string;
726
733
  view_range?: number[];
727
- }, {}>;
734
+ }, {}, {}>;
728
735
  /**
729
736
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
730
737
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -747,7 +754,7 @@ declare const anthropicTools: {
747
754
  view_range?: number[];
748
755
  }, {
749
756
  maxCharacters?: number;
750
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
757
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
751
758
  command: "view" | "create" | "str_replace" | "insert";
752
759
  path: string;
753
760
  file_text?: string;
@@ -756,7 +763,7 @@ declare const anthropicTools: {
756
763
  insert_text?: string;
757
764
  old_str?: string;
758
765
  view_range?: number[];
759
- }, unknown>;
766
+ }, unknown, {}>;
760
767
  /**
761
768
  * Creates a web fetch tool that gives Claude direct access to real-time web content.
762
769
  *
@@ -796,7 +803,7 @@ declare const anthropicTools: {
796
803
  enabled: boolean;
797
804
  };
798
805
  maxContentTokens?: number;
799
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
806
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
800
807
  url: string;
801
808
  }, {
802
809
  type: "web_fetch_result";
@@ -818,7 +825,7 @@ declare const anthropicTools: {
818
825
  };
819
826
  };
820
827
  retrievedAt: string | null;
821
- }>;
828
+ }, {}>;
822
829
  /**
823
830
  * Creates a web fetch tool that gives Claude direct access to real-time web content.
824
831
  *
@@ -858,7 +865,7 @@ declare const anthropicTools: {
858
865
  enabled: boolean;
859
866
  };
860
867
  maxContentTokens?: number;
861
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
868
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
862
869
  url: string;
863
870
  }, {
864
871
  type: "web_fetch_result";
@@ -880,7 +887,7 @@ declare const anthropicTools: {
880
887
  };
881
888
  };
882
889
  retrievedAt: string | null;
883
- }>;
890
+ }, {}>;
884
891
  /**
885
892
  * Creates a web search tool that gives Claude direct access to real-time web content.
886
893
  *
@@ -908,7 +915,7 @@ declare const anthropicTools: {
908
915
  country?: string;
909
916
  timezone?: string;
910
917
  };
911
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
918
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
912
919
  query: string;
913
920
  }, {
914
921
  type: "web_search_result";
@@ -916,7 +923,7 @@ declare const anthropicTools: {
916
923
  title: string | null;
917
924
  pageAge: string | null;
918
925
  encryptedContent: string;
919
- }[]>;
926
+ }[], {}>;
920
927
  /**
921
928
  * Creates a web search tool that gives Claude direct access to real-time web content.
922
929
  *
@@ -944,7 +951,7 @@ declare const anthropicTools: {
944
951
  country?: string;
945
952
  timezone?: string;
946
953
  };
947
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
954
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
948
955
  query: string;
949
956
  }, {
950
957
  type: "web_search_result";
@@ -952,7 +959,7 @@ declare const anthropicTools: {
952
959
  title: string | null;
953
960
  pageAge: string | null;
954
961
  encryptedContent: string;
955
- }[]>;
962
+ }[], {}>;
956
963
  /**
957
964
  * Creates a tool search tool that uses regex patterns to find tools.
958
965
  *
@@ -972,13 +979,13 @@ declare const anthropicTools: {
972
979
  }, {
973
980
  type: "tool_reference";
974
981
  toolName: string;
975
- }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
982
+ }[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
976
983
  pattern: string;
977
984
  limit?: number;
978
985
  }, {
979
986
  type: "tool_reference";
980
987
  toolName: string;
981
- }[]>;
988
+ }[], {}>;
982
989
  /**
983
990
  * Creates a tool search tool that uses BM25 (natural language) to find tools.
984
991
  *
@@ -998,30 +1005,35 @@ declare const anthropicTools: {
998
1005
  }, {
999
1006
  type: "tool_reference";
1000
1007
  toolName: string;
1001
- }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
1008
+ }[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
1002
1009
  query: string;
1003
1010
  limit?: number;
1004
1011
  }, {
1005
1012
  type: "tool_reference";
1006
1013
  toolName: string;
1007
- }[]>;
1014
+ }[], {}>;
1008
1015
  };
1009
1016
 
1010
- interface AnthropicProvider extends ProviderV3 {
1017
+ interface AnthropicProvider extends ProviderV4 {
1011
1018
  /**
1012
1019
  * Creates a model for text generation.
1013
1020
  */
1014
- (modelId: AnthropicMessagesModelId): LanguageModelV3;
1021
+ (modelId: AnthropicMessagesModelId): LanguageModelV4;
1015
1022
  /**
1016
1023
  * Creates a model for text generation.
1017
1024
  */
1018
- languageModel(modelId: AnthropicMessagesModelId): LanguageModelV3;
1019
- chat(modelId: AnthropicMessagesModelId): LanguageModelV3;
1020
- messages(modelId: AnthropicMessagesModelId): LanguageModelV3;
1025
+ languageModel(modelId: AnthropicMessagesModelId): LanguageModelV4;
1026
+ chat(modelId: AnthropicMessagesModelId): LanguageModelV4;
1027
+ messages(modelId: AnthropicMessagesModelId): LanguageModelV4;
1021
1028
  /**
1022
1029
  * @deprecated Use `embeddingModel` instead.
1023
1030
  */
1024
1031
  textEmbeddingModel(modelId: string): never;
1032
+ files(): FilesV4;
1033
+ /**
1034
+ * Returns a SkillsV4 interface for uploading skills to Anthropic.
1035
+ */
1036
+ skills(): SkillsV4;
1025
1037
  /**
1026
1038
  * Anthropic-specific computer use tool.
1027
1039
  */