@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/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "@ai-sdk/provider-utils";
|
|
12
12
|
|
|
13
13
|
// src/version.ts
|
|
14
|
-
var VERSION = true ? "2.0.
|
|
14
|
+
var VERSION = true ? "2.0.75" : "0.0.0-test";
|
|
15
15
|
|
|
16
16
|
// src/anthropic-messages-language-model.ts
|
|
17
17
|
import {
|
|
@@ -644,7 +644,13 @@ var anthropicProviderOptions = z3.object({
|
|
|
644
644
|
thinking: z3.discriminatedUnion("type", [
|
|
645
645
|
z3.object({
|
|
646
646
|
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
647
|
-
type: z3.literal("adaptive")
|
|
647
|
+
type: z3.literal("adaptive"),
|
|
648
|
+
/**
|
|
649
|
+
* Controls whether thinking content is included in the response.
|
|
650
|
+
* - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
|
|
651
|
+
* - `"summarized"`: Thinking content is returned. Required to see reasoning output.
|
|
652
|
+
*/
|
|
653
|
+
display: z3.enum(["omitted", "summarized"]).optional()
|
|
648
654
|
}),
|
|
649
655
|
z3.object({
|
|
650
656
|
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
@@ -700,7 +706,19 @@ var anthropicProviderOptions = z3.object({
|
|
|
700
706
|
/**
|
|
701
707
|
* @default 'high'
|
|
702
708
|
*/
|
|
703
|
-
effort: z3.enum(["low", "medium", "high", "max"]).optional(),
|
|
709
|
+
effort: z3.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
710
|
+
/**
|
|
711
|
+
* Task budget for agentic turns. Informs the model of the total token budget
|
|
712
|
+
* available for the current task, allowing it to prioritize work and wind down
|
|
713
|
+
* gracefully as the budget is consumed.
|
|
714
|
+
*
|
|
715
|
+
* Advisory only — does not enforce a hard token limit.
|
|
716
|
+
*/
|
|
717
|
+
taskBudget: z3.object({
|
|
718
|
+
type: z3.literal("tokens"),
|
|
719
|
+
total: z3.number().int().min(2e4),
|
|
720
|
+
remaining: z3.number().int().min(0).optional()
|
|
721
|
+
}).optional(),
|
|
704
722
|
/**
|
|
705
723
|
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
706
724
|
* Only supported with claude-opus-4-6.
|
|
@@ -1991,7 +2009,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1991
2009
|
toolChoice,
|
|
1992
2010
|
providerOptions
|
|
1993
2011
|
}) {
|
|
1994
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2012
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1995
2013
|
const warnings = [];
|
|
1996
2014
|
if (frequencyPenalty != null) {
|
|
1997
2015
|
warnings.push({
|
|
@@ -2049,8 +2067,36 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2049
2067
|
const {
|
|
2050
2068
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2051
2069
|
supportsStructuredOutput,
|
|
2070
|
+
rejectsSamplingParameters,
|
|
2052
2071
|
isKnownModel
|
|
2053
2072
|
} = getModelCapabilities(this.modelId);
|
|
2073
|
+
if (rejectsSamplingParameters) {
|
|
2074
|
+
if (temperature != null) {
|
|
2075
|
+
warnings.push({
|
|
2076
|
+
type: "unsupported-setting",
|
|
2077
|
+
setting: "temperature",
|
|
2078
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
2079
|
+
});
|
|
2080
|
+
temperature = void 0;
|
|
2081
|
+
}
|
|
2082
|
+
if (topK != null) {
|
|
2083
|
+
warnings.push({
|
|
2084
|
+
type: "unsupported-setting",
|
|
2085
|
+
setting: "topK",
|
|
2086
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
2087
|
+
});
|
|
2088
|
+
topK = void 0;
|
|
2089
|
+
}
|
|
2090
|
+
if (topP != null) {
|
|
2091
|
+
warnings.push({
|
|
2092
|
+
type: "unsupported-setting",
|
|
2093
|
+
setting: "topP",
|
|
2094
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
2095
|
+
});
|
|
2096
|
+
topP = void 0;
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2054
2100
|
const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : "jsonTool";
|
|
2055
2101
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2056
2102
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
@@ -2069,6 +2115,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2069
2115
|
const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
|
|
2070
2116
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2071
2117
|
let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
|
|
2118
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.display : void 0;
|
|
2072
2119
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2073
2120
|
const baseArgs = {
|
|
2074
2121
|
// model id:
|
|
@@ -2083,11 +2130,31 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2083
2130
|
...isThinking && {
|
|
2084
2131
|
thinking: {
|
|
2085
2132
|
type: thinkingType,
|
|
2086
|
-
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
2133
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
2134
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
2087
2135
|
}
|
|
2088
2136
|
},
|
|
2089
|
-
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
2090
|
-
output_config: {
|
|
2137
|
+
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
2138
|
+
output_config: {
|
|
2139
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
2140
|
+
effort: anthropicOptions.effort
|
|
2141
|
+
},
|
|
2142
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
|
|
2143
|
+
task_budget: {
|
|
2144
|
+
type: anthropicOptions.taskBudget.type,
|
|
2145
|
+
total: anthropicOptions.taskBudget.total,
|
|
2146
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
2147
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
},
|
|
2151
|
+
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
2152
|
+
format: {
|
|
2153
|
+
type: "json_schema",
|
|
2154
|
+
schema: responseFormat.schema
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2091
2158
|
},
|
|
2092
2159
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
2093
2160
|
speed: anthropicOptions.speed
|
|
@@ -2095,7 +2162,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2095
2162
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
2096
2163
|
cache_control: anthropicOptions.cacheControl
|
|
2097
2164
|
},
|
|
2098
|
-
...((
|
|
2165
|
+
...((_f = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _f.userId) != null && {
|
|
2099
2166
|
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
2100
2167
|
},
|
|
2101
2168
|
// structured output:
|
|
@@ -2109,7 +2176,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2109
2176
|
...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
|
|
2110
2177
|
container: {
|
|
2111
2178
|
id: anthropicOptions.container.id,
|
|
2112
|
-
skills: (
|
|
2179
|
+
skills: (_g = anthropicOptions.container.skills) == null ? void 0 : _g.map((skill) => ({
|
|
2113
2180
|
type: skill.type,
|
|
2114
2181
|
skill_id: skill.skillId,
|
|
2115
2182
|
version: skill.version
|
|
@@ -2229,6 +2296,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2229
2296
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
2230
2297
|
betas.add("effort-2025-11-24");
|
|
2231
2298
|
}
|
|
2299
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
2300
|
+
betas.add("task-budgets-2026-03-13");
|
|
2301
|
+
}
|
|
2232
2302
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
2233
2303
|
betas.add("fast-mode-2026-02-01");
|
|
2234
2304
|
}
|
|
@@ -2272,7 +2342,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2272
2342
|
...betas,
|
|
2273
2343
|
...toolsBetas,
|
|
2274
2344
|
...userSuppliedBetas,
|
|
2275
|
-
...(
|
|
2345
|
+
...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
|
|
2276
2346
|
]),
|
|
2277
2347
|
usesJsonResponseTool: jsonResponseTool != null
|
|
2278
2348
|
};
|
|
@@ -3236,52 +3306,67 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3236
3306
|
}
|
|
3237
3307
|
};
|
|
3238
3308
|
function getModelCapabilities(modelId) {
|
|
3239
|
-
if (modelId.includes("claude-
|
|
3309
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
3310
|
+
return {
|
|
3311
|
+
maxOutputTokens: 128e3,
|
|
3312
|
+
supportsStructuredOutput: true,
|
|
3313
|
+
rejectsSamplingParameters: true,
|
|
3314
|
+
isKnownModel: true
|
|
3315
|
+
};
|
|
3316
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
3240
3317
|
return {
|
|
3241
3318
|
maxOutputTokens: 128e3,
|
|
3242
3319
|
supportsStructuredOutput: true,
|
|
3320
|
+
rejectsSamplingParameters: false,
|
|
3243
3321
|
isKnownModel: true
|
|
3244
3322
|
};
|
|
3245
3323
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
3246
3324
|
return {
|
|
3247
3325
|
maxOutputTokens: 64e3,
|
|
3248
3326
|
supportsStructuredOutput: true,
|
|
3327
|
+
rejectsSamplingParameters: false,
|
|
3249
3328
|
isKnownModel: true
|
|
3250
3329
|
};
|
|
3251
3330
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
3252
3331
|
return {
|
|
3253
3332
|
maxOutputTokens: 32e3,
|
|
3254
3333
|
supportsStructuredOutput: true,
|
|
3334
|
+
rejectsSamplingParameters: false,
|
|
3255
3335
|
isKnownModel: true
|
|
3256
3336
|
};
|
|
3257
3337
|
} else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
|
|
3258
3338
|
return {
|
|
3259
3339
|
maxOutputTokens: 64e3,
|
|
3260
3340
|
supportsStructuredOutput: false,
|
|
3341
|
+
rejectsSamplingParameters: false,
|
|
3261
3342
|
isKnownModel: true
|
|
3262
3343
|
};
|
|
3263
3344
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
3264
3345
|
return {
|
|
3265
3346
|
maxOutputTokens: 32e3,
|
|
3266
3347
|
supportsStructuredOutput: false,
|
|
3348
|
+
rejectsSamplingParameters: false,
|
|
3267
3349
|
isKnownModel: true
|
|
3268
3350
|
};
|
|
3269
3351
|
} else if (modelId.includes("claude-3-5-haiku")) {
|
|
3270
3352
|
return {
|
|
3271
3353
|
maxOutputTokens: 8192,
|
|
3272
3354
|
supportsStructuredOutput: false,
|
|
3355
|
+
rejectsSamplingParameters: false,
|
|
3273
3356
|
isKnownModel: true
|
|
3274
3357
|
};
|
|
3275
3358
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
3276
3359
|
return {
|
|
3277
3360
|
maxOutputTokens: 4096,
|
|
3278
3361
|
supportsStructuredOutput: false,
|
|
3362
|
+
rejectsSamplingParameters: false,
|
|
3279
3363
|
isKnownModel: true
|
|
3280
3364
|
};
|
|
3281
3365
|
} else {
|
|
3282
3366
|
return {
|
|
3283
3367
|
maxOutputTokens: 4096,
|
|
3284
3368
|
supportsStructuredOutput: false,
|
|
3369
|
+
rejectsSamplingParameters: false,
|
|
3285
3370
|
isKnownModel: false
|
|
3286
3371
|
};
|
|
3287
3372
|
}
|