@ai-sdk/anthropic 4.0.0-beta.4 → 4.0.0-beta.40

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +293 -4
  2. package/README.md +2 -0
  3. package/dist/index.d.ts +83 -58
  4. package/dist/index.js +1918 -1259
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +85 -58
  7. package/dist/internal/index.js +1679 -1245
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/05-anthropic.mdx +115 -12
  10. package/package.json +14 -15
  11. package/src/{anthropic-messages-api.ts → anthropic-api.ts} +8 -4
  12. package/src/anthropic-files.ts +96 -0
  13. package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +239 -54
  14. package/src/anthropic-message-metadata.ts +0 -3
  15. package/src/{anthropic-messages-options.ts → anthropic-options.ts} +68 -11
  16. package/src/anthropic-prepare-tools.ts +12 -5
  17. package/src/anthropic-provider.ts +39 -10
  18. package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +3 -3
  19. package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +51 -28
  20. package/src/get-cache-control.ts +1 -1
  21. package/src/index.ts +1 -1
  22. package/src/internal/index.ts +11 -2
  23. package/src/sanitize-json-schema.ts +203 -0
  24. package/src/skills/anthropic-skills-api.ts +44 -0
  25. package/src/skills/anthropic-skills.ts +136 -0
  26. package/src/tool/bash_20241022.ts +2 -2
  27. package/src/tool/bash_20250124.ts +2 -2
  28. package/src/tool/code-execution_20250522.ts +2 -2
  29. package/src/tool/code-execution_20250825.ts +2 -2
  30. package/src/tool/code-execution_20260120.ts +2 -2
  31. package/src/tool/computer_20241022.ts +2 -2
  32. package/src/tool/computer_20250124.ts +2 -2
  33. package/src/tool/computer_20251124.ts +2 -2
  34. package/src/tool/memory_20250818.ts +2 -2
  35. package/src/tool/text-editor_20241022.ts +2 -2
  36. package/src/tool/text-editor_20250124.ts +2 -2
  37. package/src/tool/text-editor_20250429.ts +2 -2
  38. package/src/tool/text-editor_20250728.ts +2 -2
  39. package/src/tool/tool-search-bm25_20251119.ts +2 -2
  40. package/src/tool/tool-search-regex_20251119.ts +2 -2
  41. package/src/tool/web-fetch-20250910.ts +2 -2
  42. package/src/tool/web-fetch-20260209.ts +2 -2
  43. package/src/tool/web-search_20250305.ts +2 -2
  44. package/src/tool/web-search_20260209.ts +2 -2
  45. package/dist/index.d.mts +0 -1090
  46. package/dist/index.mjs +0 -5244
  47. package/dist/index.mjs.map +0 -1
  48. package/dist/internal/index.d.mts +0 -969
  49. package/dist/internal/index.mjs +0 -5136
  50. package/dist/internal/index.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,294 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.0-beta.40
