@ai-sdk/anthropic 3.0.41 → 3.0.42
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 +6 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +3 -3
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +3 -3
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +14 -14
- package/package.json +1 -1
- package/src/anthropic-messages-language-model.ts +3 -3
- package/src/anthropic-messages-options.ts +4 -2
- package/src/index.ts +5 -1
package/docs/05-anthropic.mdx
CHANGED
|
@@ -175,7 +175,7 @@ const result = streamText({
|
|
|
175
175
|
Anthropic introduced an `effort` option with `claude-opus-4-5` that affects thinking, text responses, and function calls. Effort defaults to `high` and you can set it to `medium` or `low` to save tokens and to lower time-to-last-token latency (TTLT).
|
|
176
176
|
|
|
177
177
|
```ts highlight="8-10"
|
|
178
|
-
import { anthropic,
|
|
178
|
+
import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
|
|
179
179
|
import { generateText } from 'ai';
|
|
180
180
|
|
|
181
181
|
const { text, usage } = await generateText({
|
|
@@ -184,7 +184,7 @@ const { text, usage } = await generateText({
|
|
|
184
184
|
providerOptions: {
|
|
185
185
|
anthropic: {
|
|
186
186
|
effort: 'low',
|
|
187
|
-
} satisfies
|
|
187
|
+
} satisfies AnthropicLanguageModelOptions,
|
|
188
188
|
},
|
|
189
189
|
});
|
|
190
190
|
|
|
@@ -200,7 +200,7 @@ You can enable it using the `thinking` provider option
|
|
|
200
200
|
and specifying a thinking budget in tokens.
|
|
201
201
|
|
|
202
202
|
```ts highlight="4,8-10"
|
|
203
|
-
import { anthropic,
|
|
203
|
+
import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
|
|
204
204
|
import { generateText } from 'ai';
|
|
205
205
|
|
|
206
206
|
const { text, reasoningText, reasoning } = await generateText({
|
|
@@ -209,7 +209,7 @@ const { text, reasoningText, reasoning } = await generateText({
|
|
|
209
209
|
providerOptions: {
|
|
210
210
|
anthropic: {
|
|
211
211
|
thinking: { type: 'enabled', budgetTokens: 12000 },
|
|
212
|
-
} satisfies
|
|
212
|
+
} satisfies AnthropicLanguageModelOptions,
|
|
213
213
|
},
|
|
214
214
|
});
|
|
215
215
|
|
|
@@ -228,7 +228,7 @@ Anthropic's Context Management feature allows you to automatically manage conver
|
|
|
228
228
|
You can configure context management using the `contextManagement` provider option:
|
|
229
229
|
|
|
230
230
|
```ts highlight="7-20"
|
|
231
|
-
import { anthropic,
|
|
231
|
+
import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
|
|
232
232
|
import { generateText } from 'ai';
|
|
233
233
|
|
|
234
234
|
const result = await generateText({
|
|
@@ -248,7 +248,7 @@ const result = await generateText({
|
|
|
248
248
|
},
|
|
249
249
|
],
|
|
250
250
|
},
|
|
251
|
-
} satisfies
|
|
251
|
+
} satisfies AnthropicLanguageModelOptions,
|
|
252
252
|
},
|
|
253
253
|
});
|
|
254
254
|
|
|
@@ -285,7 +285,7 @@ const result = await generateText({
|
|
|
285
285
|
},
|
|
286
286
|
],
|
|
287
287
|
},
|
|
288
|
-
} satisfies
|
|
288
|
+
} satisfies AnthropicLanguageModelOptions,
|
|
289
289
|
},
|
|
290
290
|
});
|
|
291
291
|
```
|
|
@@ -295,7 +295,7 @@ const result = await generateText({
|
|
|
295
295
|
The `compact_20260112` edit type automatically summarizes earlier conversation context when token limits are reached. This is useful for long-running conversations where you want to preserve the essence of earlier exchanges while staying within token limits.
|
|
296
296
|
|
|
297
297
|
```ts highlight="7-19"
|
|
298
|
-
import { anthropic,
|
|
298
|
+
import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
|
|
299
299
|
import { streamText } from 'ai';
|
|
300
300
|
|
|
301
301
|
const result = streamText({
|
|
@@ -317,7 +317,7 @@ const result = streamText({
|
|
|
317
317
|
},
|
|
318
318
|
],
|
|
319
319
|
},
|
|
320
|
-
} satisfies
|
|
320
|
+
} satisfies AnthropicLanguageModelOptions,
|
|
321
321
|
},
|
|
322
322
|
});
|
|
323
323
|
```
|
|
@@ -898,7 +898,7 @@ Anthropic supports connecting to [MCP servers](https://docs.claude.com/en/docs/a
|
|
|
898
898
|
You can enable this feature with the `mcpServers` provider option:
|
|
899
899
|
|
|
900
900
|
```ts
|
|
901
|
-
import { anthropic,
|
|
901
|
+
import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
|
|
902
902
|
import { generateText } from 'ai';
|
|
903
903
|
|
|
904
904
|
const result = await generateText({
|
|
@@ -920,7 +920,7 @@ const result = await generateText({
|
|
|
920
920
|
},
|
|
921
921
|
},
|
|
922
922
|
],
|
|
923
|
-
} satisfies
|
|
923
|
+
} satisfies AnthropicLanguageModelOptions,
|
|
924
924
|
},
|
|
925
925
|
});
|
|
926
926
|
```
|
|
@@ -1150,7 +1150,7 @@ To use skills, you need to:
|
|
|
1150
1150
|
2. Specify the container with skills in `providerOptions`
|
|
1151
1151
|
|
|
1152
1152
|
```ts highlight="4,9-17,19-23"
|
|
1153
|
-
import { anthropic,
|
|
1153
|
+
import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
|
|
1154
1154
|
import { generateText } from 'ai';
|
|
1155
1155
|
|
|
1156
1156
|
const result = await generateText({
|
|
@@ -1170,7 +1170,7 @@ const result = await generateText({
|
|
|
1170
1170
|
},
|
|
1171
1171
|
],
|
|
1172
1172
|
},
|
|
1173
|
-
} satisfies
|
|
1173
|
+
} satisfies AnthropicLanguageModelOptions,
|
|
1174
1174
|
},
|
|
1175
1175
|
});
|
|
1176
1176
|
```
|
|
@@ -1197,7 +1197,7 @@ const result = await generateText({
|
|
|
1197
1197
|
},
|
|
1198
1198
|
],
|
|
1199
1199
|
},
|
|
1200
|
-
} satisfies
|
|
1200
|
+
} satisfies AnthropicLanguageModelOptions,
|
|
1201
1201
|
},
|
|
1202
1202
|
});
|
|
1203
1203
|
```
|
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
} from './anthropic-messages-api';
|
|
42
42
|
import {
|
|
43
43
|
AnthropicMessagesModelId,
|
|
44
|
-
|
|
44
|
+
anthropicLanguageModelOptions,
|
|
45
45
|
} from './anthropic-messages-options';
|
|
46
46
|
import { prepareTools } from './anthropic-prepare-tools';
|
|
47
47
|
import {
|
|
@@ -234,7 +234,7 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
234
234
|
const canonicalOptions = await parseProviderOptions({
|
|
235
235
|
provider: 'anthropic',
|
|
236
236
|
providerOptions,
|
|
237
|
-
schema:
|
|
237
|
+
schema: anthropicLanguageModelOptions,
|
|
238
238
|
});
|
|
239
239
|
|
|
240
240
|
const customProviderOptions =
|
|
@@ -242,7 +242,7 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
242
242
|
? await parseProviderOptions({
|
|
243
243
|
provider: providerOptionsName,
|
|
244
244
|
providerOptions,
|
|
245
|
-
schema:
|
|
245
|
+
schema: anthropicLanguageModelOptions,
|
|
246
246
|
})
|
|
247
247
|
: null;
|
|
248
248
|
|
|
@@ -58,7 +58,7 @@ export type AnthropicFilePartProviderOptions = z.infer<
|
|
|
58
58
|
typeof anthropicFilePartProviderOptions
|
|
59
59
|
>;
|
|
60
60
|
|
|
61
|
-
export const
|
|
61
|
+
export const anthropicLanguageModelOptions = z.object({
|
|
62
62
|
/**
|
|
63
63
|
* Whether to send reasoning to the model.
|
|
64
64
|
*
|
|
@@ -238,4 +238,6 @@ export const anthropicProviderOptions = z.object({
|
|
|
238
238
|
.optional(),
|
|
239
239
|
});
|
|
240
240
|
|
|
241
|
-
export type
|
|
241
|
+
export type AnthropicLanguageModelOptions = z.infer<
|
|
242
|
+
typeof anthropicLanguageModelOptions
|
|
243
|
+
>;
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,11 @@ export type {
|
|
|
2
2
|
AnthropicMessageMetadata,
|
|
3
3
|
AnthropicUsageIteration,
|
|
4
4
|
} from './anthropic-message-metadata';
|
|
5
|
-
export type {
|
|
5
|
+
export type {
|
|
6
|
+
AnthropicLanguageModelOptions,
|
|
7
|
+
/** @deprecated Use `AnthropicLanguageModelOptions` instead. */
|
|
8
|
+
AnthropicLanguageModelOptions as AnthropicProviderOptions,
|
|
9
|
+
} from './anthropic-messages-options';
|
|
6
10
|
export type { AnthropicToolOptions } from './anthropic-prepare-tools';
|
|
7
11
|
export { anthropic, createAnthropic } from './anthropic-provider';
|
|
8
12
|
export type {
|