@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.
@@ -824,7 +824,13 @@ var anthropicLanguageModelOptions = z3.object({
824
824
  thinking: z3.discriminatedUnion("type", [
825
825
  z3.object({
826
826
  /** for Sonnet 4.6, Opus 4.6, and newer models */
827
- type: z3.literal("adaptive")
827
+ type: z3.literal("adaptive"),
828
+ /**
829
+ * Controls whether thinking content is included in the response.
830
+ * - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
831
+ * - `"summarized"`: Thinking content is returned. Required to see reasoning output.
832
+ */
833
+ display: z3.enum(["omitted", "summarized"]).optional()
828
834
  }),
829
835
  z3.object({
830
836
  /** for models before Opus 4.6, except Sonnet 4.6 still supports it */
@@ -904,7 +910,19 @@ var anthropicLanguageModelOptions = z3.object({
904
910
  /**
905
911
  * @default 'high'
906
912
  */
907
- effort: z3.enum(["low", "medium", "high", "max"]).optional(),
913
+ effort: z3.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
914
+ /**
915
+ * Task budget for agentic turns. Informs the model of the total token budget
916
+ * available for the current task, allowing it to prioritize work and wind down
917
+ * gracefully as the budget is consumed.
918
+ *
919
+ * Advisory only — does not enforce a hard token limit.
920
+ */
921
+ taskBudget: z3.object({
922
+ type: z3.literal("tokens"),
923
+ total: z3.number().int().min(2e4),
924
+ remaining: z3.number().int().min(0).optional()
925
+ }).optional(),
908
926
  /**
909
927
  * Enable fast mode for faster inference (2.5x faster output token speeds).
910
928
  * Only supported with claude-opus-4-6.
@@ -2922,7 +2940,7 @@ var AnthropicMessagesLanguageModel = class {
2922
2940
  providerOptions,
2923
2941
  stream
2924
2942
  }) {
2925
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2943
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2926
2944
  const warnings = [];
2927
2945
  if (frequencyPenalty != null) {
2928
2946
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2977,8 +2995,35 @@ var AnthropicMessagesLanguageModel = class {
2977
2995
  const {
2978
2996
  maxOutputTokens: maxOutputTokensForModel,
2979
2997
  supportsStructuredOutput: modelSupportsStructuredOutput,
2998
+ rejectsSamplingParameters,
2980
2999
  isKnownModel
2981
3000
  } = getModelCapabilities(this.modelId);
3001
+ if (rejectsSamplingParameters) {
3002
+ if (temperature != null) {
3003
+ warnings.push({
3004
+ type: "unsupported",
3005
+ feature: "temperature",
3006
+ details: `temperature is not supported by ${this.modelId} and will be ignored`
3007
+ });
3008
+ temperature = void 0;
3009
+ }
3010
+ if (topK != null) {
3011
+ warnings.push({
3012
+ type: "unsupported",
3013
+ feature: "topK",
3014
+ details: `topK is not supported by ${this.modelId} and will be ignored`
3015
+ });
3016
+ topK = void 0;
3017
+ }
3018
+ if (topP != null) {
3019
+ warnings.push({
3020
+ type: "unsupported",
3021
+ feature: "topP",
3022
+ details: `topP is not supported by ${this.modelId} and will be ignored`
3023
+ });
3024
+ topP = void 0;
3025
+ }
3026
+ }
2982
3027
  const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2983
3028
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2984
3029
  const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
@@ -3025,6 +3070,7 @@ var AnthropicMessagesLanguageModel = class {
3025
3070
  const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3026
3071
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
3027
3072
  let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
3073
+ const thinkingDisplay = thinkingType === "adaptive" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.display : void 0;
3028
3074
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
3029
3075
  const baseArgs = {
3030
3076
  // model id:
@@ -3039,14 +3085,24 @@ var AnthropicMessagesLanguageModel = class {
3039
3085
  ...isThinking && {
3040
3086
  thinking: {
3041
3087
  type: thinkingType,
3042
- ...thinkingBudget != null && { budget_tokens: thinkingBudget }
3088
+ ...thinkingBudget != null && { budget_tokens: thinkingBudget },
3089
+ ...thinkingDisplay != null && { display: thinkingDisplay }
3043
3090
  }
3044
3091
  },
3045
- ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3092
+ ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3046
3093
  output_config: {
3047
3094
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
3048
3095
  effort: anthropicOptions.effort
3049
3096
  },
3097
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
3098
+ task_budget: {
3099
+ type: anthropicOptions.taskBudget.type,
3100
+ total: anthropicOptions.taskBudget.total,
3101
+ ...anthropicOptions.taskBudget.remaining != null && {
3102
+ remaining: anthropicOptions.taskBudget.remaining
3103
+ }
3104
+ }
3105
+ },
3050
3106
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
3051
3107
  format: {
3052
3108
  type: "json_schema",
@@ -3064,7 +3120,7 @@ var AnthropicMessagesLanguageModel = class {
3064
3120
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3065
3121
  cache_control: anthropicOptions.cacheControl
3066
3122
  },
3067
- ...((_g = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _g.userId) != null && {
3123
+ ...((_h = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _h.userId) != null && {
3068
3124
  metadata: { user_id: anthropicOptions.metadata.userId }
3069
3125
  },
3070
3126
  // mcp servers:
@@ -3234,10 +3290,13 @@ var AnthropicMessagesLanguageModel = class {
3234
3290
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
3235
3291
  betas.add("effort-2025-11-24");
3236
3292
  }
3293
+ if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
3294
+ betas.add("task-budgets-2026-03-13");
3295
+ }
3237
3296
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3238
3297
  betas.add("fast-mode-2026-02-01");
3239
3298
  }
3240
- if (stream && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _h : true)) {
3299
+ if (stream && ((_i = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _i : true)) {
3241
3300
  betas.add("fine-grained-tool-streaming-2025-05-14");
3242
3301
  }
3243
3302
  const {
@@ -3276,7 +3335,7 @@ var AnthropicMessagesLanguageModel = class {
3276
3335
  ...betas,
3277
3336
  ...toolsBetas,
3278
3337
  ...userSuppliedBetas,
3279
- ...(_i = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _i : []
3338
+ ...(_j = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _j : []
3280
3339
  ]),
3281
3340
  usesJsonResponseTool: jsonResponseTool != null,
3282
3341
  toolNameMapping,
@@ -4535,46 +4594,60 @@ var AnthropicMessagesLanguageModel = class {
4535
4594
  }
4536
4595
  };
4537
4596
  function getModelCapabilities(modelId) {
4538
- if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4597
+ if (modelId.includes("claude-opus-4-7")) {
4598
+ return {
4599
+ maxOutputTokens: 128e3,
4600
+ supportsStructuredOutput: true,
4601
+ rejectsSamplingParameters: true,
4602
+ isKnownModel: true
4603
+ };
4604
+ } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4539
4605
  return {
4540
4606
  maxOutputTokens: 128e3,
4541
4607
  supportsStructuredOutput: true,
4608
+ rejectsSamplingParameters: false,
4542
4609
  isKnownModel: true
4543
4610
  };
4544
4611
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
4545
4612
  return {
4546
4613
  maxOutputTokens: 64e3,
4547
4614
  supportsStructuredOutput: true,
4615
+ rejectsSamplingParameters: false,
4548
4616
  isKnownModel: true
4549
4617
  };
4550
4618
  } else if (modelId.includes("claude-opus-4-1")) {
4551
4619
  return {
4552
4620
  maxOutputTokens: 32e3,
4553
4621
  supportsStructuredOutput: true,
4622
+ rejectsSamplingParameters: false,
4554
4623
  isKnownModel: true
4555
4624
  };
4556
4625
  } else if (modelId.includes("claude-sonnet-4-")) {
4557
4626
  return {
4558
4627
  maxOutputTokens: 64e3,
4559
4628
  supportsStructuredOutput: false,
4629
+ rejectsSamplingParameters: false,
4560
4630
  isKnownModel: true
4561
4631
  };
4562
4632
  } else if (modelId.includes("claude-opus-4-")) {
4563
4633
  return {
4564
4634
  maxOutputTokens: 32e3,
4565
4635
  supportsStructuredOutput: false,
4636
+ rejectsSamplingParameters: false,
4566
4637
  isKnownModel: true
4567
4638
  };
4568
4639
  } else if (modelId.includes("claude-3-haiku")) {
4569
4640
  return {
4570
4641
  maxOutputTokens: 4096,
4571
4642
  supportsStructuredOutput: false,
4643
+ rejectsSamplingParameters: false,
4572
4644
  isKnownModel: true
4573
4645
  };
4574
4646
  } else {
4575
4647
  return {
4576
4648
  maxOutputTokens: 4096,
4577
4649
  supportsStructuredOutput: false,
4650
+ rejectsSamplingParameters: false,
4578
4651
  isKnownModel: false
4579
4652
  };
4580
4653
  }