@ai-sdk/anthropic 3.0.0-beta.87 → 3.0.0-beta.88

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.
@@ -1028,6 +1028,9 @@ async function prepareTools({
1028
1028
  )
1029
1029
  } : {}
1030
1030
  });
1031
+ if (supportsStructuredOutput === true) {
1032
+ betas.add("structured-outputs-2025-11-13");
1033
+ }
1031
1034
  if (tool.inputExamples != null) {
1032
1035
  betas.add("advanced-tool-use-2025-11-20");
1033
1036
  }
@@ -2197,7 +2200,7 @@ var AnthropicMessagesLanguageModel = class {
2197
2200
  providerOptions,
2198
2201
  stream
2199
2202
  }) {
2200
- var _a, _b, _c, _d, _e, _f;
2203
+ var _a, _b, _c, _d, _e, _f, _g;
2201
2204
  const warnings = [];
2202
2205
  if (frequencyPenalty != null) {
2203
2206
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2239,10 +2242,11 @@ var AnthropicMessagesLanguageModel = class {
2239
2242
  });
2240
2243
  const {
2241
2244
  maxOutputTokens: maxOutputTokensForModel,
2242
- supportsStructuredOutput,
2245
+ supportsStructuredOutput: modelSupportsStructuredOutput,
2243
2246
  isKnownModel
2244
2247
  } = getModelCapabilities(this.modelId);
2245
- const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : "auto";
2248
+ const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2249
+ const structureOutputMode = (_b = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _b : "auto";
2246
2250
  const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
2247
2251
  const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
2248
2252
  type: "function",
@@ -2274,13 +2278,13 @@ var AnthropicMessagesLanguageModel = class {
2274
2278
  });
2275
2279
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
2276
2280
  prompt,
2277
- sendReasoning: (_b = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _b : true,
2281
+ sendReasoning: (_c = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _c : true,
2278
2282
  warnings,
2279
2283
  cacheControlValidator,
2280
2284
  toolNameMapping
2281
2285
  });
2282
- const isThinking = ((_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type) === "enabled";
2283
- let thinkingBudget = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens;
2286
+ const isThinking = ((_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.type) === "enabled";
2287
+ let thinkingBudget = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.budgetTokens;
2284
2288
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
2285
2289
  const baseArgs = {
2286
2290
  // model id:
@@ -2322,7 +2326,7 @@ var AnthropicMessagesLanguageModel = class {
2322
2326
  ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
2323
2327
  container: {
2324
2328
  id: anthropicOptions.container.id,
2325
- skills: (_e = anthropicOptions.container.skills) == null ? void 0 : _e.map((skill) => ({
2329
+ skills: (_f = anthropicOptions.container.skills) == null ? void 0 : _f.map((skill) => ({
2326
2330
  type: skill.type,
2327
2331
  skill_id: skill.skillId,
2328
2332
  version: skill.version
@@ -2441,10 +2445,11 @@ var AnthropicMessagesLanguageModel = class {
2441
2445
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
2442
2446
  betas.add("effort-2025-11-24");
2443
2447
  }
2444
- if (stream && ((_f = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _f : true)) {
2448
+ if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
2445
2449
  betas.add("fine-grained-tool-streaming-2025-05-14");
2446
2450
  }
2447
- if (useStructuredOutput) {
2451
+ const usingNativeOutputFormat = useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null;
2452
+ if (usingNativeOutputFormat) {
2448
2453
  betas.add("structured-outputs-2025-11-13");
2449
2454
  }
2450
2455
  const {