@ai-sdk/amazon-bedrock 5.0.13 → 5.0.15

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,26 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 5.0.15
4
+
5
+ ### Patch Changes
6
+
7
+ - 5cd0e38: feat(amazon-bedrock): add `providerOptions` schema and type for Bedrock image model requests
8
+ - Updated dependencies [fdb6d5d]
9
+ - Updated dependencies [0f93c57]
10
+ - @ai-sdk/openai@4.0.10
11
+ - @ai-sdk/provider@4.0.3
12
+ - @ai-sdk/anthropic@4.0.11
13
+ - @ai-sdk/provider-utils@5.0.7
14
+
15
+ ## 5.0.14
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [ac306ed]
20
+ - @ai-sdk/provider-utils@5.0.6
21
+ - @ai-sdk/openai@4.0.9
22
+ - @ai-sdk/anthropic@4.0.10
23
+
3
24
  ## 5.0.13
4
25
 
5
26
  ### Patch Changes
@@ -24,7 +24,7 @@ import {
24
24
  import { AwsV4Signer } from "aws4fetch";
25
25
 
26
26
  // src/version.ts
27
- var VERSION = true ? "5.0.13" : "0.0.0-test";
27
+ var VERSION = true ? "5.0.15" : "0.0.0-test";
28
28
 
29
29
  // src/amazon-bedrock-sigv4-fetch.ts
30
30
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export { AnthropicProviderOptions } from '@ai-sdk/anthropic';
2
2
  import { z } from 'zod/v4';
3
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
+ import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
3
5
  import { anthropicTools } from '@ai-sdk/anthropic/internal';
4
6
  import { ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, RerankingModelV4 } from '@ai-sdk/provider';
5
- import { FetchFunction } from '@ai-sdk/provider-utils';
6
7
 
7
8
  type AmazonBedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
8
9
  declare const amazonBedrockEmbeddingModelOptionsSchema: z.ZodObject<{
@@ -35,6 +36,18 @@ declare const amazonBedrockEmbeddingModelOptionsSchema: z.ZodObject<{
35
36
  }, z.core.$strip>;
36
37
  type AmazonBedrockEmbeddingModelOptions = z.infer<typeof amazonBedrockEmbeddingModelOptionsSchema>;
37
38
 
39
+ declare const amazonBedrockImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
40
+ quality?: "standard" | "premium" | undefined;
41
+ negativeText?: string | undefined;
42
+ cfgScale?: number | undefined;
43
+ style?: "3D_ANIMATED_FAMILY_FILM" | "DESIGN_SKETCH" | "FLAT_VECTOR_ILLUSTRATION" | "GRAPHIC_NOVEL_ILLUSTRATION" | "MAXIMALISM" | "MIDCENTURY_RETRO" | "PHOTOREALISM" | "SOFT_DIGITAL_PAINTING" | undefined;
44
+ taskType?: "TEXT_IMAGE" | "IMAGE_VARIATION" | "INPAINTING" | "OUTPAINTING" | "BACKGROUND_REMOVAL" | undefined;
45
+ maskPrompt?: string | undefined;
46
+ outPaintingMode?: "DEFAULT" | "PRECISE" | undefined;
47
+ similarityStrength?: number | undefined;
48
+ }>;
49
+ type AmazonBedrockImageModelOptions = InferSchema<typeof amazonBedrockImageModelOptionsSchema>;
50
+
38
51
  type AmazonBedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-5' | 'anthropic.claude-fable-5' | 'anthropic.claude-opus-4-8' | 'anthropic.claude-opus-4-7' | 'anthropic.claude-opus-4-6-v1' | 'anthropic.claude-sonnet-4-6-v1' | 'anthropic.claude-opus-4-5-20251101-v1:0' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'openai.gpt-oss-120b-1:0' | 'openai.gpt-oss-20b-1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | 'us.amazon.nova-premier-v1:0' | 'us.amazon.nova-pro-v1:0' | 'us.amazon.nova-micro-v1:0' | 'us.amazon.nova-lite-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-sonnet-5' | 'us.anthropic.claude-fable-5' | 'us.anthropic.claude-opus-4-8' | 'us.anthropic.claude-opus-4-7' | 'us.anthropic.claude-opus-4-6-v1' | 'us.anthropic.claude-sonnet-4-6-v1' | 'us.anthropic.claude-opus-4-5-20251101-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.anthropic.claude-haiku-4-5-20251001-v1:0' | 'us.meta.llama3-2-11b-instruct-v1:0' | 'us.meta.llama3-2-3b-instruct-v1:0' | 'us.meta.llama3-2-90b-instruct-v1:0' | 'us.meta.llama3-2-1b-instruct-v1:0' | 'us.meta.llama3-1-8b-instruct-v1:0' | 'us.meta.llama3-1-70b-instruct-v1:0' | 'us.meta.llama3-3-70b-instruct-v1:0' | 'us.deepseek.r1-v1:0' | 'us.mistral.pixtral-large-2502-v1:0' | 'us.meta.llama4-scout-17b-instruct-v1:0' | 'us.meta.llama4-maverick-17b-instruct-v1:0' | (string & {});
39
52
  declare const amazonBedrockLanguageModelChatOptions: z.ZodObject<{
40
53
  additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -204,4 +217,4 @@ declare const amazonBedrock: AmazonBedrockProvider;
204
217
 
205
218
  declare const VERSION: string;
206
219
 
207
- export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockLanguageModelChatOptions, type AmazonBedrockLanguageModelChatOptions as AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelChatOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, amazonBedrock, amazonBedrock as bedrock, createAmazonBedrock };
220
+ export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockImageModelOptions, type AmazonBedrockLanguageModelChatOptions, type AmazonBedrockLanguageModelChatOptions as AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelChatOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, amazonBedrock, amazonBedrock as bedrock, createAmazonBedrock };
package/dist/index.js CHANGED
@@ -1990,6 +1990,7 @@ import {
1990
1990
  convertUint8ArrayToBase64,
1991
1991
  createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
1992
1992
  createJsonResponseHandler as createJsonResponseHandler3,
1993
+ parseProviderOptions as parseProviderOptions4,
1993
1994
  postJsonToApi as postJsonToApi3,
1994
1995
  resolve as resolve3,
1995
1996
  serializeModelOptions as serializeModelOptions3,
@@ -2002,8 +2003,44 @@ var modelMaxImagesPerCall = {
2002
2003
  "amazon.nova-canvas-v1:0": 5
2003
2004
  };
2004
2005
 
2005
- // src/amazon-bedrock-image-model.ts
2006
+ // src/amazon-bedrock-image-model-options.ts
2007
+ import {
2008
+ lazySchema,
2009
+ zodSchema
2010
+ } from "@ai-sdk/provider-utils";
2006
2011
  import { z as z7 } from "zod/v4";
2012
+ var amazonBedrockImageModelOptionsSchema = lazySchema(
2013
+ () => zodSchema(
2014
+ z7.object({
2015
+ quality: z7.enum(["standard", "premium"]).optional(),
2016
+ negativeText: z7.string().optional(),
2017
+ cfgScale: z7.number().optional(),
2018
+ style: z7.enum([
2019
+ "3D_ANIMATED_FAMILY_FILM",
2020
+ "DESIGN_SKETCH",
2021
+ "FLAT_VECTOR_ILLUSTRATION",
2022
+ "GRAPHIC_NOVEL_ILLUSTRATION",
2023
+ "MAXIMALISM",
2024
+ "MIDCENTURY_RETRO",
2025
+ "PHOTOREALISM",
2026
+ "SOFT_DIGITAL_PAINTING"
2027
+ ]).optional(),
2028
+ taskType: z7.enum([
2029
+ "TEXT_IMAGE",
2030
+ "IMAGE_VARIATION",
2031
+ "INPAINTING",
2032
+ "OUTPAINTING",
2033
+ "BACKGROUND_REMOVAL"
2034
+ ]).optional(),
2035
+ maskPrompt: z7.string().optional(),
2036
+ outPaintingMode: z7.enum(["DEFAULT", "PRECISE"]).optional(),
2037
+ similarityStrength: z7.number().optional()
2038
+ })
2039
+ )
2040
+ );
2041
+
2042
+ // src/amazon-bedrock-image-model.ts
2043
+ import { z as z8 } from "zod/v4";
2007
2044
  var AmazonBedrockImageModel = class _AmazonBedrockImageModel {
2008
2045
  constructor(modelId, config) {
2009
2046
  this.modelId = modelId;
@@ -2040,11 +2077,19 @@ var AmazonBedrockImageModel = class _AmazonBedrockImageModel {
2040
2077
  files,
2041
2078
  mask
2042
2079
  }) {
2043
- var _a, _b, _c, _d, _e, _f;
2080
+ var _a, _b, _c, _d, _e, _f, _g;
2044
2081
  const warnings = [];
2045
2082
  const [width, height] = size ? size.split("x").map(Number) : [];
2046
2083
  const hasFiles = files != null && files.length > 0;
2047
- const amazonBedrockOptions = (_a = providerOptions == null ? void 0 : providerOptions.amazonBedrock) != null ? _a : providerOptions == null ? void 0 : providerOptions.bedrock;
2084
+ const amazonBedrockOptions = (_b = (_a = await parseProviderOptions4({
2085
+ provider: "amazonBedrock",
2086
+ providerOptions,
2087
+ schema: amazonBedrockImageModelOptionsSchema
2088
+ })) != null ? _a : await parseProviderOptions4({
2089
+ provider: "bedrock",
2090
+ providerOptions,
2091
+ schema: amazonBedrockImageModelOptionsSchema
2092
+ })) != null ? _b : {};
2048
2093
  const imageGenerationConfig = {
2049
2094
  ...width ? { width } : {},
2050
2095
  ...height ? { height } : {},
@@ -2057,7 +2102,7 @@ var AmazonBedrockImageModel = class _AmazonBedrockImageModel {
2057
2102
  if (hasFiles) {
2058
2103
  const hasMask = (mask == null ? void 0 : mask.type) != null;
2059
2104
  const hasMaskPrompt = (amazonBedrockOptions == null ? void 0 : amazonBedrockOptions.maskPrompt) != null;
2060
- const taskType = (_b = amazonBedrockOptions == null ? void 0 : amazonBedrockOptions.taskType) != null ? _b : hasMask || hasMaskPrompt ? "INPAINTING" : "IMAGE_VARIATION";
2105
+ const taskType = (_c = amazonBedrockOptions == null ? void 0 : amazonBedrockOptions.taskType) != null ? _c : hasMask || hasMaskPrompt ? "INPAINTING" : "IMAGE_VARIATION";
2061
2106
  const sourceImageBase64 = getBase64Data(files[0]);
2062
2107
  switch (taskType) {
2063
2108
  case "INPAINTING": {
@@ -2148,7 +2193,7 @@ var AmazonBedrockImageModel = class _AmazonBedrockImageModel {
2148
2193
  details: "This model does not support aspect ratio. Use `size` instead."
2149
2194
  });
2150
2195
  }
2151
- const currentDate = (_e = (_d = (_c = this.config._internal) == null ? void 0 : _c.currentDate) == null ? void 0 : _d.call(_c)) != null ? _e : /* @__PURE__ */ new Date();
2196
+ const currentDate = (_f = (_e = (_d = this.config._internal) == null ? void 0 : _d.currentDate) == null ? void 0 : _e.call(_d)) != null ? _f : /* @__PURE__ */ new Date();
2152
2197
  const { value: response, responseHeaders } = await postJsonToApi3({
2153
2198
  url: this.getUrl(this.modelId),
2154
2199
  headers: await resolve3(
@@ -2169,7 +2214,7 @@ var AmazonBedrockImageModel = class _AmazonBedrockImageModel {
2169
2214
  fetch: this.config.fetch
2170
2215
  });
2171
2216
  if (response.status === "Request Moderated") {
2172
- const moderationReasons = (_f = response.details) == null ? void 0 : _f["Moderation Reasons"];
2217
+ const moderationReasons = (_g = response.details) == null ? void 0 : _g["Moderation Reasons"];
2173
2218
  const reasons = Array.isArray(moderationReasons) ? moderationReasons : ["Unknown"];
2174
2219
  throw new Error(
2175
2220
  `Amazon Bedrock request was moderated: ${reasons.join(", ")}`
@@ -2202,16 +2247,16 @@ function getBase64Data(file) {
2202
2247
  }
2203
2248
  return file.data;
2204
2249
  }
2205
- var amazonBedrockImageResponseSchema = z7.object({
2250
+ var amazonBedrockImageResponseSchema = z8.object({
2206
2251
  // Normal successful response
2207
- images: z7.array(z7.string()).optional(),
2252
+ images: z8.array(z8.string()).optional(),
2208
2253
  // Moderation response fields
2209
- id: z7.string().optional(),
2210
- status: z7.string().optional(),
2211
- result: z7.unknown().optional(),
2212
- progress: z7.unknown().optional(),
2213
- details: z7.record(z7.string(), z7.unknown()).optional(),
2214
- preview: z7.unknown().optional()
2254
+ id: z8.string().optional(),
2255
+ status: z8.string().optional(),
2256
+ result: z8.unknown().optional(),
2257
+ progress: z8.unknown().optional(),
2258
+ details: z8.record(z8.string(), z8.unknown()).optional(),
2259
+ preview: z8.unknown().optional()
2215
2260
  });
2216
2261
 
2217
2262
  // src/amazon-bedrock-sigv4-fetch.ts
@@ -2224,7 +2269,7 @@ import {
2224
2269
  import { AwsV4Signer } from "aws4fetch";
2225
2270
 
2226
2271
  // src/version.ts
2227
- var VERSION = true ? "5.0.13" : "0.0.0-test";
2272
+ var VERSION = true ? "5.0.15" : "0.0.0-test";
2228
2273
 
2229
2274
  // src/amazon-bedrock-sigv4-fetch.ts
2230
2275
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
@@ -2314,42 +2359,42 @@ import {
2314
2359
  combineHeaders as combineHeaders5,
2315
2360
  createJsonErrorResponseHandler as createJsonErrorResponseHandler4,
2316
2361
  createJsonResponseHandler as createJsonResponseHandler4,
2317
- parseProviderOptions as parseProviderOptions4,
2362
+ parseProviderOptions as parseProviderOptions5,
2318
2363
  postJsonToApi as postJsonToApi4,
2319
2364
  resolve as resolve4
2320
2365
  } from "@ai-sdk/provider-utils";
2321
2366
 
2322
2367
  // src/reranking/amazon-bedrock-reranking-api.ts
2323
- import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
2324
- import { z as z8 } from "zod/v4";
2325
- var amazonBedrockRerankingResponseSchema = lazySchema(
2326
- () => zodSchema(
2327
- z8.object({
2328
- results: z8.array(
2329
- z8.object({
2330
- index: z8.number(),
2331
- relevanceScore: z8.number()
2368
+ import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
2369
+ import { z as z9 } from "zod/v4";
2370
+ var amazonBedrockRerankingResponseSchema = lazySchema2(
2371
+ () => zodSchema2(
2372
+ z9.object({
2373
+ results: z9.array(
2374
+ z9.object({
2375
+ index: z9.number(),
2376
+ relevanceScore: z9.number()
2332
2377
  })
2333
2378
  ),
2334
- nextToken: z8.string().optional()
2379
+ nextToken: z9.string().optional()
2335
2380
  })
2336
2381
  )
2337
2382
  );
2338
2383
 
2339
2384
  // src/reranking/amazon-bedrock-reranking-model-options.ts
2340
- import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
2341
- import { z as z9 } from "zod/v4";
2342
- var amazonBedrockRerankingModelOptionsSchema = lazySchema2(
2343
- () => zodSchema2(
2344
- z9.object({
2385
+ import { lazySchema as lazySchema3, zodSchema as zodSchema3 } from "@ai-sdk/provider-utils";
2386
+ import { z as z10 } from "zod/v4";
2387
+ var amazonBedrockRerankingModelOptionsSchema = lazySchema3(
2388
+ () => zodSchema3(
2389
+ z10.object({
2345
2390
  /**
2346
2391
  * If the total number of results was greater than could fit in a response, a token is returned in the nextToken field. You can enter that token in this field to return the next batch of results.
2347
2392
  */
2348
- nextToken: z9.string().optional(),
2393
+ nextToken: z10.string().optional(),
2349
2394
  /**
2350
2395
  * Additional model request fields to pass to the model.
2351
2396
  */
2352
- additionalModelRequestFields: z9.record(z9.string(), z9.any()).optional()
2397
+ additionalModelRequestFields: z10.record(z10.string(), z10.any()).optional()
2353
2398
  })
2354
2399
  )
2355
2400
  );
@@ -2371,11 +2416,11 @@ var AmazonBedrockRerankingModel = class {
2371
2416
  providerOptions
2372
2417
  }) {
2373
2418
  var _a;
2374
- const amazonBedrockOptions = (_a = await parseProviderOptions4({
2419
+ const amazonBedrockOptions = (_a = await parseProviderOptions5({
2375
2420
  provider: "amazonBedrock",
2376
2421
  providerOptions,
2377
2422
  schema: amazonBedrockRerankingModelOptionsSchema
2378
- })) != null ? _a : await parseProviderOptions4({
2423
+ })) != null ? _a : await parseProviderOptions5({
2379
2424
  provider: "bedrock",
2380
2425
  providerOptions,
2381
2426
  schema: amazonBedrockRerankingModelOptionsSchema