@ai-sdk/anthropic 2.0.106 → 2.0.107

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,19 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.0.107
4
+
5
+ ### Patch Changes
6
+
7
+ - 6dc04c5: feat(anthropic): add Claude Sonnet 5.5 support
8
+
9
+ - add the `claude-sonnet-5-5` model ID to `@ai-sdk/anthropic` and `@ai-sdk/google-vertex`, `anthropic.claude-sonnet-5-5` and `us.anthropic.claude-sonnet-5-5` to `@ai-sdk/amazon-bedrock`, and `anthropic/claude-sonnet-5.5` to `@ai-sdk/gateway`
10
+ - add the `between_tools` thinking type (`thinking: { type: 'between_tools' }`), the lowest thinking setting on `claude-sonnet-5-5`; `xhigh` and `max` effort are lowered to `high` with a warning because the API rejects them with `between_tools`
11
+ - `claude-sonnet-5-5` rejects disabled thinking: `thinking: { type: 'disabled' }` is replaced with `between_tools` thinking (with a warning), and budget-based thinking is converted to adaptive thinking
12
+ - `claude-sonnet-5-5` rejects forced tool use: `required` and named tool choices fall back to `auto`, and `structuredOutputMode: 'jsonTool'` falls back to native structured outputs, each with a warning
13
+
14
+ - Updated dependencies [14810cb]
15
+ - @ai-sdk/provider-utils@3.0.40
16
+
3
17
  ## 2.0.106
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -169,7 +169,7 @@ interface AnthropicMessageMetadata {
169
169
  } | null;
170
170
  }
171
171
 
172
- type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | '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' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | (string & {});
172
+ type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | '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' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | 'claude-sonnet-5-5' | (string & {});
173
173
  /**
174
174
  * Anthropic provider options for system messages.
175
175
  */
@@ -216,6 +216,8 @@ declare const anthropicProviderOptions: z.ZodObject<{
216
216
  }, z.core.$strip>>;
