@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.mjs
CHANGED
|
@@ -848,6 +848,20 @@ var anthropicLanguageModelOptions = z3.object({
|
|
|
848
848
|
type: z3.literal("ephemeral"),
|
|
849
849
|
ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
|
|
850
850
|
}).optional(),
|
|
851
|
+
/**
|
|
852
|
+
* Metadata to include with the request.
|
|
853
|
+
*
|
|
854
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
855
|
+
*/
|
|
856
|
+
metadata: z3.object({
|
|
857
|
+
/**
|
|
858
|
+
* An external identifier for the user associated with the request.
|
|
859
|
+
*
|
|
860
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
861
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
862
|
+
*/
|
|
863
|
+
userId: z3.string().optional()
|
|
864
|
+
}).optional(),
|
|
851
865
|
/**
|
|
852
866
|
* MCP servers to be utilized in this request.
|
|
853
867
|
*/
|
|
@@ -2899,7 +2913,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2899
2913
|
providerOptions,
|
|
2900
2914
|
stream
|
|
2901
2915
|
}) {
|
|
2902
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2916
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2903
2917
|
const warnings = [];
|
|
2904
2918
|
if (frequencyPenalty != null) {
|
|
2905
2919
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2956,6 +2970,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2956
2970
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
2957
2971
|
isKnownModel
|
|
2958
2972
|
} = getModelCapabilities(this.modelId);
|
|
2973
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2959
2974
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2960
2975
|
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2961
2976
|
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
@@ -3037,6 +3052,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3037
3052
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3038
3053
|
cache_control: anthropicOptions.cacheControl
|
|
3039
3054
|
},
|
|
3055
|
+
...((_g = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _g.userId) != null && {
|
|
3056
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3057
|
+
},
|
|
3040
3058
|
// mcp servers:
|
|
3041
3059
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3042
3060
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3160,7 +3178,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3160
3178
|
}
|
|
3161
3179
|
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
3162
3180
|
} else {
|
|
3163
|
-
if (topP != null && temperature != null) {
|
|
3181
|
+
if (isAnthropicModel && topP != null && temperature != null) {
|
|
3164
3182
|
warnings.push({
|
|
3165
3183
|
type: "unsupported",
|
|
3166
3184
|
feature: "topP",
|
|
@@ -3207,7 +3225,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3207
3225
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3208
3226
|
betas.add("fast-mode-2026-02-01");
|
|
3209
3227
|
}
|
|
3210
|
-
if (stream && ((
|
|
3228
|
+
if (stream && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _h : true)) {
|
|
3211
3229
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3212
3230
|
}
|
|
3213
3231
|
const {
|
|
@@ -3246,7 +3264,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3246
3264
|
...betas,
|
|
3247
3265
|
...toolsBetas,
|
|
3248
3266
|
...userSuppliedBetas,
|
|
3249
|
-
...(
|
|
3267
|
+
...(_i = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _i : []
|
|
3250
3268
|
]),
|
|
3251
3269
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3252
3270
|
toolNameMapping,
|