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

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