@ai-sdk/amazon-bedrock 5.0.112 → 5.0.114

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.
@@ -4,7 +4,7 @@ let _ai_sdk_provider = require("@ai-sdk/provider");
4
4
  let _ai_sdk_provider_utils = require("@ai-sdk/provider-utils");
5
5
  let aws4fetch = require("aws4fetch");
6
6
  //#region src/version.ts
7
- const VERSION = "5.0.112";
7
+ const VERSION = "5.0.114";
8
8
  //#endregion
9
9
  //#region src/amazon-bedrock-sigv4-fetch.ts
10
10
  /**
@@ -3,7 +3,7 @@ import { InvalidArgumentError, NoSuchModelError } from "@ai-sdk/provider";
3
3
  import { combineHeaders, getRuntimeEnvironmentUserAgent, isValidHostnamePart, loadOptionalSetting, loadSetting, normalizeHeaders, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
4
4
  import { AwsV4Signer } from "aws4fetch";
5
5
  //#region src/version.ts
6
- const VERSION = "5.0.112";
6
+ const VERSION = "5.0.114";
7
7
  //#endregion
8
8
  //#region src/amazon-bedrock-sigv4-fetch.ts
9
9
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/amazon-bedrock",
3
- "version": "5.0.112",
3
+ "version": "5.0.114",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -41,10 +41,10 @@
41
41
  }
42
42
  },
43
43
  "dependencies": {
44
- "@ai-sdk/anthropic": "4.0.77",
45
- "@ai-sdk/openai": "4.0.90",
46
- "@ai-sdk/provider": "4.0.25",
47
- "@ai-sdk/provider-utils": "5.0.57",
44
+ "@ai-sdk/anthropic": "4.0.79",
45
+ "@ai-sdk/openai": "4.0.92",
46
+ "@ai-sdk/provider": "4.0.27",
47
+ "@ai-sdk/provider-utils": "5.0.59",
48
48
  "@smithy/eventstream-codec": "^4.3.3",
49
49
  "@smithy/util-utf8": "^4.3.3",
50
50
  "aws4fetch": "^1.0.20"
@@ -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
- }
@@ -178,6 +178,7 @@ export class AmazonBedrockChatLanguageModel implements LanguageModelV4 {
178
178
  supportsStructuredOutput: modelSupportsStructuredOutput,
179
179
  rejectsSamplingParameters,
180
180
  rejectsForcedToolUse,
181
+ isKnownModel,
181
182
  } = getModelCapabilities(this.modelId);
182
183
 
183
184
  if (frequencyPenalty != null) {
@@ -341,6 +342,10 @@ export class AmazonBedrockChatLanguageModel implements LanguageModelV4 {
341
342
  responseFormat?.type === 'json' &&
342
343
  responseFormat.schema != null &&
343
344
  (rejectsForcedToolUse ||
345
+ (this.modelId.includes('claude-') &&
346
+ (!isKnownModel || !modelSupportsStructuredOutput) &&
347
+ !supportsNativeStructuredOutput(this.modelId) &&
348
+ structuredOutputMode !== 'jsonTool') ||
344
349
  (structuredOutputMode !== 'jsonTool' &&
345
350
  !supportsStrictTools(this.modelId) &&
346
351
  tools != null &&
@@ -70,6 +70,7 @@ export class AmazonBedrockEmbeddingModel implements EmbeddingModelV4 {
70
70
 
71
71
  async doEmbed({
72
72
  values,
73
+ dimensions,
73
74
  headers,
74
75
  abortSignal,
75
76
  providerOptions,
@@ -113,7 +114,7 @@ export class AmazonBedrockEmbeddingModel implements EmbeddingModelV4 {
113
114
  embeddingPurpose:
114
115
  amazonBedrockOptions.embeddingPurpose ?? 'GENERIC_INDEX',
115
116
  embeddingDimension:
116
- amazonBedrockOptions.embeddingDimension ?? 1024,
117
+ amazonBedrockOptions.embeddingDimension ?? dimensions ?? 1024,
117
118
  text: {
118
119
  truncationMode: amazonBedrockOptions.truncate ?? 'END',
119
120
  value: values[0],
@@ -127,11 +128,12 @@ export class AmazonBedrockEmbeddingModel implements EmbeddingModelV4 {
127
128
  input_type: amazonBedrockOptions.inputType ?? 'search_query',
128
129
  texts: values,
129
130
  truncate: amazonBedrockOptions.truncate,
130
- output_dimension: amazonBedrockOptions.outputDimension,
131
+ output_dimension:
132
+ amazonBedrockOptions.outputDimension ?? dimensions,
131
133
  }
132
134
  : {
133
135
  inputText: values[0],
134
- dimensions: amazonBedrockOptions.dimensions,
136
+ dimensions: amazonBedrockOptions.dimensions ?? dimensions,
135
137
  normalize: amazonBedrockOptions.normalize,
136
138
  };
137
139