@ai-sdk/anthropic 3.0.63 → 3.0.65
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 +18 -4
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +22 -4
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +22 -4
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +6 -0
- package/package.json +1 -3
- package/src/anthropic-messages-language-model.ts +9 -2
- package/src/anthropic-messages-options.ts +17 -0
package/docs/05-anthropic.mdx
CHANGED
|
@@ -146,6 +146,12 @@ The following optional provider options are available for Anthropic models:
|
|
|
146
146
|
- `"jsonTool"`: Use a special `"json"` tool to specify the structured output format.
|
|
147
147
|
- `"auto"`: Use `"outputFormat"` when supported, otherwise fall back to `"jsonTool"` (default).
|
|
148
148
|
|
|
149
|
+
- `metadata` _object_
|
|
150
|
+
|
|
151
|
+
Optional. Metadata to include with the request. See the [Anthropic API documentation](https://platform.claude.com/docs/en/api/messages/create) for details.
|
|
152
|
+
|
|
153
|
+
- `userId` _string_ - An external identifier for the end-user. Should be a UUID, hash, or other opaque identifier. Must not contain PII.
|
|
154
|
+
|
|
149
155
|
### Structured Outputs and Tool Input Streaming
|
|
150
156
|
|
|
151
157
|
Tool call streaming is enabled by default. You can opt out by setting the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/anthropic",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.65",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -71,9 +71,7 @@
|
|
|
71
71
|
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
72
72
|
"build:watch": "pnpm clean && tsup --watch --tsconfig tsconfig.build.json",
|
|
73
73
|
"clean": "del-cli dist docs *.tsbuildinfo",
|
|
74
|
-
"lint": "eslint \"./**/*.ts*\"",
|
|
75
74
|
"type-check": "tsc --build",
|
|
76
|
-
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
|
77
75
|
"test": "pnpm test:node && pnpm test:edge",
|
|
78
76
|
"test:update": "pnpm test:node -u",
|
|
79
77
|
"test:watch": "vitest --config vitest.node.config.js",
|
|
@@ -272,6 +272,8 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
272
272
|
isKnownModel,
|
|
273
273
|
} = getModelCapabilities(this.modelId);
|
|
274
274
|
|
|
275
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith('claude-');
|
|
276
|
+
|
|
275
277
|
const supportsStructuredOutput =
|
|
276
278
|
(this.config.supportsNativeStructuredOutput ?? true) &&
|
|
277
279
|
modelSupportsStructuredOutput;
|
|
@@ -388,6 +390,9 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
388
390
|
...(anthropicOptions?.cacheControl && {
|
|
389
391
|
cache_control: anthropicOptions.cacheControl,
|
|
390
392
|
}),
|
|
393
|
+
...(anthropicOptions?.metadata?.userId != null && {
|
|
394
|
+
metadata: { user_id: anthropicOptions.metadata.userId },
|
|
395
|
+
}),
|
|
391
396
|
|
|
392
397
|
// mcp servers:
|
|
393
398
|
...(anthropicOptions?.mcpServers &&
|
|
@@ -532,8 +537,10 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
532
537
|
// adjust max tokens to account for thinking:
|
|
533
538
|
baseArgs.max_tokens = maxTokens + (thinkingBudget ?? 0);
|
|
534
539
|
} else {
|
|
535
|
-
// Only check temperature/topP mutual exclusivity
|
|
536
|
-
|
|
540
|
+
// Only check temperature/topP mutual exclusivity for known Anthropic models
|
|
541
|
+
// when thinking is not enabled. Non-Anthropic models using the Anthropic-compatible
|
|
542
|
+
// API (e.g. Minimax) may require both parameters to be set.
|
|
543
|
+
if (isAnthropicModel && topP != null && temperature != null) {
|
|
537
544
|
warnings.push({
|
|
538
545
|
type: 'unsupported',
|
|
539
546
|
feature: 'topP',
|
|
@@ -112,6 +112,23 @@ export const anthropicLanguageModelOptions = z.object({
|
|
|
112
112
|
})
|
|
113
113
|
.optional(),
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Metadata to include with the request.
|
|
117
|
+
*
|
|
118
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
119
|
+
*/
|
|
120
|
+
metadata: z
|
|
121
|
+
.object({
|
|
122
|
+
/**
|
|
123
|
+
* An external identifier for the user associated with the request.
|
|
124
|
+
*
|
|
125
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
126
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
127
|
+
*/
|
|
128
|
+
userId: z.string().optional(),
|
|
129
|
+
})
|
|
130
|
+
.optional(),
|
|
131
|
+
|
|
115
132
|
/**
|
|
116
133
|
* MCP servers to be utilized in this request.
|
|
117
134
|
*/
|