@ai-sdk/anthropic 3.0.48 → 3.0.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "3.0.48",
3
+ "version": "3.0.50",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@ai-sdk/provider": "3.0.8",
40
- "@ai-sdk/provider-utils": "4.0.15"
40
+ "@ai-sdk/provider-utils": "4.0.16"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "20.17.24",
@@ -348,8 +348,23 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
348
348
  ...(thinkingBudget != null && { budget_tokens: thinkingBudget }),
349
349
  },
350
350
  }),
351
- ...(anthropicOptions?.effort && {
352
- output_config: { effort: anthropicOptions.effort },
351
+ ...((anthropicOptions?.effort ||
352
+ (useStructuredOutput &&
353
+ responseFormat?.type === 'json' &&
354
+ responseFormat.schema != null)) && {
355
+ output_config: {
356
+ ...(anthropicOptions?.effort && {
357
+ effort: anthropicOptions.effort,
358
+ }),
359
+ ...(useStructuredOutput &&
360
+ responseFormat?.type === 'json' &&
361
+ responseFormat.schema != null && {
362
+ format: {
363
+ type: 'json_schema',
364
+ schema: responseFormat.schema,
365
+ },
366
+ }),
367
+ },
353
368
  }),
354
369
  ...(anthropicOptions?.speed && {
355
370
  speed: anthropicOptions.speed,
@@ -358,16 +373,6 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
358
373
  cache_control: anthropicOptions.cacheControl,
359
374
  }),
360
375
 
361
- // structured output:
362
- ...(useStructuredOutput &&
363
- responseFormat?.type === 'json' &&
364
- responseFormat.schema != null && {
365
- output_format: {
366
- type: 'json_schema',
367
- schema: responseFormat.schema,
368
- },
369
- }),
370
-
371
376
  // mcp servers:
372
377
  ...(anthropicOptions?.mcpServers &&
373
378
  anthropicOptions.mcpServers.length > 0 && {
@@ -590,17 +595,6 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
590
595
  betas.add('fine-grained-tool-streaming-2025-05-14');
591
596
  }
592
597
 
593
- // structured output:
594
- // Only pass beta when actually using native output_format
595
- const usingNativeOutputFormat =
596
- useStructuredOutput &&
597
- responseFormat?.type === 'json' &&
598
- responseFormat.schema != null;
599
-
600
- if (usingNativeOutputFormat) {
601
- betas.add('structured-outputs-2025-11-13');
602
- }
603
-
604
598
  const {
605
599
  tools: anthropicTools,
606
600
  toolChoice: anthropicToolChoice,
@@ -70,7 +70,7 @@ export const anthropicLanguageModelOptions = z.object({
70
70
  /**
71
71
  * Determines how structured outputs are generated.
72
72
  *
73
- * - `outputFormat`: Use the `output_format` parameter to specify the structured output format.
73
+ * - `outputFormat`: Use the `output_config.format` parameter to specify the structured output format.
74
74
  * - `jsonTool`: Use a special 'json' tool to specify the structured output format.
75
75
  * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
76
76
  */