@ai-sdk/anthropic 2.0.106 → 2.0.108

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.
@@ -2,7 +2,7 @@ import { LanguageModelV2, JSONSchema7, SharedV2ProviderMetadata, LanguageModelV2
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
- 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 & {});
5
+ 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 & {});
6
6
 
7
7
  type AnthropicMessagesConfig = {
8
8
  provider: string;
@@ -52,6 +52,11 @@ declare function getModelCapabilities(modelId: string): {
52
52
  * Forced tool use (`tool_choice` `any` or a named tool) is rejected with a 400.
53
53
  */
54
54
  rejectsForcedToolUse: boolean;
55
+ /**
56
+ * Supports `thinking.type` `between_tools`, the lowest thinking setting on
57
+ * models that reject disabled thinking.
58
+ */
59
+ supportsBetweenToolsThinking: boolean;
55
60
  isKnownModel: boolean;
56
61
  };
57
62
 
@@ -2,7 +2,7 @@ import { LanguageModelV2, JSONSchema7, SharedV2ProviderMetadata, LanguageModelV2
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
- 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 & {});
5
+ 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 & {});
6
6
 
7
7
  type AnthropicMessagesConfig = {
8
8
  provider: string;
@@ -52,6 +52,11 @@ declare function getModelCapabilities(modelId: string): {
52
52
  * Forced tool use (`tool_choice` `any` or a named tool) is rejected with a 400.
53
53
  */
54
54
  rejectsForcedToolUse: boolean;
55
+ /**
56
+ * Supports `thinking.type` `between_tools`, the lowest thinking setting on
57
+ * models that reject disabled thinking.
58
+ */
59
+ supportsBetweenToolsThinking: boolean;
55
60
  isKnownModel: boolean;
56
61
  };
57
62
 
@@ -726,7 +726,7 @@ var anthropicProviderOptions = import_v43.z.object({
726
726
  *
727
727
  * - `outputFormat`: Use the `output_format` parameter to specify the structured output format.
728
728
  * - `jsonTool`: Use a special JSON response tool to specify the structured output format (default for most models).
729
- * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default for Opus 5.5 and Fable 5.1).
729
+ * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default for Sonnet 5.5, Opus 5.5, and Fable 5.1).
730
730
  */
731
731
  structuredOutputMode: import_v43.z.enum(["outputFormat", "jsonTool", "auto"]).optional(),
732
732
  /**
@@ -739,6 +739,9 @@ var anthropicProviderOptions = import_v43.z.object({
739
739
  * `claude-fable-5-1`) reject `enabled` and `disabled`. For those models the
740
740
  * provider drops the unsupported setting, emits a warning, and sends an
741
741
  * adaptive thinking request. Use `effort` to control how much they think.
742
+ *
743
+ * `claude-sonnet-5-5` supports `between_tools`, its lowest thinking setting,
744
+ * and the provider uses it in place of `disabled` for that model.
742
745
  */
743
746
  thinking: import_v43.z.union([
744
747
  import_v43.z.object({
@@ -770,6 +773,14 @@ var anthropicProviderOptions = import_v43.z.object({
770
773
  import_v43.z.object({
771
774
  type: import_v43.z.literal("disabled")
772
775
  }),
776
+ import_v43.z.object({
777
+ /**
778
+ * for `claude-sonnet-5-5`: no upfront thinking, but progress notes
779
+ * between tool calls are returned as summarized thinking blocks.
780
+ * Only supported at `low`, `medium`, and `high` effort.
781
+ */
782
+ type: import_v43.z.literal("between_tools")
783
+ }),
773
784
  import_v43.z.object({
774
785
  /**
775
786
  * Configure prefix mismatch handling without changing the model's
@@ -2634,6 +2645,7 @@ var AnthropicMessagesLanguageModel = class {
2634
2645
  rejectsThinkingDisabledAboveHighEffort,
2635
2646
  rejectsThinkingDisabled,
2636
2647
  rejectsForcedToolUse,
2648
+ supportsBetweenToolsThinking,
2637
2649
  isKnownModel
2638
2650
  } = getModelCapabilities(this.modelId);
2639
2651
  if (!isKnownModel && maxOutputTokens == null) {
@@ -2669,7 +2681,7 @@ var AnthropicMessagesLanguageModel = class {
2669
2681
  }
2670
2682
  }
2671
2683
  const isAnthropicModel = isKnownModel || this.modelId.includes("claude-");
2672
- 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";
2684
+ 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";
2673
2685
  let useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
2674
2686
  if (!useStructuredOutput && rejectsForcedToolUse && supportsStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) {
2675
2687
  warnings.push({
@@ -2704,7 +2716,14 @@ var AnthropicMessagesLanguageModel = class {
2704
2716
  });
2705
2717
  if (rejectsThinkingDisabled && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) != null) {
2706
2718
  const thinking = anthropicOptions.thinking;
2707
- if ("type" in thinking && thinking.type === "disabled") {
2719
+ if ("type" in thinking && thinking.type === "disabled" && supportsBetweenToolsThinking) {
2720
+ warnings.push({
2721
+ type: "unsupported-setting",
2722
+ setting: "providerOptions.anthropic.thinking",
2723
+ details: `thinking cannot be disabled for ${this.modelId}. Using 'between_tools' thinking, the lowest thinking setting, instead.`
2724
+ });
2725
+ anthropicOptions.thinking = { type: "between_tools" };
2726
+ } else if ("type" in thinking && thinking.type === "disabled") {
2708
2727
  warnings.push({
2709
2728
  type: "unsupported-setting",
2710
2729
  setting: "providerOptions.anthropic.thinking",
@@ -2735,7 +2754,15 @@ var AnthropicMessagesLanguageModel = class {
2735
2754
  });
2736
2755
  anthropicOptions.effort = "high";
2737
2756
  }
2738
- const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
2757
+ if (thinkingType === "between_tools" && anthropicOptions != null && (anthropicOptions.effort === "xhigh" || anthropicOptions.effort === "max")) {
2758
+ warnings.push({
2759
+ type: "unsupported-setting",
2760
+ setting: "providerOptions.anthropic.effort",
2761
+ details: `effort '${anthropicOptions.effort}' is not supported with 'between_tools' thinking. The effort has been lowered to 'high'.`
2762
+ });
2763
+ anthropicOptions.effort = "high";
2764
+ }
2765
+ const isThinking = thinkingType === "enabled" || thinkingType === "adaptive" || thinkingType === "between_tools";
2739
2766
  let thinkingBudget = thinkingOptions != null && "budgetTokens" in thinkingOptions ? thinkingOptions.budgetTokens : void 0;
2740
2767
  const thinkingDisplay = thinkingOptions != null && "display" in thinkingOptions ? thinkingOptions.display : void 0;
2741
2768
  const thinkingBlockBinding = thinkingOptions != null && "blockBinding" in thinkingOptions ? thinkingOptions.blockBinding : void 0;
@@ -4100,7 +4127,18 @@ var AnthropicMessagesLanguageModel = class {
4100
4127
  }
4101
4128
  };
4102
4129
  function getModelCapabilities(modelId) {
4103
- if (modelId.includes("claude-opus-5-5")) {
4130
+ if (modelId.includes("claude-sonnet-5-5")) {
4131
+ return {
4132
+ maxOutputTokens: 128e3,
4133
+ supportsStructuredOutput: true,
4134
+ rejectsSamplingParameters: true,
4135
+ rejectsThinkingDisabledAboveHighEffort: true,
4136
+ rejectsThinkingDisabled: true,
4137
+ rejectsForcedToolUse: true,
4138
+ supportsBetweenToolsThinking: true,
4139
+ isKnownModel: true
4140
+ };
4141
+ } else if (modelId.includes("claude-opus-5-5")) {
4104
4142
  return {
4105
4143
  maxOutputTokens: 128e3,
4106
4144
  supportsStructuredOutput: true,
@@ -4108,6 +4146,7 @@ function getModelCapabilities(modelId) {
4108
4146
  rejectsThinkingDisabledAboveHighEffort: true,
4109
4147
  rejectsThinkingDisabled: true,
4110
4148
  rejectsForcedToolUse: true,
4149
+ supportsBetweenToolsThinking: false,
4111
4150
  isKnownModel: true
4112
4151
  };
4113
4152
  } else if (modelId.includes("claude-opus-5")) {
@@ -4118,6 +4157,7 @@ function getModelCapabilities(modelId) {
4118
4157
  rejectsThinkingDisabledAboveHighEffort: true,
4119
4158
  rejectsThinkingDisabled: false,
4120
4159
  rejectsForcedToolUse: false,
4160
+ supportsBetweenToolsThinking: false,
4121
4161
  isKnownModel: true
4122
4162
  };
4123
4163
  } else if (modelId.includes("claude-fable-5-1")) {
@@ -4128,6 +4168,7 @@ function getModelCapabilities(modelId) {
4128
4168
  rejectsThinkingDisabledAboveHighEffort: false,
4129
4169
  rejectsThinkingDisabled: true,
4130
4170
  rejectsForcedToolUse: true,
4171
+ supportsBetweenToolsThinking: false,
4131
4172
  isKnownModel: true
4132
4173
  };
4133
4174
  } else if (modelId.includes("claude-fable-5")) {
@@ -4138,6 +4179,7 @@ function getModelCapabilities(modelId) {
4138
4179
  rejectsThinkingDisabledAboveHighEffort: false,
4139
4180
  rejectsThinkingDisabled: true,
4140
4181
  rejectsForcedToolUse: false,
4182
+ supportsBetweenToolsThinking: false,
4141
4183
  isKnownModel: true
4142
4184
  };
4143
4185
  } else if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-sonnet-5")) {
@@ -4148,6 +4190,7 @@ function getModelCapabilities(modelId) {
4148
4190
  rejectsThinkingDisabledAboveHighEffort: false,
4149
4191
  rejectsThinkingDisabled: false,
4150
4192
  rejectsForcedToolUse: false,
4193
+ supportsBetweenToolsThinking: false,
4151
4194
  isKnownModel: true
4152
4195
  };
4153
4196
  } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
@@ -4158,6 +4201,7 @@ function getModelCapabilities(modelId) {
4158
4201
  rejectsThinkingDisabledAboveHighEffort: false,
4159
4202
  rejectsThinkingDisabled: false,
4160
4203
  rejectsForcedToolUse: false,
4204
+ supportsBetweenToolsThinking: false,
4161
4205
  isKnownModel: true
4162
4206
  };
4163
4207
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
@@ -4168,6 +4212,7 @@ function getModelCapabilities(modelId) {
4168
4212
  rejectsThinkingDisabledAboveHighEffort: false,
4169
4213
  rejectsThinkingDisabled: false,
4170
4214
  rejectsForcedToolUse: false,
4215
+ supportsBetweenToolsThinking: false,
4171
4216
  isKnownModel: true
4172
4217
  };
4173
4218
  } else if (modelId.includes("claude-opus-4-1")) {
@@ -4178,6 +4223,7 @@ function getModelCapabilities(modelId) {
4178
4223
  rejectsThinkingDisabledAboveHighEffort: false,
4179
4224
  rejectsThinkingDisabled: false,
4180
4225
  rejectsForcedToolUse: false,
4226
+ supportsBetweenToolsThinking: false,
4181
4227
  isKnownModel: true
4182
4228
  };
4183
4229
  } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
@@ -4188,6 +4234,7 @@ function getModelCapabilities(modelId) {
4188
4234
  rejectsThinkingDisabledAboveHighEffort: false,
4189
4235
  rejectsThinkingDisabled: false,
4190
4236
  rejectsForcedToolUse: false,
4237
+ supportsBetweenToolsThinking: false,
4191
4238
  isKnownModel: true
4192
4239
  };
4193
4240
  } else if (modelId.includes("claude-opus-4-")) {
@@ -4198,6 +4245,7 @@ function getModelCapabilities(modelId) {
4198
4245
  rejectsThinkingDisabledAboveHighEffort: false,
4199
4246
  rejectsThinkingDisabled: false,
4200
4247
  rejectsForcedToolUse: false,
4248
+ supportsBetweenToolsThinking: false,
4201
4249
  isKnownModel: true
4202
4250
  };
4203
4251
  } else if (modelId.includes("claude-3-haiku")) {
@@ -4208,6 +4256,7 @@ function getModelCapabilities(modelId) {
4208
4256
  rejectsThinkingDisabledAboveHighEffort: false,
4209
4257
  rejectsThinkingDisabled: false,
4210
4258
  rejectsForcedToolUse: false,
4259
+ supportsBetweenToolsThinking: false,
4211
4260
  isKnownModel: true
4212
4261
  };
4213
4262
  } else if (/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)) {
@@ -4218,6 +4267,7 @@ function getModelCapabilities(modelId) {
4218
4267
  rejectsThinkingDisabledAboveHighEffort: false,
4219
4268
  rejectsThinkingDisabled: false,
4220
4269
  rejectsForcedToolUse: false,
4270
+ supportsBetweenToolsThinking: false,
4221
4271
  isKnownModel: false
4222
4272
  };
4223
4273
  } else if (modelId.includes("claude-")) {
@@ -4228,6 +4278,7 @@ function getModelCapabilities(modelId) {
4228
4278
  rejectsThinkingDisabledAboveHighEffort: true,
4229
4279
  rejectsThinkingDisabled: false,
4230
4280
  rejectsForcedToolUse: false,
4281
+ supportsBetweenToolsThinking: false,
4231
4282
  isKnownModel: false
4232
4283
  };
4233
4284
  } else {
@@ -4238,6 +4289,7 @@ function getModelCapabilities(modelId) {
4238
4289
  rejectsThinkingDisabledAboveHighEffort: false,
4239
4290
  rejectsThinkingDisabled: false,
4240
4291
  rejectsForcedToolUse: false,
4292
+ supportsBetweenToolsThinking: false,
4241
4293
  isKnownModel: false
4242
4294
  };
4243
4295
  }