4
+
5
+ ### Patch Changes
6
+
7
+ - c012d57: feat(anthropic): sanitize the unsupported JSON schema validation properties
8
+
9
+ ## 4.0.0-beta.39
10
+
11
+ ### Patch Changes
12
+
13
+ - 9f0e36c: trigger release for all packages after provenance setup
14
+ - Updated dependencies [9f0e36c]
15
+ - @ai-sdk/provider@4.0.0-beta.13
16
+ - @ai-sdk/provider-utils@5.0.0-beta.28
17
+
18
+ ## 4.0.0-beta.38
19
+
20
+ ### Patch Changes
21
+
22
+ - 87d1723: chore(anthropic): remove unnecessary messages affix from Anthropic symbols and files
23
+ - 58a2ad7: fix: more precise default message for tool execution denial
24
+ - Updated dependencies [785fe16]
25
+ - Updated dependencies [67df0a0]
26
+ - Updated dependencies [befb78c]
27
+ - Updated dependencies [0458559]
28
+ - Updated dependencies [5852c0a]
29
+ - Updated dependencies [fc92055]
30
+ - @ai-sdk/provider-utils@5.0.0-beta.27
31
+
32
+ ## 4.0.0-beta.37
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [2e98477]
37
+ - @ai-sdk/provider-utils@5.0.0-beta.26
38
+
39
+ ## 4.0.0-beta.36
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies [eea8d98]
44
+ - @ai-sdk/provider-utils@5.0.0-beta.25
45
+
46
+ ## 4.0.0-beta.35
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [f807e45]
51
+ - @ai-sdk/provider-utils@5.0.0-beta.24
52
+
53
+ ## 4.0.0-beta.34
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [350ea38]
58
+ - @ai-sdk/provider-utils@5.0.0-beta.23
59
+
60
+ ## 4.0.0-beta.33
61
+
62
+ ### Major Changes
63
+
64
+ - 832f86f: fix(anthropic): remove cacheCreationInputTokens from providerMetadata
65
+
66
+ ## 4.0.0-beta.32
67
+
68
+ ### Patch Changes
69
+
70
+ - ad0b376: fix(provider/anthropic): stop adding `fine-grained-tool-streaming-2025-05-14` beta for `claude-opus-4-7`
71
+
72
+ ## 4.0.0-beta.31
73
+
74
+ ### Patch Changes
75
+
76
+ - Updated dependencies [083947b]
77
+ - @ai-sdk/provider-utils@5.0.0-beta.22
78
+
79
+ ## 4.0.0-beta.30
80
+
81
+ ### Patch Changes
82
+
83
+ - 0d8f107: feat(provider/anthropic): add support for Opus 4.7 and relevant API enhancements
84
+
85
+ ## 4.0.0-beta.29
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [add1126]
90
+ - @ai-sdk/provider-utils@5.0.0-beta.21
91
+
92
+ ## 4.0.0-beta.28
93
+
94
+ ### Patch Changes
95
+
96
+ - b3976a2: Add workflow serialization support to all provider models.
97
+
98
+ **`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
99
+
100
+ **All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
101
+
102
+ All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
103
+
104
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
105
+ - Updated dependencies [b3976a2]
106
+ - Updated dependencies [ff5eba1]
107
+ - @ai-sdk/provider-utils@5.0.0-beta.20
108
+ - @ai-sdk/provider@4.0.0-beta.12
109
+
110
+ ## 4.0.0-beta.27
111
+
112
+ ### Major Changes
113
+
114
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
115
+
116
+ ### Patch Changes
117
+
118
+ - Updated dependencies [ef992f8]
119
+ - @ai-sdk/provider@4.0.0-beta.11
120
+ - @ai-sdk/provider-utils@5.0.0-beta.19
121
+
122
+ ## 4.0.0-beta.26
123
+
124
+ ### Patch Changes
125
+
126
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
127
+ - Updated dependencies [90e2d8a]
128
+ - @ai-sdk/provider-utils@5.0.0-beta.18
129
+
130
+ ## 4.0.0-beta.25
131
+
132
+ ### Patch Changes
133
+
134
+ - 09bd27b: feat (provider/anthropic): add support for inference_geo provider option
135
+
136
+ ## 4.0.0-beta.24
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [3ae1786]
141
+ - @ai-sdk/provider-utils@5.0.0-beta.17
142
+
143
+ ## 4.0.0-beta.23
144
+
145
+ ### Patch Changes
146
+
147
+ - Updated dependencies [176466a]
148
+ - @ai-sdk/provider@4.0.0-beta.10
149
+ - @ai-sdk/provider-utils@5.0.0-beta.16
150
+
151
+ ## 4.0.0-beta.22
152
+
153
+ ### Patch Changes
154
+
155
+ - e311194: feat(ai): allow passing provider instance to `uploadFile` and `uploadSkill` as shorthand
156
+ - Updated dependencies [e311194]
157
+ - @ai-sdk/provider@4.0.0-beta.9
158
+ - @ai-sdk/provider-utils@5.0.0-beta.15
159
+
160
+ ## 4.0.0-beta.21
161
+
162
+ ### Patch Changes
163
+
164
+ - 34bd95d: feat(ai): add support for uploading provider skills using the provider references abstraction
165
+ - Updated dependencies [34bd95d]
166
+ - Updated dependencies [008271d]
167
+ - @ai-sdk/provider@4.0.0-beta.8
168
+ - @ai-sdk/provider-utils@5.0.0-beta.14
169
+
170
+ ## 4.0.0-beta.20
171
+
172
+ ### Patch Changes
173
+
174
+ - Updated dependencies [b0c2869]
175
+ - Updated dependencies [7e26e81]
176
+ - @ai-sdk/provider-utils@5.0.0-beta.13
177
+
178
+ ## 4.0.0-beta.19
179
+
180
+ ### Patch Changes
181
+
182
+ - Updated dependencies [46d1149]
183
+ - @ai-sdk/provider-utils@5.0.0-beta.12
184
+
185
+ ## 4.0.0-beta.18
186
+
187
+ ### Patch Changes
188
+
189
+ - 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
190
+ - Updated dependencies [6fd51c0]
191
+ - @ai-sdk/provider-utils@5.0.0-beta.11
192
+ - @ai-sdk/provider@4.0.0-beta.7
193
+
194
+ ## 4.0.0-beta.17
195
+
196
+ ### Patch Changes
197
+
198
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
199
+ - Updated dependencies [c29a26f]
200
+ - @ai-sdk/provider-utils@5.0.0-beta.10
201
+ - @ai-sdk/provider@4.0.0-beta.6
202
+
203
+ ## 4.0.0-beta.16
204
+
205
+ ### Patch Changes
206
+
207
+ - 38fc777: Add AI Gateway hint to provider READMEs
208
+
209
+ ## 4.0.0-beta.15
210
+
211
+ ### Patch Changes
212
+
213
+ - f57c702: fix(anthropic): allow both temperature and topP for non-Anthropic models using the Anthropic-compatible API
214
+
215
+ 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.
216
+
217
+ ## 4.0.0-beta.14
218
+
219
+ ### Patch Changes
220
+
221
+ - Updated dependencies [2e17091]
222
+ - @ai-sdk/provider-utils@5.0.0-beta.9
223
+
224
+ ## 4.0.0-beta.13
225
+
226
+ ### Patch Changes
227
+
228
+ - Updated dependencies [986c6fd]
229
+ - Updated dependencies [493295c]
230
+ - @ai-sdk/provider-utils@5.0.0-beta.8
231
+
232
+ ## 4.0.0-beta.12
233
+
234
+ ### Patch Changes
235
+
236
+ - Updated dependencies [1f509d4]
237
+ - @ai-sdk/provider-utils@5.0.0-beta.7
238
+ - @ai-sdk/provider@4.0.0-beta.5
239
+
240
+ ## 4.0.0-beta.11
241
+
242
+ ### Patch Changes
243
+
244
+ - 0ee8aec: feat (provider/anthropic): support passing metadata.user_id
245
+
246
+ ## 4.0.0-beta.10
247
+
248
+ ### Patch Changes
249
+
250
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
251
+ - Updated dependencies [3887c70]
252
+ - @ai-sdk/provider-utils@5.0.0-beta.6
253
+ - @ai-sdk/provider@4.0.0-beta.4
254
+
255
+ ## 4.0.0-beta.9
256
+
257
+ ### Patch Changes
258
+
259
+ - Updated dependencies [776b617]
260
+ - @ai-sdk/provider-utils@5.0.0-beta.5
261
+ - @ai-sdk/provider@4.0.0-beta.3
262
+
263
+ ## 4.0.0-beta.8
264
+
265
+ ### Patch Changes
266
+
267
+ - Updated dependencies [61753c3]
268
+ - @ai-sdk/provider-utils@5.0.0-beta.4
269
+
270
+ ## 4.0.0-beta.7
271
+
272
+ ### Patch Changes
273
+
274
+ - Updated dependencies [f7d4f01]
275
+ - @ai-sdk/provider-utils@5.0.0-beta.3
276
+ - @ai-sdk/provider@4.0.0-beta.2
277
+
278
+ ## 4.0.0-beta.6
279
+
280
+ ### Patch Changes
281
+
282
+ - 21d1ee3: fix(anthropic): skip passing beta header for tool search tools
283
+
284
+ ## 4.0.0-beta.5
285
+
286
+ ### Patch Changes
287
+
288
+ - Updated dependencies [5c2a5a2]
289
+ - @ai-sdk/provider@4.0.0-beta.1
290
+ - @ai-sdk/provider-utils@5.0.0-beta.2
291
+
3
292
  ## 4.0.0-beta.4
4
293
 
5
294
  ### Patch Changes
@@ -452,13 +741,13 @@
452
741
  Before
453
742
 
454
743
  ```ts
455
- model.textEmbeddingModel('my-model-id');
744
+ model.textEmbeddingModel("my-model-id");
456
745
  ```
457
746
 
458
747
  After
459
748
 
460
749
  ```ts
461
- model.embeddingModel('my-model-id');
750
+ model.embeddingModel("my-model-id");
462
751
  ```
463
752
 
464
753
  - f33a018: chore: add model ID for Haiku 4.5
@@ -798,13 +1087,13 @@
798
1087
  Before
799
1088
 
800
1089
  ```ts
801
- model.textEmbeddingModel('my-model-id');
1090
+ model.textEmbeddingModel("my-model-id");
802
1091
  ```
803
1092
 
804
1093
  After
805
1094
 
806
1095
  ```ts
807
- model.embeddingModel('my-model-id');
1096
+ model.embeddingModel("my-model-id");
808
1097
  ```
809
1098
 
810
1099
  - 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