@ai-sdk/anthropic 2.0.73 → 2.0.75
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 +13 -0
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +96 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -11
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +95 -10
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +95 -10
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -629,7 +629,13 @@ var anthropicProviderOptions = z3.object({
|
|
|
629
629
|
thinking: z3.discriminatedUnion("type", [
|
|
630
630
|
z3.object({
|
|
631
631
|
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
632
|
-
type: z3.literal("adaptive")
|
|
632
|
+
type: z3.literal("adaptive"),
|
|
633
|
+
/**
|
|
634
|
+
* Controls whether thinking content is included in the response.
|
|
635
|
+
* - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
|
|
636
|
+
* - `"summarized"`: Thinking content is returned. Required to see reasoning output.
|
|
637
|
+
*/
|
|
638
|
+
display: z3.enum(["omitted", "summarized"]).optional()
|
|
633
639
|
}),
|
|
634
640
|
z3.object({
|
|
635
641
|
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
@@ -685,7 +691,19 @@ var anthropicProviderOptions = z3.object({
|
|
|
685
691
|
/**
|
|
686
692
|
* @default 'high'
|
|
687
693
|
*/
|
|
688
|
-
effort: z3.enum(["low", "medium", "high", "max"]).optional(),
|
|
694
|
+
effort: z3.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
695
|
+
/**
|
|
696
|
+
* Task budget for agentic turns. Informs the model of the total token budget
|
|
697
|
+
* available for the current task, allowing it to prioritize work and wind down
|
|
698
|
+
* gracefully as the budget is consumed.
|
|
699
|
+
*
|
|
700
|
+
* Advisory only — does not enforce a hard token limit.
|
|
701
|
+
*/
|
|
702
|
+
taskBudget: z3.object({
|
|
703
|
+
type: z3.literal("tokens"),
|
|
704
|
+
total: z3.number().int().min(2e4),
|
|
705
|
+
remaining: z3.number().int().min(0).optional()
|
|
706
|
+
}).optional(),
|
|
689
707
|
/**
|
|
690
708
|
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
691
709
|
* Only supported with claude-opus-4-6.
|
|
@@ -1976,7 +1994,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1976
1994
|
toolChoice,
|
|
1977
1995
|
providerOptions
|
|
1978
1996
|
}) {
|
|
1979
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1997
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1980
1998
|
const warnings = [];
|
|
1981
1999
|
if (frequencyPenalty != null) {
|
|
1982
2000
|
warnings.push({
|
|
@@ -2034,8 +2052,36 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2034
2052
|
const {
|
|
2035
2053
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2036
2054
|
supportsStructuredOutput,
|
|
2055
|
+
rejectsSamplingParameters,
|
|
2037
2056
|
isKnownModel
|
|
2038
2057
|
} = getModelCapabilities(this.modelId);
|
|
2058
|
+
if (rejectsSamplingParameters) {
|
|
2059
|
+
if (temperature != null) {
|
|
2060
|
+
warnings.push({
|
|
2061
|
+
type: "unsupported-setting",
|
|
2062
|
+
setting: "temperature",
|
|
2063
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
2064
|
+
});
|
|
2065
|
+
temperature = void 0;
|
|
2066
|
+
}
|
|
2067
|
+
if (topK != null) {
|
|
2068
|
+
warnings.push({
|
|
2069
|
+
type: "unsupported-setting",
|
|
2070
|
+
setting: "topK",
|
|
2071
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
2072
|
+
});
|
|
2073
|
+
topK = void 0;
|
|
2074
|
+
}
|
|
2075
|
+
if (topP != null) {
|
|
2076
|
+
warnings.push({
|
|
2077
|
+
type: "unsupported-setting",
|
|
2078
|
+
setting: "topP",
|
|
2079
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
2080
|
+
});
|
|
2081
|
+
topP = void 0;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2039
2085
|
const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : "jsonTool";
|
|
2040
2086
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2041
2087
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
@@ -2054,6 +2100,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2054
2100
|
const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
|
|
2055
2101
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2056
2102
|
let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
|
|
2103
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.display : void 0;
|
|
2057
2104
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2058
2105
|
const baseArgs = {
|
|
2059
2106
|
// model id:
|
|
@@ -2068,11 +2115,31 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2068
2115
|
...isThinking && {
|
|
2069
2116
|
thinking: {
|
|
2070
2117
|
type: thinkingType,
|
|
2071
|
-
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
2118
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
2119
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
2072
2120
|
}
|
|
2073
2121
|
},
|
|
2074
|
-
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
2075
|
-
output_config: {
|
|
2122
|
+
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
2123
|
+
output_config: {
|
|
2124
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
2125
|
+
effort: anthropicOptions.effort
|
|
2126
|
+
},
|
|
2127
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
|
|
2128
|
+
task_budget: {
|
|
2129
|
+
type: anthropicOptions.taskBudget.type,
|
|
2130
|
+
total: anthropicOptions.taskBudget.total,
|
|
2131
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
2132
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
},
|
|
2136
|
+
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
2137
|
+
format: {
|
|
2138
|
+
type: "json_schema",
|
|
2139
|
+
schema: responseFormat.schema
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2076
2143
|
},
|
|
2077
2144
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
2078
2145
|
speed: anthropicOptions.speed
|
|
@@ -2080,7 +2147,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2080
2147
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
2081
2148
|
cache_control: anthropicOptions.cacheControl
|
|
2082
2149
|
},
|
|
2083
|
-
...((
|
|
2150
|
+
...((_f = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _f.userId) != null && {
|
|
2084
2151
|
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
2085
2152
|
},
|
|
2086
2153
|
// structured output:
|
|
@@ -2094,7 +2161,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2094
2161
|
...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
|
|
2095
2162
|
container: {
|
|
2096
2163
|
id: anthropicOptions.container.id,
|
|
2097
|
-
skills: (
|
|
2164
|
+
skills: (_g = anthropicOptions.container.skills) == null ? void 0 : _g.map((skill) => ({
|
|
2098
2165
|
type: skill.type,
|
|
2099
2166
|
skill_id: skill.skillId,
|
|
2100
2167
|
version: skill.version
|
|
@@ -2214,6 +2281,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2214
2281
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
2215
2282
|
betas.add("effort-2025-11-24");
|
|
2216
2283
|
}
|
|
2284
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
2285
|
+
betas.add("task-budgets-2026-03-13");
|
|
2286
|
+
}
|
|
2217
2287
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
2218
2288
|
betas.add("fast-mode-2026-02-01");
|
|
2219
2289
|
}
|
|
@@ -2257,7 +2327,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2257
2327
|
...betas,
|
|
2258
2328
|
...toolsBetas,
|
|
2259
2329
|
...userSuppliedBetas,
|
|
2260
|
-
...(
|
|
2330
|
+
...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
|
|
2261
2331
|
]),
|
|
2262
2332
|
usesJsonResponseTool: jsonResponseTool != null
|
|
2263
2333
|
};
|
|
@@ -3221,52 +3291,67 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3221
3291
|
}
|
|
3222
3292
|
};
|
|
3223
3293
|
function getModelCapabilities(modelId) {
|
|
3224
|
-
if (modelId.includes("claude-
|
|
3294
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
3295
|
+
return {
|
|
3296
|
+
maxOutputTokens: 128e3,
|
|
3297
|
+
supportsStructuredOutput: true,
|
|
3298
|
+
rejectsSamplingParameters: true,
|
|
3299
|
+
isKnownModel: true
|
|
3300
|
+
};
|
|
3301
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
3225
3302
|
return {
|
|
3226
3303
|
maxOutputTokens: 128e3,
|
|
3227
3304
|
supportsStructuredOutput: true,
|
|
3305
|
+
rejectsSamplingParameters: false,
|
|
3228
3306
|
isKnownModel: true
|
|
3229
3307
|
};
|
|
3230
3308
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
3231
3309
|
return {
|
|
3232
3310
|
maxOutputTokens: 64e3,
|
|
3233
3311
|
supportsStructuredOutput: true,
|
|
3312
|
+
rejectsSamplingParameters: false,
|
|
3234
3313
|
isKnownModel: true
|
|
3235
3314
|
};
|
|
3236
3315
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
3237
3316
|
return {
|
|
3238
3317
|
maxOutputTokens: 32e3,
|
|
3239
3318
|
supportsStructuredOutput: true,
|
|
3319
|
+
rejectsSamplingParameters: false,
|
|
3240
3320
|
isKnownModel: true
|
|
3241
3321
|
};
|
|
3242
3322
|
} else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
|
|
3243
3323
|
return {
|
|
3244
3324
|
maxOutputTokens: 64e3,
|
|
3245
3325
|
supportsStructuredOutput: false,
|
|
3326
|
+
rejectsSamplingParameters: false,
|
|
3246
3327
|
isKnownModel: true
|
|
3247
3328
|
};
|
|
3248
3329
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
3249
3330
|
return {
|
|
3250
3331
|
maxOutputTokens: 32e3,
|
|
3251
3332
|
supportsStructuredOutput: false,
|
|
3333
|
+
rejectsSamplingParameters: false,
|
|
3252
3334
|
isKnownModel: true
|
|
3253
3335
|
};
|
|
3254
3336
|
} else if (modelId.includes("claude-3-5-haiku")) {
|
|
3255
3337
|
return {
|
|
3256
3338
|
maxOutputTokens: 8192,
|
|
3257
3339
|
supportsStructuredOutput: false,
|
|
3340
|
+
rejectsSamplingParameters: false,
|
|
3258
3341
|
isKnownModel: true
|
|
3259
3342
|
};
|
|
3260
3343
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
3261
3344
|
return {
|
|
3262
3345
|
maxOutputTokens: 4096,
|
|
3263
3346
|
supportsStructuredOutput: false,
|
|
3347
|
+
rejectsSamplingParameters: false,
|
|
3264
3348
|
isKnownModel: true
|
|
3265
3349
|
};
|
|
3266
3350
|
} else {
|
|
3267
3351
|
return {
|
|
3268
3352
|
maxOutputTokens: 4096,
|
|
3269
3353
|
supportsStructuredOutput: false,
|
|
3354
|
+
rejectsSamplingParameters: false,
|
|
3270
3355
|
isKnownModel: false
|
|
3271
3356
|
};
|
|
3272
3357
|
}
|