@ai-sdk/amazon-bedrock 4.0.193 → 4.0.195

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.
@@ -35,7 +35,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
35
35
  var import_aws4fetch = require("aws4fetch");
36
36
 
37
37
  // src/version.ts
38
- var VERSION = true ? "4.0.193" : "0.0.0-test";
38
+ var VERSION = true ? "4.0.195" : "0.0.0-test";
39
39
 
40
40
  // src/bedrock-sigv4-fetch.ts
41
41
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
@@ -23,7 +23,7 @@ import {
23
23
  import { AwsV4Signer } from "aws4fetch";
24
24
 
25
25
  // src/version.ts
26
- var VERSION = true ? "4.0.193" : "0.0.0-test";
26
+ var VERSION = true ? "4.0.195" : "0.0.0-test";
27
27
 
28
28
  // src/bedrock-sigv4-fetch.ts
29
29
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/amazon-bedrock",
3
- "version": "4.0.193",
3
+ "version": "4.0.195",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -44,8 +44,8 @@
44
44
  "@smithy/eventstream-codec": "^4.0.1",
45
45
  "@smithy/util-utf8": "^4.0.0",
46
46
  "aws4fetch": "^1.0.20",
47
- "@ai-sdk/anthropic": "3.0.128",
48
- "@ai-sdk/openai": "3.0.124",
47
+ "@ai-sdk/anthropic": "3.0.129",
48
+ "@ai-sdk/openai": "3.0.126",
49
49
  "@ai-sdk/provider": "3.0.18",
50
50
  "@ai-sdk/provider-utils": "4.0.57"
51
51
  },
@@ -17,37 +17,31 @@ export function isAnthropicModel({
17
17
  );
18
18
  }
19
19
 
20
+ // Bedrock validates its own Messages schema. New Claude generations currently
21
+ // reject native structured output and strict tools, so only known supported
22
+ // Claude models receive those fields. Non-Claude models and opaque inference
23
+ // profile IDs retain their existing behavior.
20
24
  export function supportsStrictTools(modelId: string): boolean {
21
- return !matchesModel(modelId, MODELS_WITHOUT_STRICT_TOOL_SUPPORT);
25
+ return (
26
+ !modelId.includes('claude-') ||
27
+ LEGACY_CLAUDE_PATTERN.test(modelId) ||
28
+ MODELS_WITH_STRICT_TOOL_SUPPORT.some(pattern => pattern.test(modelId))
29
+ );
22
30
  }
23
31
 
24
32
  export function supportsNativeStructuredOutput(modelId: string): boolean {
25
- return !matchesModel(
26
- modelId,
27
- MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT,
33
+ return (
34
+ supportsStrictTools(modelId) &&
35
+ !/claude-(?:sonnet-4-6|haiku-4-5)(?=[-.:]|$)/.test(modelId)
28
36
  );
29
37
  }
30
38
 
31
- // Bedrock validates against its own copy of the Messages schema, which rejects
32
- // `output_config.format` and tool `strict` for the newest Claude models
33
- const MODELS_WITHOUT_STRICT_TOOL_SUPPORT = [
34
- 'claude-opus-4-7',
35
- 'claude-opus-4-8',
36
- 'claude-opus-5',
37
- 'claude-fable-5',
38
- 'claude-sonnet-5',
39
- 'claude-haiku-5-5',
40
- ];
39
+ const LEGACY_CLAUDE_PATTERN = /claude-(?:instant|v?2|3)(?=[-.:]|$)/;
41
40
 
42
- // Native structured output is unreliable for additional models even though
43
- // their strict tool support remains available. Sonnet 4.6 can fail to adhere
44
- // to complex schemas, while Haiku 4.5 support varies between Bedrock accounts.
45
- const MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT = [
46
- ...MODELS_WITHOUT_STRICT_TOOL_SUPPORT,
47
- 'claude-sonnet-4-6',
48
- 'claude-haiku-4-5',
41
+ const MODELS_WITH_STRICT_TOOL_SUPPORT = [
42
+ // Original Claude 4 IDs include a release date instead of a minor version.
43
+ /claude-(?:opus|sonnet)-4(?:-\d{8})?(?:-v\d+)?(?=[:.]|$)/,
44
+ /claude-opus-4-(?:1|5|6)(?=[-.:]|$)/,
45
+ /claude-sonnet-4-(?:5|6)(?=[-.:]|$)/,
46
+ /claude-haiku-4-5(?=[-.:]|$)/,
49
47
  ];
50
-
51
- function matchesModel(modelId: string, models: string[]): boolean {
52
- return models.some(model => modelId.includes(model));
53
- }
@@ -187,6 +187,7 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
187
187
  const {
188
188
  supportsStructuredOutput: modelSupportsStructuredOutput,
189
189
  rejectsForcedToolUse,
190
+ isKnownModel,
190
191
  } = getModelCapabilities(this.modelId);
191
192
 
192
193
  const structuredOutputMode =
@@ -240,6 +241,10 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
240
241
  responseFormat?.type === 'json' &&
241
242
  responseFormat.schema != null &&
242
243
  (rejectsForcedToolUse ||
244
+ (this.modelId.includes('claude-') &&
245
+ (!isKnownModel || !modelSupportsStructuredOutput) &&
246
+ !supportsNativeStructuredOutput(this.modelId) &&
247
+ structuredOutputMode !== 'jsonTool') ||
243
248
  (structuredOutputMode !== 'jsonTool' &&
244
249
  !supportsStrictTools(this.modelId) &&
245
250
  tools != null &&