@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.70
4
+
5
+ ### Patch Changes
6
+
7
+ - 2ff8d57: feat(provider/anthropic): add support for Opus 4.7 and relevant API enhancements
8
+
3
9
  ## 3.0.69
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -128,7 +128,7 @@ interface AnthropicMessageMetadata {
128
128
  } | null;
129
129
  }
130
130
 
131
- type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | (string & {});
131
+ type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | (string & {});
132
132
  declare const anthropicLanguageModelOptions: z.ZodObject<{
133
133
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
134
134
  structuredOutputMode: z.ZodOptional<z.ZodEnum<{
@@ -138,6 +138,10 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
138
138
  }>>;
139
139
  thinking: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
140
140
  type: z.ZodLiteral<"adaptive">;
141
+ display: z.ZodOptional<z.ZodEnum<{
142
+ omitted: "omitted";
143
+ summarized: "summarized";
144
+ }>>;
141
145
  }, z.core.$strip>, z.ZodObject<{
142
146
  type: z.ZodLiteral<"enabled">;
143
147
  budgetTokens: z.ZodOptional<z.ZodNumber>;
@@ -175,8 +179,14 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
175
179
  low: "low";
176
180
  medium: "medium";
177
181
  high: "high";
182
+ xhigh: "xhigh";
178
183
  max: "max";
179
184
  }>>;
185
+ taskBudget: z.ZodOptional<z.ZodObject<{
186
+ type: z.ZodLiteral<"tokens">;
187
+ total: z.ZodNumber;
188
+ remaining: z.ZodOptional<z.ZodNumber>;
189
+ }, z.core.$strip>>;
180
190
  speed: z.ZodOptional<z.ZodEnum<{
181
191
  fast: "fast";
182
192
  standard: "standard";
package/dist/index.d.ts CHANGED
@@ -128,7 +128,7 @@ interface AnthropicMessageMetadata {
128
128
  } | null;
129
129
  }
130
130
 
131
- type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | (string & {});
131
+ type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | (string & {});
132
132
  declare const anthropicLanguageModelOptions: z.ZodObject<{
133
133
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
134
134
  structuredOutputMode: z.ZodOptional<z.ZodEnum<{
@@ -138,6 +138,10 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
138
138
  }>>;
139
139
  thinking: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
140
140
  type: z.ZodLiteral<"adaptive">;
141
+ display: z.ZodOptional<z.ZodEnum<{
142
+ omitted: "omitted";
143
+ summarized: "summarized";
144
+ }>>;
141
145
  }, z.core.$strip>, z.ZodObject<{
142
146
  type: z.ZodLiteral<"enabled">;
143
147
  budgetTokens: z.ZodOptional<z.ZodNumber>;
@@ -175,8 +179,14 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
175
179
  low: "low";
176
180
  medium: "medium";
177
181
  high: "high";
182
+ xhigh: "xhigh";
178
183
  max: "max";
179
184
  }>>;
