@ai-sdk/anthropic 3.0.69 → 3.0.70
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 +6 -0
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +83 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -10
- 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 +82 -9
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +82 -9
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +72 -2
- package/package.json +1 -1
- package/src/anthropic-messages-language-model.ts +63 -1
- package/src/anthropic-messages-options.ts +23 -1
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "@ai-sdk/provider-utils";
|
|
13
13
|
|
|
14
14
|
// src/version.ts
|
|
15
|
-
var VERSION = true ? "3.0.
|
|
15
|
+
var VERSION = true ? "3.0.70" : "0.0.0-test";
|
|
16
16
|
|
|
17
17
|
// src/anthropic-messages-language-model.ts
|
|
18
18
|
import {
|
|
@@ -840,7 +840,13 @@ var anthropicLanguageModelOptions = z3.object({
|
|
|
840
840
|
thinking: z3.discriminatedUnion("type", [
|
|
841
841
|
z3.object({
|
|
842
842
|
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
843
|
-
type: z3.literal("adaptive")
|
|
843
|
+
type: z3.literal("adaptive"),
|
|
844
|
+
/**
|
|
845
|
+
* Controls whether thinking content is included in the response.
|
|
846
|
+
* - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
|
|
847
|
+
* - `"summarized"`: Thinking content is returned. Required to see reasoning output.
|
|
848
|
+
*/
|
|
849
|
+
display: z3.enum(["omitted", "summarized"]).optional()
|
|
844
850
|
}),
|
|
845
851
|
z3.object({
|
|
846
852
|
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
@@ -920,7 +926,19 @@ var anthropicLanguageModelOptions = z3.object({
|
|
|
920
926
|
/**
|
|
921
927
|
* @default 'high'
|
|
922
928
|
*/
|
|
923
|
-
effort: z3.enum(["low", "medium", "high", "max"]).optional(),
|
|
929
|
+
effort: z3.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
930
|
+
/**
|
|
931
|
+
* Task budget for agentic turns. Informs the model of the total token budget
|
|
932
|
+
* available for the current task, allowing it to prioritize work and wind down
|
|
933
|
+
* gracefully as the budget is consumed.
|
|
934
|
+
*
|
|
935
|
+
* Advisory only — does not enforce a hard token limit.
|
|
936
|
+
*/
|
|
937
|
+
taskBudget: z3.object({
|
|
938
|
+
type: z3.literal("tokens"),
|
|
939
|
+
total: z3.number().int().min(2e4),
|
|
940
|
+
remaining: z3.number().int().min(0).optional()
|
|
941
|
+
}).optional(),
|
|
924
942
|
/**
|
|
925
943
|
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
926
944
|
* Only supported with claude-opus-4-6.
|
|
@@ -2938,7 +2956,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2938
2956
|
providerOptions,
|
|
2939
2957
|
stream
|
|
2940
2958
|
}) {
|
|
2941
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2959
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2942
2960
|
const warnings = [];
|
|
2943
2961
|
if (frequencyPenalty != null) {
|
|
2944
2962
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2993,8 +3011,35 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2993
3011
|
const {
|
|
2994
3012
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2995
3013
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
3014
|
+
rejectsSamplingParameters,
|
|
2996
3015
|
isKnownModel
|
|
2997
3016
|
} = getModelCapabilities(this.modelId);
|
|
3017
|
+
if (rejectsSamplingParameters) {
|
|
3018
|
+
if (temperature != null) {
|
|
3019
|
+
warnings.push({
|
|
3020
|
+
type: "unsupported",
|
|
3021
|
+
feature: "temperature",
|
|
3022
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
3023
|
+
});
|
|
3024
|
+
temperature = void 0;
|
|
3025
|
+
}
|
|
3026
|
+
if (topK != null) {
|
|
3027
|
+
warnings.push({
|
|
3028
|
+
type: "unsupported",
|
|
3029
|
+
feature: "topK",
|
|
3030
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
3031
|
+
});
|
|
3032
|
+
topK = void 0;
|
|
3033
|
+
}
|
|
3034
|
+
if (topP != null) {
|
|
3035
|
+
warnings.push({
|
|
3036
|
+
type: "unsupported",
|
|
3037
|
+
feature: "topP",
|
|
3038
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
3039
|
+
});
|
|
3040
|
+
topP = void 0;
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
2998
3043
|
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2999
3044
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
3000
3045
|
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
@@ -3041,6 +3086,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3041
3086
|
const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
|
|
3042
3087
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
3043
3088
|
let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
|
|
3089
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.display : void 0;
|
|
3044
3090
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
3045
3091
|
const baseArgs = {
|
|
3046
3092
|
// model id:
|
|
@@ -3055,14 +3101,24 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3055
3101
|
...isThinking && {
|
|
3056
3102
|
thinking: {
|
|
3057
3103
|
type: thinkingType,
|
|
3058
|
-
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
3104
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
3105
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
3059
3106
|
}
|
|
3060
3107
|
},
|
|
3061
|
-
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
3108
|
+
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
3062
3109
|
output_config: {
|
|
3063
3110
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
3064
3111
|
effort: anthropicOptions.effort
|
|
3065
3112
|
},
|
|
3113
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
|
|
3114
|
+
task_budget: {
|
|
3115
|
+
type: anthropicOptions.taskBudget.type,
|
|
3116
|
+
total: anthropicOptions.taskBudget.total,
|
|
3117
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
3118
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
},
|
|
3066
3122
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
3067
3123
|
format: {
|
|
3068
3124
|
type: "json_schema",
|
|
@@ -3080,7 +3136,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3080
3136
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3081
3137
|
cache_control: anthropicOptions.cacheControl
|
|
3082
3138
|
},
|
|
3083
|
-
...((
|
|
3139
|
+
...((_h = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _h.userId) != null && {
|
|
3084
3140
|
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3085
3141
|
},
|
|
3086
3142
|
// mcp servers:
|
|
@@ -3250,10 +3306,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3250
3306
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
3251
3307
|
betas.add("effort-2025-11-24");
|
|
3252
3308
|
}
|
|
3309
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
3310
|
+
betas.add("task-budgets-2026-03-13");
|
|
3311
|
+
}
|
|
3253
3312
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3254
3313
|
betas.add("fast-mode-2026-02-01");
|
|
3255
3314
|
}
|
|
3256
|
-
if (stream && ((
|
|
3315
|
+
if (stream && ((_i = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _i : true)) {
|
|
3257
3316
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3258
3317
|
}
|
|
3259
3318
|
const {
|
|
@@ -3292,7 +3351,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3292
3351
|
...betas,
|
|
3293
3352
|
...toolsBetas,
|
|
3294
3353
|
...userSuppliedBetas,
|
|
3295
|
-
...(
|
|
3354
|
+
...(_j = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _j : []
|
|
3296
3355
|
]),
|
|
3297
3356
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3298
3357
|
toolNameMapping,
|
|
@@ -4551,46 +4610,60 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4551
4610
|
}
|
|
4552
4611
|
};
|
|
4553
4612
|
function getModelCapabilities(modelId) {
|
|
4554
|
-
if (modelId.includes("claude-
|
|
4613
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
4614
|
+
return {
|
|
4615
|
+
maxOutputTokens: 128e3,
|
|
4616
|
+
supportsStructuredOutput: true,
|
|
4617
|
+
rejectsSamplingParameters: true,
|
|
4618
|
+
isKnownModel: true
|
|
4619
|
+
};
|
|
4620
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
4555
4621
|
return {
|
|
4556
4622
|
maxOutputTokens: 128e3,
|
|
4557
4623
|
supportsStructuredOutput: true,
|
|
4624
|
+
rejectsSamplingParameters: false,
|
|
4558
4625
|
isKnownModel: true
|
|
4559
4626
|
};
|
|
4560
4627
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
4561
4628
|
return {
|
|
4562
4629
|
maxOutputTokens: 64e3,
|
|
4563
4630
|
supportsStructuredOutput: true,
|
|
4631
|
+
rejectsSamplingParameters: false,
|
|
4564
4632
|
isKnownModel: true
|
|
4565
4633
|
};
|
|
4566
4634
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
4567
4635
|
return {
|
|
4568
4636
|
maxOutputTokens: 32e3,
|
|
4569
4637
|
supportsStructuredOutput: true,
|
|
4638
|
+
rejectsSamplingParameters: false,
|
|
4570
4639
|
isKnownModel: true
|
|
4571
4640
|
};
|
|
4572
4641
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
4573
4642
|
return {
|
|
4574
4643
|
maxOutputTokens: 64e3,
|
|
4575
4644
|
supportsStructuredOutput: false,
|
|
4645
|
+
rejectsSamplingParameters: false,
|
|
4576
4646
|
isKnownModel: true
|
|
4577
4647
|
};
|
|
4578
4648
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
4579
4649
|
return {
|
|
4580
4650
|
maxOutputTokens: 32e3,
|
|
4581
4651
|
supportsStructuredOutput: false,
|
|
4652
|
+
rejectsSamplingParameters: false,
|
|
4582
4653
|
isKnownModel: true
|
|
4583
4654
|
};
|
|
4584
4655
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
4585
4656
|
return {
|
|
4586
4657
|
maxOutputTokens: 4096,
|
|
4587
4658
|
supportsStructuredOutput: false,
|
|
4659
|
+
rejectsSamplingParameters: false,
|
|
4588
4660
|
isKnownModel: true
|
|
4589
4661
|
};
|
|
4590
4662
|
} else {
|
|
4591
4663
|
return {
|
|
4592
4664
|
maxOutputTokens: 4096,
|
|
4593
4665
|
supportsStructuredOutput: false,
|
|
4666
|
+
rejectsSamplingParameters: false,
|
|
4594
4667
|
isKnownModel: false
|
|
4595
4668
|
};
|
|
4596
4669
|
}
|