@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.
@@ -629,7 +629,13 @@ var anthropicProviderOptions = z3.object({
629
629
  thinking: z3.discriminatedUnion("type", [
630
630
  z3.object({
631
631
  /** for Sonnet 4.6, Opus 4.6, and newer models */
632
- type: z3.literal("adaptive")
632
+ type: z3.literal("adaptive"),
633
+ /**
634
+ * Controls whether thinking content is included in the response.
635
+ * - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
636
+ * - `"summarized"`: Thinking content is returned. Required to see reasoning output.
637
+ */
638
+ display: z3.enum(["omitted", "summarized"]).optional()
633
639
  }),
634
640
  z3.object({
635
641
  /** for models before Opus 4.6, except Sonnet 4.6 still supports it */
@@ -685,12 +691,33 @@ var anthropicProviderOptions = z3.object({
685
691
  /**
686
692
  * @default 'high'
687
693
  */
688
- effort: z3.enum(["low", "medium", "high", "max"]).optional(),
694
+ effort: z3.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
695
+ /**
696
+ * Task budget for agentic turns. Informs the model of the total token budget
697
+ * available for the current task, allowing it to prioritize work and wind down
698
+ * gracefully as the budget is consumed.
699
+ *
700
+ * Advisory only — does not enforce a hard token limit.
701
+ */
702
+ taskBudget: z3.object({
703
+ type: z3.literal("tokens"),
704
+ total: z3.number().int().min(2e4),
705
+ remaining: z3.number().int().min(0).optional()
706
+ }).optional(),
689
707
  /**
690
708
  * Enable fast mode for faster inference (2.5x faster output token speeds).
691
709
  * Only supported with claude-opus-4-6.
692
710
  */
693
711
  speed: z3.enum(["fast", "standard"]).optional(),
712
+ /**
713
+ * Controls where model inference runs for this request.
714
+ *
715
+ * - `"global"`: Inference may run in any available geography (default).
716
+ * - `"us"`: Inference runs only in US-based infrastructure.
717
+ *
718
+ * See https://platform.claude.com/docs/en/build-with-claude/data-residency
719
+ */
720
+ inferenceGeo: z3.enum(["us", "global"]).optional(),
694
721
  /**
695
722
  * Context management configuration for automatic context window management.
696
723
  * Enables features like automatic compaction and clearing of tool uses/thinking blocks.
@@ -1976,7 +2003,7 @@ var AnthropicMessagesLanguageModel = class {
1976
2003
  toolChoice,
1977
2004
  providerOptions
1978
2005
  }) {
1979
- var _a, _b, _c, _d, _e, _f, _g;
2006
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1980
2007
  const warnings = [];
1981
2008
  if (frequencyPenalty != null) {
1982
2009
  warnings.push({
@@ -2034,8 +2061,36 @@ var AnthropicMessagesLanguageModel = class {
2034
2061
  const {
2035
2062
  maxOutputTokens: maxOutputTokensForModel,
2036
2063
  supportsStructuredOutput,
2064
+ rejectsSamplingParameters,
2037
2065
  isKnownModel
2038
2066
  } = getModelCapabilities(this.modelId);
2067
+ if (rejectsSamplingParameters) {
2068
+ if (temperature != null) {
2069
+ warnings.push({
2070
+ type: "unsupported-setting",
2071
+ setting: "temperature",
2072
+ details: `temperature is not supported by ${this.modelId} and will be ignored`
2073
+ });
2074
+ temperature = void 0;
2075
+ }
2076
+ if (topK != null) {
2077
+ warnings.push({
2078
+ type: "unsupported-setting",
2079
+ setting: "topK",
2080
+ details: `topK is not supported by ${this.modelId} and will be ignored`
2081
+ });
2082
+ topK = void 0;
2083
+ }
2084
+ if (topP != null) {
2085
+ warnings.push({
2086
+ type: "unsupported-setting",
2087
+ setting: "topP",
2088
+ details: `topP is not supported by ${this.modelId} and will be ignored`
2089
+ });
2090
+ topP = void 0;
2091
+ }
2092
+ }
2093
+ const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2039
2094
  const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : "jsonTool";
2040
2095
  const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
2041
2096
  const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
@@ -2054,6 +2109,7 @@ var AnthropicMessagesLanguageModel = class {
2054
2109
  const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
2055
2110
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
2056
2111
  let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
2112
+ const thinkingDisplay = thinkingType === "adaptive" ? (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.display : void 0;
2057
2113
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
2058
2114
  const baseArgs = {
2059
2115
  // model id:
@@ -2068,19 +2124,42 @@ var AnthropicMessagesLanguageModel = class {
2068
2124
  ...isThinking && {
2069
2125
  thinking: {
2070
2126
  type: thinkingType,
2071
- ...thinkingBudget != null && { budget_tokens: thinkingBudget }
2127
+ ...thinkingBudget != null && { budget_tokens: thinkingBudget },
2128
+ ...thinkingDisplay != null && { display: thinkingDisplay }
2072
2129
  }
2073
2130
  },
2074
- ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
2075
- output_config: { effort: anthropicOptions.effort }
2131
+ ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
2132
+ output_config: {
2133
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
2134
+ effort: anthropicOptions.effort
2135
+ },
2136
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
2137
+ task_budget: {
2138
+ type: anthropicOptions.taskBudget.type,
2139
+ total: anthropicOptions.taskBudget.total,
2140
+ ...anthropicOptions.taskBudget.remaining != null && {
2141
+ remaining: anthropicOptions.taskBudget.remaining
2142
+ }
2143
+ }
2144
+ },
2145
+ ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2146
+ format: {
2147
+ type: "json_schema",
2148
+ schema: responseFormat.schema
2149
+ }
2150
+ }
2151
+ }
2076
2152
  },
2077
2153
  ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
2078
2154
  speed: anthropicOptions.speed
2079
2155
  },
2156
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
2157
+ inference_geo: anthropicOptions.inferenceGeo
2158
+ },
2080
2159
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
2081
2160
  cache_control: anthropicOptions.cacheControl
2082
2161
  },
2083
- ...((_e = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _e.userId) != null && {
2162
+ ...((_f = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _f.userId) != null && {
2084
2163
  metadata: { user_id: anthropicOptions.metadata.userId }
2085
2164
  },
2086
2165
  // structured output:
@@ -2094,7 +2173,7 @@ var AnthropicMessagesLanguageModel = class {
2094
2173
  ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
2095
2174
  container: {
2096
2175
  id: anthropicOptions.container.id,
2097
- skills: (_f = anthropicOptions.container.skills) == null ? void 0 : _f.map((skill) => ({
2176
+ skills: (_g = anthropicOptions.container.skills) == null ? void 0 : _g.map((skill) => ({
2098
2177
  type: skill.type,
2099
2178
  skill_id: skill.skillId,
2100
2179
  version: skill.version
@@ -2214,6 +2293,9 @@ var AnthropicMessagesLanguageModel = class {
2214
2293
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
2215
2294
  betas.add("effort-2025-11-24");
2216
2295
  }
2296
+ if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
2297
+ betas.add("task-budgets-2026-03-13");
2298
+ }
2217
2299
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
2218
2300
  betas.add("fast-mode-2026-02-01");
2219
2301
  }
@@ -2257,7 +2339,7 @@ var AnthropicMessagesLanguageModel = class {
2257
2339
  ...betas,
2258
2340
  ...toolsBetas,
2259
2341
  ...userSuppliedBetas,
2260
- ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
2342
+ ...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
2261
2343
  ]),
2262
2344
  usesJsonResponseTool: jsonResponseTool != null
2263
2345
  };
@@ -3221,52 +3303,67 @@ var AnthropicMessagesLanguageModel = class {
3221
3303
  }
3222
3304
  };
3223
3305
  function getModelCapabilities(modelId) {
3224
- if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
3306
+ if (modelId.includes("claude-opus-4-7")) {
3307
+ return {
3308
+ maxOutputTokens: 128e3,
3309
+ supportsStructuredOutput: true,
3310
+ rejectsSamplingParameters: true,
3311
+ isKnownModel: true
3312
+ };
3313
+ } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
3225
3314
  return {
3226
3315
  maxOutputTokens: 128e3,
3227
3316
  supportsStructuredOutput: true,
3317
+ rejectsSamplingParameters: false,
3228
3318
  isKnownModel: true
3229
3319
  };
3230
3320
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
3231
3321
  return {
3232
3322
  maxOutputTokens: 64e3,
3233
3323
  supportsStructuredOutput: true,
3324
+ rejectsSamplingParameters: false,
3234
3325
  isKnownModel: true
3235
3326
  };
3236
3327
  } else if (modelId.includes("claude-opus-4-1")) {
3237
3328
  return {
3238
3329
  maxOutputTokens: 32e3,
3239
3330
  supportsStructuredOutput: true,
3331
+ rejectsSamplingParameters: false,
3240
3332
  isKnownModel: true
3241
3333
  };
3242
3334
  } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
3243
3335
  return {
3244
3336
  maxOutputTokens: 64e3,
3245
3337
  supportsStructuredOutput: false,
3338
+ rejectsSamplingParameters: false,
3246
3339
  isKnownModel: true
3247
3340
  };
3248
3341
  } else if (modelId.includes("claude-opus-4-")) {
3249
3342
  return {
3250
3343
  maxOutputTokens: 32e3,
3251
3344
  supportsStructuredOutput: false,
3345
+ rejectsSamplingParameters: false,
3252
3346
  isKnownModel: true
3253
3347
  };
3254
3348
  } else if (modelId.includes("claude-3-5-haiku")) {
3255
3349
  return {
3256
3350
  maxOutputTokens: 8192,
3257
3351
  supportsStructuredOutput: false,
3352
+ rejectsSamplingParameters: false,
3258
3353
  isKnownModel: true
3259
3354
  };
3260
3355
  } else if (modelId.includes("claude-3-haiku")) {
3261
3356
  return {
3262
3357
  maxOutputTokens: 4096,
3263
3358
  supportsStructuredOutput: false,
3359
+ rejectsSamplingParameters: false,
3264
3360
  isKnownModel: true
3265
3361
  };
3266
3362
  } else {
3267
3363
  return {
3268
3364
  maxOutputTokens: 4096,
3269
3365
  supportsStructuredOutput: false,
3366
+ rejectsSamplingParameters: false,
3270
3367
  isKnownModel: false
3271
3368
  };
3272
3369
  }