@ai-sdk/anthropic 4.0.0-beta.8 → 4.0.0-canary.43

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 +298 -4
  2. package/README.md +2 -0
  3. package/dist/index.d.ts +83 -58
  4. package/dist/index.js +2043 -1354
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +85 -58
  7. package/dist/internal/index.js +1804 -1340
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/05-anthropic.mdx +116 -13
  10. package/package.json +13 -14
  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-options.ts → anthropic-language-model-options.ts} +68 -11
  15. package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +263 -78
  16. package/src/anthropic-message-metadata.ts +1 -4
  17. package/src/anthropic-prepare-tools.ts +14 -5
  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 -5242
  50. package/dist/index.mjs.map +0 -1
  51. package/dist/internal/index.d.mts +0 -969
  52. package/dist/internal/index.mjs +0 -5134
  53. package/dist/internal/index.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,299 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.0-canary.43
4
+
5
+ ### Patch Changes
6
+
7
+ - 0c4c275: trigger initial canary release
8
+ - Updated dependencies [0c4c275]
9
+ - @ai-sdk/provider-utils@5.0.0-canary.31
10
+ - @ai-sdk/provider@4.0.0-canary.15
11
+
12
+ ## 4.0.0-beta.42
13
+
14
+ ### Major Changes
15
+
16
+ - 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
17
+
18
+ For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [08d2129]
23
+ - @ai-sdk/provider-utils@5.0.0-beta.30
24
+
25
+ ## 4.0.0-beta.41
26
+
27
+ ### Patch Changes
28
+
29
+ - 9bd6512: feat(provider): change file part data property to be tagged with a type and remove the image part type
30
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
31
+ - Updated dependencies [9bd6512]
32
+ - Updated dependencies [258c093]
33
+ - Updated dependencies [b6783da]
34
+ - @ai-sdk/provider-utils@5.0.0-beta.29
35
+ - @ai-sdk/provider@4.0.0-beta.14
36
+
37
+ ## 4.0.0-beta.40
38
+
39
+ ### Patch Changes
40
+
41
+ - c012d57: feat(anthropic): sanitize the unsupported JSON schema validation properties
42
+
43
+ ## 4.0.0-beta.39
44
+
45
+ ### Patch Changes
46
+
47
+ - 9f0e36c: trigger release for all packages after provenance setup
48
+ - Updated dependencies [9f0e36c]
49
+ - @ai-sdk/provider@4.0.0-beta.13
50
+ - @ai-sdk/provider-utils@5.0.0-beta.28
51
+
52
+ ## 4.0.0-beta.38
53
+
54
+ ### Patch Changes
55
+
56
+ - 87d1723: chore(anthropic): remove unnecessary messages affix from Anthropic symbols and files
57
+ - 58a2ad7: fix: more precise default message for tool execution denial
58
+ - Updated dependencies [785fe16]
59
+ - Updated dependencies [67df0a0]
60
+ - Updated dependencies [befb78c]
61
+ - Updated dependencies [0458559]
62
+ - Updated dependencies [5852c0a]
63
+ - Updated dependencies [fc92055]
64
+ - @ai-sdk/provider-utils@5.0.0-beta.27
65
+
66
+ ## 4.0.0-beta.37
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [2e98477]
71
+ - @ai-sdk/provider-utils@5.0.0-beta.26
72
+
73
+ ## 4.0.0-beta.36
74
+
75
+ ### Patch Changes
76
+
77
+ - Updated dependencies [eea8d98]
78
+ - @ai-sdk/provider-utils@5.0.0-beta.25
79
+
80
+ ## 4.0.0-beta.35
81
+
82
+ ### Patch Changes
83
+
84
+ - Updated dependencies [f807e45]
85
+ - @ai-sdk/provider-utils@5.0.0-beta.24
86
+
87
+ ## 4.0.0-beta.34
88
+
89
+ ### Patch Changes
90
+
91
+ - Updated dependencies [350ea38]
92
+ - @ai-sdk/provider-utils@5.0.0-beta.23
93
+
94
+ ## 4.0.0-beta.33
95
+
96
+ ### Major Changes
97
+
98
+ - 832f86f: fix(anthropic): remove cacheCreationInputTokens from providerMetadata
99
+
100
+ ## 4.0.0-beta.32
101
+
102
+ ### Patch Changes
103
+
104
+ - ad0b376: fix(provider/anthropic): stop adding `fine-grained-tool-streaming-2025-05-14` beta for `claude-opus-4-7`
105
+
106
+ ## 4.0.0-beta.31
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies [083947b]
111
+ - @ai-sdk/provider-utils@5.0.0-beta.22
112
+
113
+ ## 4.0.0-beta.30
114
+
115
+ ### Patch Changes
116
+
117
+ - 0d8f107: feat(provider/anthropic): add support for Opus 4.7 and relevant API enhancements
118
+
119
+ ## 4.0.0-beta.29
120
+
121
+ ### Patch Changes
122
+
123
+ - Updated dependencies [add1126]
124
+ - @ai-sdk/provider-utils@5.0.0-beta.21
125
+
126
+ ## 4.0.0-beta.28
127
+
128
+ ### Patch Changes
129
+
130
+ - b3976a2: Add workflow serialization support to all provider models.
131
+
132
+ **`@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.
133
+
134
+ **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.
135
+
136
+ All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
137
+
138
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
139
+ - Updated dependencies [b3976a2]
140
+ - Updated dependencies [ff5eba1]
141
+ - @ai-sdk/provider-utils@5.0.0-beta.20
142
+ - @ai-sdk/provider@4.0.0-beta.12
143
+
144
+ ## 4.0.0-beta.27
145
+
146
+ ### Major Changes
147
+
148
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
149
+
150
+ ### Patch Changes
151
+
152
+ - Updated dependencies [ef992f8]
153
+ - @ai-sdk/provider@4.0.0-beta.11
154
+ - @ai-sdk/provider-utils@5.0.0-beta.19
155
+
156
+ ## 4.0.0-beta.26
157
+
158
+ ### Patch Changes
159
+
160
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
161
+ - Updated dependencies [90e2d8a]
162
+ - @ai-sdk/provider-utils@5.0.0-beta.18
163
+
164
+ ## 4.0.0-beta.25
165
+
166
+ ### Patch Changes
167
+
168
+ - 09bd27b: feat (provider/anthropic): add support for inference_geo provider option
169
+
170
+ ## 4.0.0-beta.24
171
+
172
+ ### Patch Changes
173
+
174
+ - Updated dependencies [3ae1786]
175
+ - @ai-sdk/provider-utils@5.0.0-beta.17
176
+
177
+ ## 4.0.0-beta.23
178
+
179
+ ### Patch Changes
180
+
181
+ - Updated dependencies [176466a]
182
+ - @ai-sdk/provider@4.0.0-beta.10
183
+ - @ai-sdk/provider-utils@5.0.0-beta.16
184
+
185
+ ## 4.0.0-beta.22
186
+
187
+ ### Patch Changes
188
+
189
+ - e311194: feat(ai): allow passing provider instance to `uploadFile` and `uploadSkill` as shorthand
190
+ - Updated dependencies [e311194]
191
+ - @ai-sdk/provider@4.0.0-beta.9
192
+ - @ai-sdk/provider-utils@5.0.0-beta.15
193
+
194
+ ## 4.0.0-beta.21
195
+
196
+ ### Patch Changes
197
+
198
+ - 34bd95d: feat(ai): add support for uploading provider skills using the provider references abstraction
199
+ - Updated dependencies [34bd95d]
200
+ - Updated dependencies [008271d]
201
+ - @ai-sdk/provider@4.0.0-beta.8
202
+ - @ai-sdk/provider-utils@5.0.0-beta.14
203
+
204
+ ## 4.0.0-beta.20
205
+
206
+ ### Patch Changes
207
+
208
+ - Updated dependencies [b0c2869]
209
+ - Updated dependencies [7e26e81]
210
+ - @ai-sdk/provider-utils@5.0.0-beta.13
211
+
212
+ ## 4.0.0-beta.19
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [46d1149]
217
+ - @ai-sdk/provider-utils@5.0.0-beta.12
218
+
219
+ ## 4.0.0-beta.18
220
+
221
+ ### Patch Changes
222
+
223
+ - 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
224
+ - Updated dependencies [6fd51c0]
225
+ - @ai-sdk/provider-utils@5.0.0-beta.11
226
+ - @ai-sdk/provider@4.0.0-beta.7
227
+
228
+ ## 4.0.0-beta.17
229
+
230
+ ### Patch Changes
231
+
232
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
233
+ - Updated dependencies [c29a26f]
234
+ - @ai-sdk/provider-utils@5.0.0-beta.10
235
+ - @ai-sdk/provider@4.0.0-beta.6
236
+
237
+ ## 4.0.0-beta.16
238
+
239
+ ### Patch Changes
240
+
241
+ - 38fc777: Add AI Gateway hint to provider READMEs
242
+
243
+ ## 4.0.0-beta.15
244
+
245
+ ### Patch Changes
246
+
247
+ - f57c702: fix(anthropic): allow both temperature and topP for non-Anthropic models using the Anthropic-compatible API
248
+
249
+ 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.
250
+
251
+ ## 4.0.0-beta.14
252
+
253
+ ### Patch Changes
254
+
255
+ - Updated dependencies [2e17091]
256
+ - @ai-sdk/provider-utils@5.0.0-beta.9
257
+
258
+ ## 4.0.0-beta.13
259
+
260
+ ### Patch Changes
261
+
262
+ - Updated dependencies [986c6fd]
263
+ - Updated dependencies [493295c]
264
+ - @ai-sdk/provider-utils@5.0.0-beta.8
265
+
266
+ ## 4.0.0-beta.12
267
+
268
+ ### Patch Changes
269
+
270
+ - Updated dependencies [1f509d4]
271
+ - @ai-sdk/provider-utils@5.0.0-beta.7
272
+ - @ai-sdk/provider@4.0.0-beta.5
273
+
274
+ ## 4.0.0-beta.11
275
+
276
+ ### Patch Changes
277
+
278
+ - 0ee8aec: feat (provider/anthropic): support passing metadata.user_id
279
+
280
+ ## 4.0.0-beta.10
281
+
282
+ ### Patch Changes
283
+
284
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
285
+ - Updated dependencies [3887c70]
286
+ - @ai-sdk/provider-utils@5.0.0-beta.6
287
+ - @ai-sdk/provider@4.0.0-beta.4
288
+
289
+ ## 4.0.0-beta.9
290
+
291
+ ### Patch Changes
292
+
293
+ - Updated dependencies [776b617]
294
+ - @ai-sdk/provider-utils@5.0.0-beta.5
295
+ - @ai-sdk/provider@4.0.0-beta.3
296
+
3
297
  ## 4.0.0-beta.8
4
298
 
5
299
  ### Patch Changes
@@ -481,13 +775,13 @@
481
775
  Before
482
776
 
483
777
  ```ts
484
- model.textEmbeddingModel('my-model-id');
778
+ model.textEmbeddingModel("my-model-id");
485
779
  ```
486
780
 
487
781
  After
488
782
 
489
783
  ```ts
490
- model.embeddingModel('my-model-id');
784
+ model.embeddingModel("my-model-id");
491
785
  ```
492
786
 
493
787
  - f33a018: chore: add model ID for Haiku 4.5
@@ -827,13 +1121,13 @@
827
1121
  Before
828
1122
 
829
1123
  ```ts
830
- model.textEmbeddingModel('my-model-id');
1124
+ model.textEmbeddingModel("my-model-id");
831
1125
  ```
832
1126
 
833
1127
  After
834
1128
 
835
1129
  ```ts
836
- model.embeddingModel('my-model-id');
1130
+ model.embeddingModel("my-model-id");
837
1131
  ```
838
1132
 
839
1133
  - 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