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

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,149 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.0-beta.21
4
+
5
+ ### Patch Changes
6
+
7
+ - 34bd95d: feat(ai): add support for uploading provider skills using the provider references abstraction
8
+ - Updated dependencies [34bd95d]
9
+ - Updated dependencies [008271d]
10
+ - @ai-sdk/provider@4.0.0-beta.8
11
+ - @ai-sdk/provider-utils@5.0.0-beta.14
12
+
13
+ ## 4.0.0-beta.20
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [b0c2869]
18
+ - Updated dependencies [7e26e81]
19
+ - @ai-sdk/provider-utils@5.0.0-beta.13
20
+
21
+ ## 4.0.0-beta.19
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [46d1149]
26
+ - @ai-sdk/provider-utils@5.0.0-beta.12
27
+
28
+ ## 4.0.0-beta.18
29
+
30
+ ### Patch Changes
31
+
32
+ - 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
33
+ - Updated dependencies [6fd51c0]
34
+ - @ai-sdk/provider-utils@5.0.0-beta.11
35
+ - @ai-sdk/provider@4.0.0-beta.7
36
+
37
+ ## 4.0.0-beta.17
38
+
39
+ ### Patch Changes
40
+
41
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
42
+ - Updated dependencies [c29a26f]
43
+ - @ai-sdk/provider-utils@5.0.0-beta.10
44
+ - @ai-sdk/provider@4.0.0-beta.6
45
+
46
+ ## 4.0.0-beta.16
47
+
48
+ ### Patch Changes
49
+
50
+ - 38fc777: Add AI Gateway hint to provider READMEs
51
+
52
+ ## 4.0.0-beta.15
53
+
54
+ ### Patch Changes
55
+
56
+ - f57c702: fix(anthropic): allow both temperature and topP for non-Anthropic models using the Anthropic-compatible API
57
+
58
+ 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.
59
+
60
+ ## 4.0.0-beta.14
61
+
62
+ ### Patch Changes
63
+
64
+ - Updated dependencies [2e17091]
65
+ - @ai-sdk/provider-utils@5.0.0-beta.9
66
+
67
+ ## 4.0.0-beta.13
68
+
69
+ ### Patch Changes
70
+
71
+ - Updated dependencies [986c6fd]
72
+ - Updated dependencies [493295c]
73
+ - @ai-sdk/provider-utils@5.0.0-beta.8
74
+
75
+ ## 4.0.0-beta.12
76
+
77
+ ### Patch Changes
78
+
79
+ - Updated dependencies [1f509d4]
80
+ - @ai-sdk/provider-utils@5.0.0-beta.7
81
+ - @ai-sdk/provider@4.0.0-beta.5
82
+
83
+ ## 4.0.0-beta.11
84
+
85
+ ### Patch Changes
86
+
87
+ - 0ee8aec: feat (provider/anthropic): support passing metadata.user_id
88
+
89
+ ## 4.0.0-beta.10
90
+
91
+ ### Patch Changes
92
+
93
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
94
+ - Updated dependencies [3887c70]
95
+ - @ai-sdk/provider-utils@5.0.0-beta.6
96
+ - @ai-sdk/provider@4.0.0-beta.4
97
+
98
+ ## 4.0.0-beta.9
99
+
100
+ ### Patch Changes
101
+
102
+ - Updated dependencies [776b617]
103
+ - @ai-sdk/provider-utils@5.0.0-beta.5
104
+ - @ai-sdk/provider@4.0.0-beta.3
105
+
106
+ ## 4.0.0-beta.8
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies [61753c3]
111
+ - @ai-sdk/provider-utils@5.0.0-beta.4
112
+
113
+ ## 4.0.0-beta.7
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies [f7d4f01]
118
+ - @ai-sdk/provider-utils@5.0.0-beta.3
119
+ - @ai-sdk/provider@4.0.0-beta.2
120
+
121
+ ## 4.0.0-beta.6
122
+
123
+ ### Patch Changes
124
+
125
+ - 21d1ee3: fix(anthropic): skip passing beta header for tool search tools
126
+
127
+ ## 4.0.0-beta.5
128
+
129
+ ### Patch Changes
130
+
131
+ - Updated dependencies [5c2a5a2]
132
+ - @ai-sdk/provider@4.0.0-beta.1
133
+ - @ai-sdk/provider-utils@5.0.0-beta.2
134
+
135
+ ## 4.0.0-beta.4
136
+
137
+ ### Patch Changes
138
+
139
+ - f05a40d: fix(vertex): throw warning when strict: true for vertexAnthropic
140
+
141
+ ## 4.0.0-beta.3
142
+
143
+ ### Patch Changes
144
+
145
+ - e748b35: chore: update v3 specs to v4
146
+
3
147
  ## 4.0.0-beta.2
4
148
 
5
149
  ### Patch Changes
@@ -440,13 +584,13 @@
440
584
  Before
441
585
 
442
586
  ```ts
443
- model.textEmbeddingModel('my-model-id');
587
+ model.textEmbeddingModel("my-model-id");
444
588
  ```
445
589
 
446
590
  After
447
591
 
448
592
  ```ts
449
- model.embeddingModel('my-model-id');
593
+ model.embeddingModel("my-model-id");
450
594
  ```
451
595
 
452
596
  - f33a018: chore: add model ID for Haiku 4.5
@@ -786,13 +930,13 @@
786
930
  Before
787
931
 
788
932
  ```ts
789
- model.textEmbeddingModel('my-model-id');
933
+ model.textEmbeddingModel("my-model-id");
790
934
  ```
791
935
 
792
936
  After
793
937
 
794
938
  ```ts
795
- model.embeddingModel('my-model-id');
939
+ model.embeddingModel("my-model-id");
796
940
  ```
797
941
 
798
942
  - 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
  */