@ai-sdk/anthropic 4.0.0-beta.2 → 4.0.0-beta.4

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,17 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.0-beta.4
4
+
5
+ ### Patch Changes
6
+
7
+ - f05a40d: fix(vertex): throw warning when strict: true for vertexAnthropic
8
+
9
+ ## 4.0.0-beta.3
10
+
11
+ ### Patch Changes
12
+
13
+ - e748b35: chore: update v3 specs to v4
14
+
3
15
  ## 4.0.0-beta.2
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { JSONObject, ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
1
+ import { JSONObject, ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
2
2
  import { z } from 'zod/v4';
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
@@ -1007,17 +1007,17 @@ declare const anthropicTools: {
1007
1007
  }[]>;
1008
1008
  };
1009
1009
 
1010
- interface AnthropicProvider extends ProviderV3 {
1010
+ interface AnthropicProvider extends ProviderV4 {
1011
1011
  /**
1012
1012
  * Creates a model for text generation.
1013
1013
  */
1014
- (modelId: AnthropicMessagesModelId): LanguageModelV3;
1014
+ (modelId: AnthropicMessagesModelId): LanguageModelV4;
1015
1015
  /**
1016
1016
  * Creates a model for text generation.
1017
1017
  */
1018
- languageModel(modelId: AnthropicMessagesModelId): LanguageModelV3;
1019
- chat(modelId: AnthropicMessagesModelId): LanguageModelV3;
1020
- messages(modelId: AnthropicMessagesModelId): LanguageModelV3;
1018
+ languageModel(modelId: AnthropicMessagesModelId): LanguageModelV4;
1019
+ chat(modelId: AnthropicMessagesModelId): LanguageModelV4;
1020
+ messages(modelId: AnthropicMessagesModelId): LanguageModelV4;
1021
1021
  /**
1022
1022
  * @deprecated Use `embeddingModel` instead.
1023
1023
  */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { JSONObject, ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
1
+ import { JSONObject, ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
2
2
  import { z } from 'zod/v4';
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
@@ -1007,17 +1007,17 @@ declare const anthropicTools: {
1007
1007
  }[]>;
1008
1008
  };
1009
1009
 
1010
- interface AnthropicProvider extends ProviderV3 {
1010
+ interface AnthropicProvider extends ProviderV4 {
1011
1011
  /**
1012
1012
  * Creates a model for text generation.
1013
1013
  */
1014
- (modelId: AnthropicMessagesModelId): LanguageModelV3;
1014
+ (modelId: AnthropicMessagesModelId): LanguageModelV4;
1015
1015
  /**
1016
1016
  * Creates a model for text generation.
1017
1017
  */
1018
- languageModel(modelId: AnthropicMessagesModelId): LanguageModelV3;
1019
- chat(modelId: AnthropicMessagesModelId): LanguageModelV3;
1020
- messages(modelId: AnthropicMessagesModelId): LanguageModelV3;
1018
+ languageModel(modelId: AnthropicMessagesModelId): LanguageModelV4;
1019
+ chat(modelId: AnthropicMessagesModelId): LanguageModelV4;
1020
+ messages(modelId: AnthropicMessagesModelId): LanguageModelV4;
1021
1021
  /**
1022
1022
  * @deprecated Use `embeddingModel` instead.
1023
1023
  */
package/dist/index.js CHANGED
@@ -18,21 +18,21 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  VERSION: () => VERSION,
24
24
  anthropic: () => anthropic,
25
25
  createAnthropic: () => createAnthropic,
26
26
  forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep
27
27
  });
28
- module.exports = __toCommonJS(src_exports);
28
+ module.exports = __toCommonJS(index_exports);
29
29
 
30
30
  // src/anthropic-provider.ts
31
31
  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 ? "4.0.0-beta.2" : "0.0.0-test";
35
+ var VERSION = true ? "4.0.0-beta.4" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -1269,7 +1269,8 @@ async function prepareTools({
1269
1269
  toolChoice,
1270
1270
  disableParallelToolUse,
1271
1271
  cacheControlValidator,
1272
- supportsStructuredOutput
1272
+ supportsStructuredOutput,
1273
+ supportsStrictTools
1273
1274
  }) {
1274
1275
  var _a;
1275
1276
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
@@ -1291,13 +1292,20 @@ async function prepareTools({
1291
1292
  const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
1292
1293
  const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
1293
1294
  const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
1295
+ if (!supportsStrictTools && tool.strict != null) {
1296
+ toolWarnings.push({
1297
+ type: "unsupported",
1298
+ feature: "strict",
1299
+ details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
1300
+ });
1301
+ }
1294
1302
  anthropicTools2.push({
1295
1303
  name: tool.name,
1296
1304
  description: tool.description,
1297
1305
  input_schema: tool.inputSchema,
1298
1306
  cache_control: cacheControl,
1299
1307
  ...eagerInputStreaming ? { eager_input_streaming: true } : {},
1300
- ...supportsStructuredOutput === true && tool.strict != null ? { strict: tool.strict } : {},
1308
+ ...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
1301
1309
  ...deferLoading != null ? { defer_loading: deferLoading } : {},
1302
1310
  ...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
1303
1311
  ...tool.inputExamples != null ? {
@@ -2830,7 +2838,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
2830
2838
  }
2831
2839
  var AnthropicMessagesLanguageModel = class {
2832
2840
  constructor(modelId, config) {
2833
- this.specificationVersion = "v3";
2841
+ this.specificationVersion = "v4";
2834
2842
  var _a;
2835
2843
  this.modelId = modelId;
2836
2844
  this.config = config;
@@ -2872,7 +2880,7 @@ var AnthropicMessagesLanguageModel = class {
2872
2880
  providerOptions,
2873
2881
  stream
2874
2882
  }) {
2875
- var _a, _b, _c, _d, _e, _f, _g;
2883
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2876
2884
  const warnings = [];
2877
2885
  if (frequencyPenalty != null) {
2878
2886
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2930,7 +2938,8 @@ var AnthropicMessagesLanguageModel = class {
2930
2938
  isKnownModel
2931
2939
  } = getModelCapabilities(this.modelId);
2932
2940
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2933
- const structureOutputMode = (_b = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _b : "auto";
2941
+ const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
2942
+ const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
2934
2943
  const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
2935
2944
  const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
2936
2945
  type: "function",
@@ -2965,14 +2974,14 @@ var AnthropicMessagesLanguageModel = class {
2965
2974
  });
2966
2975
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
2967
2976
  prompt,
2968
- sendReasoning: (_c = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _c : true,
2977
+ sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
2969
2978
  warnings,
2970
2979
  cacheControlValidator,
2971
2980
  toolNameMapping
2972
2981
  });
2973
- const thinkingType = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.type;
2982
+ const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
2974
2983
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
2975
- let thinkingBudget = thinkingType === "enabled" ? (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.budgetTokens : void 0;
2984
+ let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
2976
2985
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
2977
2986
  const baseArgs = {
2978
2987
  // model id:
@@ -3179,7 +3188,7 @@ var AnthropicMessagesLanguageModel = class {
3179
3188
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3180
3189
  betas.add("fast-mode-2026-02-01");
3181
3190
  }
3182
- if (stream && ((_f = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _f : true)) {
3191
+ if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
3183
3192
  betas.add("fine-grained-tool-streaming-2025-05-14");
3184
3193
  }
3185
3194
  const {
@@ -3193,13 +3202,15 @@ var AnthropicMessagesLanguageModel = class {
3193
3202
  toolChoice: { type: "required" },
3194
3203
  disableParallelToolUse: true,
3195
3204
  cacheControlValidator,
3196
- supportsStructuredOutput: false
3205
+ supportsStructuredOutput: false,
3206
+ supportsStrictTools
3197
3207
  } : {
3198
3208
  tools: tools != null ? tools : [],
3199
3209
  toolChoice,
3200
3210
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
3201
3211
  cacheControlValidator,
3202
- supportsStructuredOutput
3212
+ supportsStructuredOutput,
3213
+ supportsStrictTools
3203
3214
  }
3204
3215
  );
3205
3216
  const cacheWarnings = cacheControlValidator.getWarnings();
@@ -3216,7 +3227,7 @@ var AnthropicMessagesLanguageModel = class {
3216
3227
  ...betas,
3217
3228
  ...toolsBetas,
3218
3229
  ...userSuppliedBetas,
3219
- ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
3230
+ ...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
3220
3231
  ]),
3221
3232
  usesJsonResponseTool: jsonResponseTool != null,
3222
3233
  toolNameMapping,
@@ -5112,7 +5123,7 @@ function createAnthropic(options = {}) {
5112
5123
  }
5113
5124
  return createChatModel(modelId);
5114
5125
  };
5115
- provider.specificationVersion = "v3";
5126
+ provider.specificationVersion = "v4";
5116
5127
  provider.languageModel = createChatModel;
5117
5128
  provider.chat = createChatModel;
5118
5129
  provider.messages = createChatModel;