217
217
  }, z.core.$strip>, z.ZodObject<{
218
218
  type: z.ZodLiteral<"disabled">;
219
+ }, z.core.$strip>, z.ZodObject<{
220
+ type: z.ZodLiteral<"between_tools">;
219
221
  }, z.core.$strip>, z.ZodObject<{
220
222
  blockBinding: z.ZodObject<{
221
223
  prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
package/dist/index.d.ts CHANGED
@@ -169,7 +169,7 @@ interface AnthropicMessageMetadata {
169
169
  } | null;
170
170
  }
171
171
 
172
- type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | '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' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | (string & {});
172
+ type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | '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' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | 'claude-sonnet-5-5' | (string & {});
173
173
  /**
174
174
  * Anthropic provider options for system messages.
175
175
  */
@@ -216,6 +216,8 @@ declare const anthropicProviderOptions: z.ZodObject<{
216
216
  }, z.core.$strip>>;
217
217
  }, z.core.$strip>, z.ZodObject<{
218
218
  type: z.ZodLiteral<"disabled">;
219
+ }, z.core.$strip>, z.ZodObject<{
220
+ type: z.ZodLiteral<"between_tools">;
219
221
  }, z.core.$strip>, z.ZodObject<{
220
222
  blockBinding: z.ZodObject<{
221
223
  prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var import_provider4 = require("@ai-sdk/provider");
31
31
  var import_provider_utils21 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/version.ts
34
- var VERSION = true ? "2.0.106" : "0.0.0-test";
34
+ var VERSION = true ? "2.0.107" : "0.0.0-test";
35
35
 
36
36
  // src/anthropic-messages-language-model.ts
37
37
  var import_provider3 = require("@ai-sdk/provider");
@@ -731,7 +731,7 @@ var anthropicProviderOptions = import_v43.z.object({
731
731
  *
732
732
  * - `outputFormat`: Use the `output_format` parameter to specify the structured output format.
733
733
  * - `jsonTool`: Use a special JSON response tool to specify the structured output format (default for most models).
734
- * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default for Opus 5.5 and Fable 5.1).
734
+ * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default for Sonnet 5.5, Opus 5.5, and Fable 5.1).
735
735
  */
736
736
  structuredOutputMode: import_v43.z.enum(["outputFormat", "jsonTool", "auto"]).optional(),
737
737
  /**
@@ -744,6 +744,9 @@ var anthropicProviderOptions = import_v43.z.object({
744
744
  * `claude-fable-5-1`) reject `enabled` and `disabled`. For those models the
745
745
  * provider drops the unsupported setting, emits a warning, and sends an
746
746
  * adaptive thinking request. Use `effort` to control how much they think.
747
+ *
748
+ * `claude-sonnet-5-5` supports `between_tools`, its lowest thinking setting,
749
+ * and the provider uses it in place of `disabled` for that model.
747
750
  */
748
751
  thinking: import_v43.z.union([
749
752
  import_v43.z.object({
@@ -775,6 +778,14 @@ var anthropicProviderOptions = import_v43.z.object({
775
778
  import_v43.z.object({
776
779
  type: import_v43.z.literal("disabled")
777
780
  }),
781
+ import_v43.z.object({
782
+ /**
783
+ * for `claude-sonnet-5-5`: no upfront thinking, but progress notes
784
+ * between tool calls are returned as summarized thinking blocks.
785
+ * Only supported at `low`, `medium`, and `high` effort.
786
+ */
787
+ type: import_v43.z.literal("between_tools")
788
+ }),
778
789
  import_v43.z.object({
779
790
  /**
780
791
  * Configure prefix mismatch handling without changing the model's
@@ -2639,6 +2650,7 @@ var AnthropicMessagesLanguageModel = class {
2639
2650
  rejectsThinkingDisabledAboveHighEffort,
2640
2651
  rejectsThinkingDisabled,
2641
2652
  rejectsForcedToolUse,
2653
+ supportsBetweenToolsThinking,
2642
2654
  isKnownModel
2643
2655
  } = getModelCapabilities(this.modelId);
2644
2656
  if (!isKnownModel && maxOutputTokens == null) {
@@ -2674,7 +2686,7 @@ var AnthropicMessagesLanguageModel = class {
2674
2686
  }
2675
2687
  }
2676
2688
  const isAnthropicModel = isKnownModel || this.modelId.includes("claude-");
2677
- const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : this.modelId.includes("claude-fable-5-1") || this.modelId.includes("claude-opus-5-5") ? "auto" : "jsonTool";
2689
+ const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : this.modelId.includes("claude-fable-5-1") || this.modelId.includes("claude-opus-5-5") || this.modelId.includes("claude-sonnet-5-5") ? "auto" : "jsonTool";
2678
2690
  let useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
2679
2691
  if (!useStructuredOutput && rejectsForcedToolUse && supportsStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) {
2680
2692
  warnings.push({
@@ -2709,7 +2721,14 @@ var AnthropicMessagesLanguageModel = class {
2709
2721
  });
2710
2722
  if (rejectsThinkingDisabled && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) != null) {
2711
2723
  const thinking = anthropicOptions.thinking;
2712
- if ("type" in thinking && thinking.type === "disabled") {
2724
+ if ("type" in thinking && thinking.type === "disabled" && supportsBetweenToolsThinking) {
2725
+ warnings.push({
2726
+ type: "unsupported-setting",
2727
+ setting: "providerOptions.anthropic.thinking",
2728
+ details: `thinking cannot be disabled for ${this.modelId}. Using 'between_tools' thinking, the lowest thinking setting, instead.`
2729
+ });
2730
+ anthropicOptions.thinking = { type: "between_tools" };
2731
+ } else if ("type" in thinking && thinking.type === "disabled") {
2713
2732
  warnings.push({
2714
2733
  type: "unsupported-setting",
2715
2734
  setting: "providerOptions.anthropic.thinking",
@@ -2740,7 +2759,15 @@ var AnthropicMessagesLanguageModel = class {
2740
2759
  });
2741
2760
  anthropicOptions.effort = "high";
2742
2761
  }
2743
- const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
2762
+ if (thinkingType === "between_tools" && anthropicOptions != null && (anthropicOptions.effort === "xhigh" || anthropicOptions.effort === "max")) {
2763
+ warnings.push({
2764
+ type: "unsupported-setting",
2765
+ setting: "providerOptions.anthropic.effort",
2766
+ details: `effort '${anthropicOptions.effort}' is not supported with 'between_tools' thinking. The effort has been lowered to 'high'.`
2767
+ });
2768
+ anthropicOptions.effort = "high";
2769
+ }
2770
+ const isThinking = thinkingType === "enabled" || thinkingType === "adaptive" || thinkingType === "between_tools";
2744
2771
  let thinkingBudget = thinkingOptions != null && "budgetTokens" in thinkingOptions ? thinkingOptions.budgetTokens : void 0;
2745
2772
  const thinkingDisplay = thinkingOptions != null && "display" in thinkingOptions ? thinkingOptions.display : void 0;
2746
2773
  const thinkingBlockBinding = thinkingOptions != null && "blockBinding" in thinkingOptions ? thinkingOptions.blockBinding : void 0;
@@ -4105,7 +4132,18 @@ var AnthropicMessagesLanguageModel = class {
4105
4132
  }
4106
4133
  };
4107
4134
  function getModelCapabilities(modelId) {
4108
- if (modelId.includes("claude-opus-5-5")) {
4135
+ if (modelId.includes("claude-sonnet-5-5")) {
4136
+ return {
4137
+ maxOutputTokens: 128e3,
4138
+ supportsStructuredOutput: true,
4139
+ rejectsSamplingParameters: true,
4140
+ rejectsThinkingDisabledAboveHighEffort: true,
4141
+ rejectsThinkingDisabled: true,
4142
+ rejectsForcedToolUse: true,
4143
+ supportsBetweenToolsThinking: true,
4144
+ isKnownModel: true
4145
+ };
4146
+ } else if (modelId.includes("claude-opus-5-5")) {
4109
4147
  return {
4110
4148
  maxOutputTokens: 128e3,
4111
4149
  supportsStructuredOutput: true,
@@ -4113,6 +4151,7 @@ function getModelCapabilities(modelId) {
4113
4151
  rejectsThinkingDisabledAboveHighEffort: true,
4114
4152
  rejectsThinkingDisabled: true,
4115
4153
  rejectsForcedToolUse: true,
4154
+ supportsBetweenToolsThinking: false,
4116
4155
  isKnownModel: true
4117
4156
  };
4118
4157
  } else if (modelId.includes("claude-opus-5")) {
@@ -4123,6 +4162,7 @@ function getModelCapabilities(modelId) {
4123
4162
  rejectsThinkingDisabledAboveHighEffort: true,
4124
4163
  rejectsThinkingDisabled: false,
4125
4164
  rejectsForcedToolUse: false,
4165
+ supportsBetweenToolsThinking: false,
4126
4166
  isKnownModel: true
4127
4167
  };
4128
4168
  } else if (modelId.includes("claude-fable-5-1")) {
@@ -4133,6 +4173,7 @@ function getModelCapabilities(modelId) {
4133
4173
  rejectsThinkingDisabledAboveHighEffort: false,
4134
4174
  rejectsThinkingDisabled: true,
4135
4175
  rejectsForcedToolUse: true,
4176
+ supportsBetweenToolsThinking: false,
4136
4177
  isKnownModel: true
4137
4178
  };
4138
4179
  } else if (modelId.includes("claude-fable-5")) {
@@ -4143,6 +4184,7 @@ function getModelCapabilities(modelId) {
4143
4184
  rejectsThinkingDisabledAboveHighEffort: false,
4144
4185
  rejectsThinkingDisabled: true,
4145
4186
  rejectsForcedToolUse: false,
4187
+ supportsBetweenToolsThinking: false,
4146
4188
  isKnownModel: true
4147
4189
  };
4148
4190
  } else if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-sonnet-5")) {
@@ -4153,6 +4195,7 @@ function getModelCapabilities(modelId) {
4153
4195
  rejectsThinkingDisabledAboveHighEffort: false,
4154
4196
  rejectsThinkingDisabled: false,
4155
4197
  rejectsForcedToolUse: false,
4198
+ supportsBetweenToolsThinking: false,
4156
4199
  isKnownModel: true
4157
4200
  };
4158
4201
  } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
@@ -4163,6 +4206,7 @@ function getModelCapabilities(modelId) {
4163
4206
  rejectsThinkingDisabledAboveHighEffort: false,
4164
4207
  rejectsThinkingDisabled: false,
4165
4208
  rejectsForcedToolUse: false,
4209
+ supportsBetweenToolsThinking: false,
4166
4210
  isKnownModel: true
4167
4211
  };
4168
4212
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
@@ -4173,6 +4217,7 @@ function getModelCapabilities(modelId) {
4173
4217
  rejectsThinkingDisabledAboveHighEffort: false,
4174
4218
  rejectsThinkingDisabled: false,
4175
4219
  rejectsForcedToolUse: false,
4220
+ supportsBetweenToolsThinking: false,
4176
4221
  isKnownModel: true
4177
4222
  };
4178
4223
  } else if (modelId.includes("claude-opus-4-1")) {
@@ -4183,6 +4228,7 @@ function getModelCapabilities(modelId) {
4183
4228
  rejectsThinkingDisabledAboveHighEffort: false,
4184
4229
  rejectsThinkingDisabled: false,
4185
4230
  rejectsForcedToolUse: false,
4231
+ supportsBetweenToolsThinking: false,
4186
4232
  isKnownModel: true
4187
4233
  };
4188
4234
  } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
@@ -4193,6 +4239,7 @@ function getModelCapabilities(modelId) {
4193
4239
  rejectsThinkingDisabledAboveHighEffort: false,
4194
4240
  rejectsThinkingDisabled: false,
4195
4241
  rejectsForcedToolUse: false,
4242
+ supportsBetweenToolsThinking: false,
4196
4243
  isKnownModel: true
4197
4244
  };
4198
4245
  } else if (modelId.includes("claude-opus-4-")) {
@@ -4203,6 +4250,7 @@ function getModelCapabilities(modelId) {
4203
4250
  rejectsThinkingDisabledAboveHighEffort: false,
4204
4251
  rejectsThinkingDisabled: false,
4205
4252
  rejectsForcedToolUse: false,
4253
+ supportsBetweenToolsThinking: false,
4206
4254
  isKnownModel: true
4207
4255
  };
4208
4256
  } else if (modelId.includes("claude-3-haiku")) {
@@ -4213,6 +4261,7 @@ function getModelCapabilities(modelId) {
4213
4261
  rejectsThinkingDisabledAboveHighEffort: false,
4214
4262
  rejectsThinkingDisabled: false,
4215
4263
  rejectsForcedToolUse: false,
4264
+ supportsBetweenToolsThinking: false,
4216
4265
  isKnownModel: true
4217
4266
  };
4218
4267
  } else if (/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)) {
@@ -4223,6 +4272,7 @@ function getModelCapabilities(modelId) {
4223
4272
  rejectsThinkingDisabledAboveHighEffort: false,
4224
4273
  rejectsThinkingDisabled: false,
4225
4274
  rejectsForcedToolUse: false,
4275
+ supportsBetweenToolsThinking: false,
4226
4276
  isKnownModel: false
4227
4277
  };
4228
4278
  } else if (modelId.includes("claude-")) {
@@ -4233,6 +4283,7 @@ function getModelCapabilities(modelId) {
4233
4283
  rejectsThinkingDisabledAboveHighEffort: true,
4234
4284
  rejectsThinkingDisabled: false,
4235
4285
  rejectsForcedToolUse: false,
4286
+ supportsBetweenToolsThinking: false,
4236
4287
  isKnownModel: false
4237
4288
  };
4238
4289
  } else {
@@ -4243,6 +4294,7 @@ function getModelCapabilities(modelId) {
4243
4294
  rejectsThinkingDisabledAboveHighEffort: false,
4244
4295
  rejectsThinkingDisabled: false,
4245
4296
  rejectsForcedToolUse: false,
4297
+ supportsBetweenToolsThinking: false,
4246
4298
  isKnownModel: false
4247
4299
  };
4248
4300
  }