@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/dist/internal/index.js
CHANGED
|
@@ -861,6 +861,20 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
861
861
|
type: import_v43.z.literal("ephemeral"),
|
|
862
862
|
ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
|
|
863
863
|
}).optional(),
|
|
864
|
+
/**
|
|
865
|
+
* Metadata to include with the request.
|
|
866
|
+
*
|
|
867
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
868
|
+
*/
|
|
869
|
+
metadata: import_v43.z.object({
|
|
870
|
+
/**
|
|
871
|
+
* An external identifier for the user associated with the request.
|
|
872
|
+
*
|
|
873
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
874
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
875
|
+
*/
|
|
876
|
+
userId: import_v43.z.string().optional()
|
|
877
|
+
}).optional(),
|
|
864
878
|
/**
|
|
865
879
|
* MCP servers to be utilized in this request.
|
|
866
880
|
*/
|
|
@@ -2870,7 +2884,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2870
2884
|
providerOptions,
|
|
2871
2885
|
stream
|
|
2872
2886
|
}) {
|
|
2873
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2887
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2874
2888
|
const warnings = [];
|
|
2875
2889
|
if (frequencyPenalty != null) {
|
|
2876
2890
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2927,6 +2941,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2927
2941
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
2928
2942
|
isKnownModel
|
|
2929
2943
|
} = getModelCapabilities(this.modelId);
|
|
2944
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2930
2945
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2931
2946
|
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2932
2947
|
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
@@ -3008,6 +3023,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3008
3023
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3009
3024
|
cache_control: anthropicOptions.cacheControl
|
|
3010
3025
|
},
|
|
3026
|
+
...((_g = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _g.userId) != null && {
|
|
3027
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3028
|
+
},
|
|
3011
3029
|
// mcp servers:
|
|
3012
3030
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3013
3031
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3131,7 +3149,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3131
3149
|
}
|
|
3132
3150
|
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
3133
3151
|
} else {
|
|
3134
|
-
if (topP != null && temperature != null) {
|
|
3152
|
+
if (isAnthropicModel && topP != null && temperature != null) {
|
|
3135
3153
|
warnings.push({
|
|
3136
3154
|
type: "unsupported",
|
|
3137
3155
|
feature: "topP",
|
|
@@ -3178,7 +3196,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3178
3196
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3179
3197
|
betas.add("fast-mode-2026-02-01");
|
|
3180
3198
|
}
|
|
3181
|
-
if (stream && ((
|
|
3199
|
+
if (stream && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _h : true)) {
|
|
3182
3200
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3183
3201
|
}
|
|
3184
3202
|
const {
|
|
@@ -3217,7 +3235,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3217
3235
|
...betas,
|
|
3218
3236
|
...toolsBetas,
|
|
3219
3237
|
...userSuppliedBetas,
|
|
3220
|
-
...(
|
|
3238
|
+
...(_i = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _i : []
|
|
3221
3239
|
]),
|
|
3222
3240
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3223
3241
|
toolNameMapping,
|