185
+ taskBudget: z.ZodOptional<z.ZodObject<{
186
+ type: z.ZodLiteral<"tokens">;
187
+ total: z.ZodNumber;
188
+ remaining: z.ZodOptional<z.ZodNumber>;
189
+ }, z.core.$strip>>;
180
190
  speed: z.ZodOptional<z.ZodEnum<{
181
191
  fast: "fast";
182
192
  standard: "standard";
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.69" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.70" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -845,7 +845,13 @@ var anthropicLanguageModelOptions = import_v43.z.object({
845
845
  thinking: import_v43.z.discriminatedUnion("type", [
846
846
  import_v43.z.object({
847
847
  /** for Sonnet 4.6, Opus 4.6, and newer models */
848
- type: import_v43.z.literal("adaptive")
848
+ type: import_v43.z.literal("adaptive"),
849
+ /**
850
+ * Controls whether thinking content is included in the response.
851
+ * - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
852
+ * - `"summarized"`: Thinking content is returned. Required to see reasoning output.
853
+ */
854
+ display: import_v43.z.enum(["omitted", "summarized"]).optional()
849
855
  }),
850
856
  import_v43.z.object({
851
857
  /** for models before Opus 4.6, except Sonnet 4.6 still supports it */
@@ -925,7 +931,19 @@ var anthropicLanguageModelOptions = import_v43.z.object({
925
931
  /**
926
932
  * @default 'high'
927
933
  */
928
- effort: import_v43.z.enum(["low", "medium", "high", "max"]).optional(),
934
+ effort: import_v43.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
935
+ /**
936
+ * Task budget for agentic turns. Informs the model of the total token budget
937
+ * available for the current task, allowing it to prioritize work and wind down
938
+ * gracefully as the budget is consumed.
939
+ *
940
+ * Advisory only — does not enforce a hard token limit.
941
+ */
942
+ taskBudget: import_v43.z.object({
943
+ type: import_v43.z.literal("tokens"),
944
+ total: import_v43.z.number().int().min(2e4),
945
+ remaining: import_v43.z.number().int().min(0).optional()
946
+ }).optional(),
929
947
  /**
930
948
  * Enable fast mode for faster inference (2.5x faster output token speeds).
931
949
  * Only supported with claude-opus-4-6.
@@ -2901,7 +2919,7 @@ var AnthropicMessagesLanguageModel = class {
2901
2919
  providerOptions,
2902
2920
  stream
2903
2921
  }) {
2904
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2922
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2905
2923
  const warnings = [];
2906
2924
  if (frequencyPenalty != null) {
2907
2925
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2956,8 +2974,35 @@ var AnthropicMessagesLanguageModel = class {
2956
2974
  const {
2957
2975
  maxOutputTokens: maxOutputTokensForModel,
2958
2976
  supportsStructuredOutput: modelSupportsStructuredOutput,
2977
+ rejectsSamplingParameters,
2959
2978
  isKnownModel
2960
2979
  } = getModelCapabilities(this.modelId);
2980
+ if (rejectsSamplingParameters) {
2981
+ if (temperature != null) {
2982
+ warnings.push({
2983
+ type: "unsupported",
2984
+ feature: "temperature",
2985
+ details: `temperature is not supported by ${this.modelId} and will be ignored`
2986
+ });
2987
+ temperature = void 0;
2988
+ }
2989
+ if (topK != null) {
2990
+ warnings.push({
2991
+ type: "unsupported",
2992
+ feature: "topK",
2993
+ details: `topK is not supported by ${this.modelId} and will be ignored`
2994
+ });
2995
+ topK = void 0;
2996
+ }
2997
+ if (topP != null) {
2998
+ warnings.push({
2999
+ type: "unsupported",
3000
+ feature: "topP",
3001
+ details: `topP is not supported by ${this.modelId} and will be ignored`
3002
+ });
3003
+ topP = void 0;
3004
+ }
3005
+ }
2961
3006
  const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2962
3007
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2963
3008
  const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
@@ -3004,6 +3049,7 @@ var AnthropicMessagesLanguageModel = class {
3004
3049
  const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3005
3050
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
3006
3051
  let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
3052
+ const thinkingDisplay = thinkingType === "adaptive" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.display : void 0;
3007
3053
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
3008
3054
  const baseArgs = {
3009
3055
  // model id:
@@ -3018,14 +3064,24 @@ var AnthropicMessagesLanguageModel = class {
3018
3064
  ...isThinking && {
3019
3065
  thinking: {
3020
3066
  type: thinkingType,
3021
- ...thinkingBudget != null && { budget_tokens: thinkingBudget }
3067
+ ...thinkingBudget != null && { budget_tokens: thinkingBudget },
3068
+ ...thinkingDisplay != null && { display: thinkingDisplay }
3022
3069
  }
3023
3070
  },
3024
- ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3071
+ ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3025
3072
  output_config: {
3026
3073
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
3027
3074
  effort: anthropicOptions.effort
3028
3075
  },
3076
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
3077
+ task_budget: {
3078
+ type: anthropicOptions.taskBudget.type,
3079
+ total: anthropicOptions.taskBudget.total,
3080
+ ...anthropicOptions.taskBudget.remaining != null && {
3081
+ remaining: anthropicOptions.taskBudget.remaining
3082
+ }
3083
+ }
3084
+ },
3029
3085
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
3030
3086
  format: {
3031
3087
  type: "json_schema",
@@ -3043,7 +3099,7 @@ var AnthropicMessagesLanguageModel = class {
3043
3099
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3044
3100
  cache_control: anthropicOptions.cacheControl
3045
3101
  },
3046
- ...((_g = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _g.userId) != null && {
3102
+ ...((_h = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _h.userId) != null && {
3047
3103
  metadata: { user_id: anthropicOptions.metadata.userId }
3048
3104
  },
3049
3105
  // mcp servers:
@@ -3213,10 +3269,13 @@ var AnthropicMessagesLanguageModel = class {
3213
3269
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
3214
3270
  betas.add("effort-2025-11-24");
3215
3271
  }
3272
+ if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
3273
+ betas.add("task-budgets-2026-03-13");
3274
+ }
3216
3275
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3217
3276
  betas.add("fast-mode-2026-02-01");
3218
3277
  }
3219
- if (stream && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _h : true)) {
3278
+ if (stream && ((_i = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _i : true)) {
3220
3279
  betas.add("fine-grained-tool-streaming-2025-05-14");
3221
3280
  }
3222
3281
  const {
@@ -3255,7 +3314,7 @@ var AnthropicMessagesLanguageModel = class {
3255
3314
  ...betas,
3256
3315
  ...toolsBetas,
3257
3316
  ...userSuppliedBetas,
3258
- ...(_i = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _i : []
3317
+ ...(_j = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _j : []
3259
3318
  ]),
3260
3319
  usesJsonResponseTool: jsonResponseTool != null,
3261
3320
  toolNameMapping,
@@ -4514,46 +4573,60 @@ var AnthropicMessagesLanguageModel = class {
4514
4573
  }
4515
4574
  };
4516
4575
  function getModelCapabilities(modelId) {
4517
- if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4576
+ if (modelId.includes("claude-opus-4-7")) {
4577
+ return {
4578
+ maxOutputTokens: 128e3,
4579
+ supportsStructuredOutput: true,
4580
+ rejectsSamplingParameters: true,
4581
+ isKnownModel: true
4582
+ };
4583
+ } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4518
4584
  return {
4519
4585
  maxOutputTokens: 128e3,
4520
4586
  supportsStructuredOutput: true,
4587
+ rejectsSamplingParameters: false,
4521
4588
  isKnownModel: true
4522
4589
  };
4523
4590
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
4524
4591
  return {
4525
4592
  maxOutputTokens: 64e3,
4526
4593
  supportsStructuredOutput: true,
4594
+ rejectsSamplingParameters: false,
4527
4595
  isKnownModel: true
4528
4596
  };
4529
4597
  } else if (modelId.includes("claude-opus-4-1")) {
4530
4598
  return {
4531
4599
  maxOutputTokens: 32e3,
4532
4600
  supportsStructuredOutput: true,
4601
+ rejectsSamplingParameters: false,
4533
4602
  isKnownModel: true
4534
4603
  };
4535
4604
  } else if (modelId.includes("claude-sonnet-4-")) {
4536
4605
  return {
4537
4606
  maxOutputTokens: 64e3,
4538
4607
  supportsStructuredOutput: false,
4608
+ rejectsSamplingParameters: false,
4539
4609
  isKnownModel: true
4540
4610
  };
4541
4611
  } else if (modelId.includes("claude-opus-4-")) {
4542
4612
  return {
4543
4613
  maxOutputTokens: 32e3,
4544
4614
  supportsStructuredOutput: false,
4615
+ rejectsSamplingParameters: false,
4545
4616
  isKnownModel: true
4546
4617
  };
4547
4618
  } else if (modelId.includes("claude-3-haiku")) {
4548
4619
  return {
4549
4620
  maxOutputTokens: 4096,
4550
4621
  supportsStructuredOutput: false,
4622
+ rejectsSamplingParameters: false,
4551
4623
  isKnownModel: true
4552
4624
  };
4553
4625
  } else {
4554
4626
  return {
4555
4627
  maxOutputTokens: 4096,
4556
4628
  supportsStructuredOutput: false,
4629
+ rejectsSamplingParameters: false,
4557
4630
  isKnownModel: false
4558
4631
  };
4559
4632
  }