@ai-sdk/anthropic 2.0.74 → 2.0.76
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 +12 -0
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +108 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -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 +107 -10
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +107 -10
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
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.76" : "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,12 +706,33 @@ 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.
|
|
707
725
|
*/
|
|
708
726
|
speed: z3.enum(["fast", "standard"]).optional(),
|
|
727
|
+
/**
|
|
728
|
+
* Controls where model inference runs for this request.
|
|
729
|
+
*
|
|
730
|
+
* - `"global"`: Inference may run in any available geography (default).
|
|
731
|
+
* - `"us"`: Inference runs only in US-based infrastructure.
|
|
732
|
+
*
|
|
733
|
+
* See https://platform.claude.com/docs/en/build-with-claude/data-residency
|
|
734
|
+
*/
|
|
735
|
+
inferenceGeo: z3.enum(["us", "global"]).optional(),
|
|
709
736
|
/**
|
|
710
737
|
* Context management configuration for automatic context window management.
|
|
711
738
|
* Enables features like automatic compaction and clearing of tool uses/thinking blocks.
|
|
@@ -1991,7 +2018,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1991
2018
|
toolChoice,
|
|
1992
2019
|
providerOptions
|
|
1993
2020
|
}) {
|
|
1994
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2021
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1995
2022
|
const warnings = [];
|
|
1996
2023
|
if (frequencyPenalty != null) {
|
|
1997
2024
|
warnings.push({
|
|
@@ -2049,8 +2076,36 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2049
2076
|
const {
|
|
2050
2077
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2051
2078
|
supportsStructuredOutput,
|
|
2079
|
+
rejectsSamplingParameters,
|
|
2052
2080
|
isKnownModel
|
|
2053
2081
|
} = getModelCapabilities(this.modelId);
|
|
2082
|
+
if (rejectsSamplingParameters) {
|
|
2083
|
+
if (temperature != null) {
|
|
2084
|
+
warnings.push({
|
|
2085
|
+
type: "unsupported-setting",
|
|
2086
|
+
setting: "temperature",
|
|
2087
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
2088
|
+
});
|
|
2089
|
+
temperature = void 0;
|
|
2090
|
+
}
|
|
2091
|
+
if (topK != null) {
|
|
2092
|
+
warnings.push({
|
|
2093
|
+
type: "unsupported-setting",
|
|
2094
|
+
setting: "topK",
|
|
2095
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
2096
|
+
});
|
|
2097
|
+
topK = void 0;
|
|
2098
|
+
}
|
|
2099
|
+
if (topP != null) {
|
|
2100
|
+
warnings.push({
|
|
2101
|
+
type: "unsupported-setting",
|
|
2102
|
+
setting: "topP",
|
|
2103
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
2104
|
+
});
|
|
2105
|
+
topP = void 0;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2054
2109
|
const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : "jsonTool";
|
|
2055
2110
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2056
2111
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
@@ -2069,6 +2124,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2069
2124
|
const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
|
|
2070
2125
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2071
2126
|
let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
|
|
2127
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.display : void 0;
|
|
2072
2128
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2073
2129
|
const baseArgs = {
|
|
2074
2130
|
// model id:
|
|
@@ -2083,19 +2139,42 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2083
2139
|
...isThinking && {
|
|
2084
2140
|
thinking: {
|
|
2085
2141
|
type: thinkingType,
|
|
2086
|
-
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
2142
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
2143
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
2087
2144
|
}
|
|
2088
2145
|
},
|
|
2089
|
-
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
2090
|
-
output_config: {
|
|
2146
|
+
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
2147
|
+
output_config: {
|
|
2148
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
2149
|
+
effort: anthropicOptions.effort
|
|
2150
|
+
},
|
|
2151
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
|
|
2152
|
+
task_budget: {
|
|
2153
|
+
type: anthropicOptions.taskBudget.type,
|
|
2154
|
+
total: anthropicOptions.taskBudget.total,
|
|
2155
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
2156
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
},
|
|
2160
|
+
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
2161
|
+
format: {
|
|
2162
|
+
type: "json_schema",
|
|
2163
|
+
schema: responseFormat.schema
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2091
2167
|
},
|
|
2092
2168
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
2093
2169
|
speed: anthropicOptions.speed
|
|
2094
2170
|
},
|
|
2171
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
|
|
2172
|
+
inference_geo: anthropicOptions.inferenceGeo
|
|
2173
|
+
},
|
|
2095
2174
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
2096
2175
|
cache_control: anthropicOptions.cacheControl
|
|
2097
2176
|
},
|
|
2098
|
-
...((
|
|
2177
|
+
...((_f = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _f.userId) != null && {
|
|
2099
2178
|
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
2100
2179
|
},
|
|
2101
2180
|
// structured output:
|
|
@@ -2109,7 +2188,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2109
2188
|
...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
|
|
2110
2189
|
container: {
|
|
2111
2190
|
id: anthropicOptions.container.id,
|
|
2112
|
-
skills: (
|
|
2191
|
+
skills: (_g = anthropicOptions.container.skills) == null ? void 0 : _g.map((skill) => ({
|
|
2113
2192
|
type: skill.type,
|
|
2114
2193
|
skill_id: skill.skillId,
|
|
2115
2194
|
version: skill.version
|
|
@@ -2229,6 +2308,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2229
2308
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
2230
2309
|
betas.add("effort-2025-11-24");
|
|
2231
2310
|
}
|
|
2311
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
2312
|
+
betas.add("task-budgets-2026-03-13");
|
|
2313
|
+
}
|
|
2232
2314
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
2233
2315
|
betas.add("fast-mode-2026-02-01");
|
|
2234
2316
|
}
|
|
@@ -2272,7 +2354,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2272
2354
|
...betas,
|
|
2273
2355
|
...toolsBetas,
|
|
2274
2356
|
...userSuppliedBetas,
|
|
2275
|
-
...(
|
|
2357
|
+
...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
|
|
2276
2358
|
]),
|
|
2277
2359
|
usesJsonResponseTool: jsonResponseTool != null
|
|
2278
2360
|
};
|
|
@@ -3236,52 +3318,67 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3236
3318
|
}
|
|
3237
3319
|
};
|
|
3238
3320
|
function getModelCapabilities(modelId) {
|
|
3239
|
-
if (modelId.includes("claude-
|
|
3321
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
3322
|
+
return {
|
|
3323
|
+
maxOutputTokens: 128e3,
|
|
3324
|
+
supportsStructuredOutput: true,
|
|
3325
|
+
rejectsSamplingParameters: true,
|
|
3326
|
+
isKnownModel: true
|
|
3327
|
+
};
|
|
3328
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
3240
3329
|
return {
|
|
3241
3330
|
maxOutputTokens: 128e3,
|
|
3242
3331
|
supportsStructuredOutput: true,
|
|
3332
|
+
rejectsSamplingParameters: false,
|
|
3243
3333
|
isKnownModel: true
|
|
3244
3334
|
};
|
|
3245
3335
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
3246
3336
|
return {
|
|
3247
3337
|
maxOutputTokens: 64e3,
|
|
3248
3338
|
supportsStructuredOutput: true,
|
|
3339
|
+
rejectsSamplingParameters: false,
|
|
3249
3340
|
isKnownModel: true
|
|
3250
3341
|
};
|
|
3251
3342
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
3252
3343
|
return {
|
|
3253
3344
|
maxOutputTokens: 32e3,
|
|
3254
3345
|
supportsStructuredOutput: true,
|
|
3346
|
+
rejectsSamplingParameters: false,
|
|
3255
3347
|
isKnownModel: true
|
|
3256
3348
|
};
|
|
3257
3349
|
} else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
|
|
3258
3350
|
return {
|
|
3259
3351
|
maxOutputTokens: 64e3,
|
|
3260
3352
|
supportsStructuredOutput: false,
|
|
3353
|
+
rejectsSamplingParameters: false,
|
|
3261
3354
|
isKnownModel: true
|
|
3262
3355
|
};
|
|
3263
3356
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
3264
3357
|
return {
|
|
3265
3358
|
maxOutputTokens: 32e3,
|
|
3266
3359
|
supportsStructuredOutput: false,
|
|
3360
|
+
rejectsSamplingParameters: false,
|
|
3267
3361
|
isKnownModel: true
|
|
3268
3362
|
};
|
|
3269
3363
|
} else if (modelId.includes("claude-3-5-haiku")) {
|
|
3270
3364
|
return {
|
|
3271
3365
|
maxOutputTokens: 8192,
|
|
3272
3366
|
supportsStructuredOutput: false,
|
|
3367
|
+
rejectsSamplingParameters: false,
|
|
3273
3368
|
isKnownModel: true
|
|
3274
3369
|
};
|
|
3275
3370
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
3276
3371
|
return {
|
|
3277
3372
|
maxOutputTokens: 4096,
|
|
3278
3373
|
supportsStructuredOutput: false,
|
|
3374
|
+
rejectsSamplingParameters: false,
|
|
3279
3375
|
isKnownModel: true
|
|
3280
3376
|
};
|
|
3281
3377
|
} else {
|
|
3282
3378
|
return {
|
|
3283
3379
|
maxOutputTokens: 4096,
|
|
3284
3380
|
supportsStructuredOutput: false,
|
|
3381
|
+
rejectsSamplingParameters: false,
|
|
3285
3382
|
isKnownModel: false
|
|
3286
3383
|
};
|
|
3287
3384
|
}
|