@ai-sdk/anthropic 3.0.68 → 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,12 +910,33 @@ 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.
911
929
  */
912
930
  speed: z3.enum(["fast", "standard"]).optional(),
931
+ /**
932
+ * Controls where model inference runs for this request.
933
+ *
934
+ * - `"global"`: Inference may run in any available geography (default).
935
+ * - `"us"`: Inference runs only in US-based infrastructure.
936
+ *
937
+ * See https://platform.claude.com/docs/en/build-with-claude/data-residency
938
+ */
939
+ inferenceGeo: z3.enum(["us", "global"]).optional(),
913
940
  /**
914
941
  * A set of beta features to enable.
915
942
  * Allow a provider to receive the full `betas` set if it needs it.
@@ -2913,7 +2940,7 @@ var AnthropicMessagesLanguageModel = class {
2913
2940
  providerOptions,
2914
2941
  stream
2915
2942
  }) {
2916
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2943
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2917
2944
  const warnings = [];
2918
2945
  if (frequencyPenalty != null) {
2919
2946
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2968,8 +2995,35 @@ var AnthropicMessagesLanguageModel = class {
2968
2995
  const {
2969
2996
  maxOutputTokens: maxOutputTokensForModel,
2970
2997
  supportsStructuredOutput: modelSupportsStructuredOutput,
2998
+ rejectsSamplingParameters,
2971
2999
  isKnownModel
2972
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
+ }
2973
3027
  const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2974
3028
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2975
3029
  const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
@@ -3016,6 +3070,7 @@ var AnthropicMessagesLanguageModel = class {
3016
3070
  const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3017
3071
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
3018
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;
3019
3074
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
3020
3075
  const baseArgs = {
3021
3076
  // model id:
@@ -3030,14 +3085,24 @@ var AnthropicMessagesLanguageModel = class {
3030
3085
  ...isThinking && {
3031
3086
  thinking: {
3032
3087
  type: thinkingType,
3033
- ...thinkingBudget != null && { budget_tokens: thinkingBudget }
3088
+ ...thinkingBudget != null && { budget_tokens: thinkingBudget },
3089
+ ...thinkingDisplay != null && { display: thinkingDisplay }
3034
3090
  }
3035
3091
  },
3036
- ...((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) && {
3037
3093
  output_config: {
3038
3094
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
3039
3095
  effort: anthropicOptions.effort
3040
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
+ },
3041
3106
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
3042
3107
  format: {
3043
3108
  type: "json_schema",
@@ -3049,10 +3114,13 @@ var AnthropicMessagesLanguageModel = class {
3049
3114
  ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
3050
3115
  speed: anthropicOptions.speed
3051
3116
  },
3117
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
3118
+ inference_geo: anthropicOptions.inferenceGeo
3119
+ },
3052
3120
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3053
3121
  cache_control: anthropicOptions.cacheControl
3054
3122
  },
3055
- ...((_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 && {
3056
3124
  metadata: { user_id: anthropicOptions.metadata.userId }
3057
3125
  },
3058
3126
  // mcp servers:
@@ -3222,10 +3290,13 @@ var AnthropicMessagesLanguageModel = class {
3222
3290
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
3223
3291
  betas.add("effort-2025-11-24");
3224
3292
  }
3293
+ if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
3294
+ betas.add("task-budgets-2026-03-13");
3295
+ }
3225
3296
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3226
3297
  betas.add("fast-mode-2026-02-01");
3227
3298
  }
3228
- 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)) {
3229
3300
  betas.add("fine-grained-tool-streaming-2025-05-14");
3230
3301
  }
3231
3302
  const {
@@ -3264,7 +3335,7 @@ var AnthropicMessagesLanguageModel = class {
3264
3335
  ...betas,
3265
3336
  ...toolsBetas,
3266
3337
  ...userSuppliedBetas,
3267
- ...(_i = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _i : []
3338
+ ...(_j = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _j : []
3268
3339
  ]),
3269
3340
  usesJsonResponseTool: jsonResponseTool != null,
3270
3341
  toolNameMapping,
@@ -4523,46 +4594,60 @@ var AnthropicMessagesLanguageModel = class {
4523
4594
  }
4524
4595
  };
4525
4596
  function getModelCapabilities(modelId) {
4526
- 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")) {
4527
4605
  return {
4528
4606
  maxOutputTokens: 128e3,
4529
4607
  supportsStructuredOutput: true,
4608
+ rejectsSamplingParameters: false,
4530
4609
  isKnownModel: true
4531
4610
  };
4532
4611
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
4533
4612
  return {
4534
4613
  maxOutputTokens: 64e3,
4535
4614
  supportsStructuredOutput: true,
4615
+ rejectsSamplingParameters: false,
4536
4616
  isKnownModel: true
4537
4617
  };
4538
4618
  } else if (modelId.includes("claude-opus-4-1")) {
4539
4619
  return {
4540
4620
  maxOutputTokens: 32e3,
4541
4621
  supportsStructuredOutput: true,
4622
+ rejectsSamplingParameters: false,
4542
4623
  isKnownModel: true
4543
4624
  };
4544
4625
  } else if (modelId.includes("claude-sonnet-4-")) {
4545
4626
  return {
4546
4627
  maxOutputTokens: 64e3,
4547
4628
  supportsStructuredOutput: false,
4629
+ rejectsSamplingParameters: false,
4548
4630
  isKnownModel: true
4549
4631
  };
4550
4632
  } else if (modelId.includes("claude-opus-4-")) {
4551
4633
  return {
4552
4634
  maxOutputTokens: 32e3,
4553
4635
  supportsStructuredOutput: false,
4636
+ rejectsSamplingParameters: false,
4554
4637
  isKnownModel: true
4555
4638
  };
4556
4639
  } else if (modelId.includes("claude-3-haiku")) {
4557
4640
  return {
4558
4641
  maxOutputTokens: 4096,
4559
4642
  supportsStructuredOutput: false,
4643
+ rejectsSamplingParameters: false,
4560
4644
  isKnownModel: true
4561
4645
  };
4562
4646
  } else {
4563
4647
  return {
4564
4648
  maxOutputTokens: 4096,
4565
4649
  supportsStructuredOutput: false,
4650
+ rejectsSamplingParameters: false,
4566
4651
  isKnownModel: false
4567
4652
  };
4568
4653
  }