@ai-sdk/amazon-bedrock 4.0.200 → 4.0.202

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/dist/index.mjs CHANGED
@@ -9,6 +9,8 @@ import {
9
9
 
10
10
  // src/bedrock-chat-language-model.ts
11
11
  import {
12
+ lazySchema as lazySchema4,
13
+ zodSchema as zodSchema4,
12
14
  combineHeaders,
13
15
  createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
14
16
  createJsonResponseHandler,
@@ -55,19 +57,27 @@ var BEDROCK_DOCUMENT_MIME_TYPES = {
55
57
  };
56
58
 
57
59
  // src/bedrock-chat-options.ts
60
+ import {
61
+ lazySchema,
62
+ zodSchema
63
+ } from "@ai-sdk/provider-utils";
58
64
  import { z } from "zod/v4";
59
- var bedrockFilePartProviderOptions = z.object({
60
- /**
61
- * Citation configuration for this document.
62
- * When enabled, this document will generate citations in the response.
63
- */
64
- citations: z.object({
65
- /**
66
- * Enable citations for this document
67
- */
68
- enabled: z.boolean()
69
- }).optional()
70
- });
65
+ var bedrockFilePartProviderOptions = lazySchema(
66
+ () => zodSchema(
67
+ z.object({
68
+ /**
69
+ * Citation configuration for this document.
70
+ * When enabled, this document will generate citations in the response.
71
+ */
72
+ citations: z.object({
73
+ /**
74
+ * Enable citations for this document
75
+ */
76
+ enabled: z.boolean()
77
+ }).optional()
78
+ })
79
+ )
80
+ );
71
81
  var amazonBedrockLanguageModelOptions = z.object({
72
82
  /**
73
83
  * Determines how structured outputs are generated for Anthropic models.
@@ -133,12 +143,20 @@ var MODELS_WITH_STRICT_TOOL_SUPPORT = [
133
143
  ];
134
144
 
135
145
  // src/bedrock-error.ts
136
- import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
146
+ import {
147
+ lazySchema as lazySchema2,
148
+ zodSchema as zodSchema2,
149
+ createJsonErrorResponseHandler
150
+ } from "@ai-sdk/provider-utils";
137
151
  import { z as z2 } from "zod/v4";
138
- var BedrockErrorSchema = z2.object({
139
- message: z2.string(),
140
- type: z2.string().nullish()
141
- });
152
+ var BedrockErrorSchema = lazySchema2(
153
+ () => zodSchema2(
154
+ z2.object({
155
+ message: z2.string(),
156
+ type: z2.string().nullish()
157
+ })
158
+ )
159
+ );
142
160
  var bedrockFailedResponseHandler = createJsonErrorResponseHandler({
143
161
  errorSchema: BedrockErrorSchema,
144
162
  errorToMessage: (error) => error.type == null ? error.message : `${error.type}: ${error.message}`
@@ -456,12 +474,20 @@ import {
456
474
  } from "@ai-sdk/provider-utils";
457
475
 
458
476
  // src/bedrock-reasoning-metadata.ts
477
+ import {
478
+ lazySchema as lazySchema3,
479
+ zodSchema as zodSchema3
480
+ } from "@ai-sdk/provider-utils";
459
481
  import { z as z3 } from "zod/v4";
460
- var bedrockReasoningMetadataSchema = z3.object({
461
- signature: z3.string().optional(),
462
- redactedData: z3.string().optional(),
463
- redactedContent: z3.string().optional()
464
- });
482
+ var bedrockReasoningMetadataSchema = lazySchema3(
483
+ () => zodSchema3(
484
+ z3.object({
485
+ signature: z3.string().optional(),
486
+ redactedData: z3.string().optional(),
487
+ redactedContent: z3.string().optional()
488
+ })
489
+ )
490
+ );
465
491
 
466
492
  // src/normalize-tool-call-id.ts
467
493
  function isMistralModel(modelId) {
@@ -941,10 +967,14 @@ function mapBedrockFinishReason(finishReason, isJsonResponseFromTool) {
941
967
  function isJsonResponseToolName(name) {
942
968
  return name === "json" || name === "json<|channel|>commentary";
943
969
  }
944
- var anthropicProviderOptions = z4.object({
945
- disableParallelToolUse: z4.boolean().optional(),
946
- structuredOutputMode: z4.enum(["outputFormat", "jsonTool", "auto"]).optional()
947
- });
970
+ var anthropicProviderOptions = lazySchema4(
971
+ () => zodSchema4(
972
+ z4.object({
973
+ disableParallelToolUse: z4.boolean().optional(),
974
+ structuredOutputMode: z4.enum(["outputFormat", "jsonTool", "auto"]).optional()
975
+ })
976
+ )
977
+ );
948
978
  var BedrockChatLanguageModel = class {
949
979
  constructor(modelId, config) {
950
980
  this.modelId = modelId;
@@ -1826,68 +1856,72 @@ var BedrockToolUseSchema = z4.object({
1826
1856
  name: z4.string(),
1827
1857
  input: z4.unknown().optional()
1828
1858
  });
1829
- var BedrockReasoningTextSchema = z4.object({
1859
+ var BedrockReasoningTextSchema = () => z4.object({
1830
1860
  signature: z4.string().nullish(),
1831
1861
  text: z4.string()
1832
1862
  });
1833
- var BedrockRedactedReasoningSchema = z4.object({
1863
+ var BedrockRedactedReasoningSchema = () => z4.object({
1834
1864
  data: z4.string()
1835
1865
  });
1836
1866
  var AmazonBedrockCacheDetailSchema = z4.object({
1837
1867
  inputTokens: z4.number(),
1838
1868
  ttl: z4.string()
1839
1869
  }).catchall(z4.json());
1840
- var BedrockResponseSchema = z4.object({
1841
- metrics: z4.object({
1842
- latencyMs: z4.number()
1843
- }).nullish(),
1844
- output: z4.object({
1845
- message: z4.object({
1846
- content: z4.array(
1847
- z4.object({
1848
- text: z4.string().nullish(),
1849
- citationsContent: z4.object({
1850
- content: z4.array(
1851
- z4.object({
1852
- text: z4.string().nullish()
1853
- })
1854
- ).nullish()
1855
- }).nullish(),
1856
- toolUse: BedrockToolUseSchema.nullish(),
1857
- reasoningContent: z4.union([
1858
- z4.object({
1859
- reasoningText: BedrockReasoningTextSchema
1860
- }),
1861
- z4.object({
1862
- redactedReasoning: BedrockRedactedReasoningSchema
1863
- }),
1864
- // `redactedContent` is a member of the documented
1865
- // ReasoningContentBlock union. OpenAI models on Bedrock
1866
- // (e.g. `us.openai.gpt-5.6-luna`) return their encrypted
1867
- // reasoning in this shape.
1870
+ var BedrockResponseSchema = lazySchema4(
1871
+ () => zodSchema4(
1872
+ z4.object({
1873
+ metrics: z4.object({
1874
+ latencyMs: z4.number()
1875
+ }).nullish(),
1876
+ output: z4.object({
1877
+ message: z4.object({
1878
+ content: z4.array(
1868
1879
  z4.object({
1869
- redactedContent: z4.string()
1880
+ text: z4.string().nullish(),
1881
+ citationsContent: z4.object({
1882
+ content: z4.array(
1883
+ z4.object({
1884
+ text: z4.string().nullish()
1885
+ })
1886
+ ).nullish()
1887
+ }).nullish(),
1888
+ toolUse: BedrockToolUseSchema.nullish(),
1889
+ reasoningContent: z4.union([
1890
+ z4.object({
1891
+ reasoningText: BedrockReasoningTextSchema()
1892
+ }),
1893
+ z4.object({
1894
+ redactedReasoning: BedrockRedactedReasoningSchema()
1895
+ }),
1896
+ // `redactedContent` is a member of the documented
1897
+ // ReasoningContentBlock union. OpenAI models on Bedrock
1898
+ // (e.g. `us.openai.gpt-5.6-luna`) return their encrypted
1899
+ // reasoning in this shape.
1900
+ z4.object({
1901
+ redactedContent: z4.string()
1902
+ })
1903
+ ]).nullish()
1870
1904
  })
1871
- ]).nullish()
1905
+ ),
1906
+ role: z4.string()
1872
1907
  })
1873
- ),
1874
- role: z4.string()
1908
+ }),
1909
+ stopReason: BedrockStopReasonSchema,
1910
+ additionalModelResponseFields: BedrockAdditionalModelResponseFieldsSchema.nullish(),
1911
+ trace: z4.unknown().nullish(),
1912
+ performanceConfig: z4.object({ latency: z4.string() }).nullish(),
1913
+ serviceTier: z4.object({ type: z4.string() }).nullish(),
1914
+ usage: z4.object({
1915
+ inputTokens: z4.number(),
1916
+ outputTokens: z4.number(),
1917
+ totalTokens: z4.number(),
1918
+ cacheReadInputTokens: z4.number().nullish(),
1919
+ cacheWriteInputTokens: z4.number().nullish(),
1920
+ cacheDetails: z4.array(AmazonBedrockCacheDetailSchema).nullish()
1921
+ }).catchall(z4.json())
1875
1922
  })
1876
- }),
1877
- stopReason: BedrockStopReasonSchema,
1878
- additionalModelResponseFields: BedrockAdditionalModelResponseFieldsSchema.nullish(),
1879
- trace: z4.unknown().nullish(),
1880
- performanceConfig: z4.object({ latency: z4.string() }).nullish(),
1881
- serviceTier: z4.object({ type: z4.string() }).nullish(),
1882
- usage: z4.object({
1883
- inputTokens: z4.number(),
1884
- outputTokens: z4.number(),
1885
- totalTokens: z4.number(),
1886
- cacheReadInputTokens: z4.number().nullish(),
1887
- cacheWriteInputTokens: z4.number().nullish(),
1888
- cacheDetails: z4.array(AmazonBedrockCacheDetailSchema).nullish()
1889
- }).catchall(z4.json())
1890
- });
1923
+ )
1924
+ );
1891
1925
  var BedrockStreamSchema = z4.object({
1892
1926
  contentBlockDelta: z4.object({
1893
1927
  contentBlockIndex: z4.number(),
@@ -1954,6 +1988,8 @@ import {
1954
1988
  TooManyEmbeddingValuesForCallError
1955
1989
  } from "@ai-sdk/provider";
1956
1990
  import {
1991
+ lazySchema as lazySchema6,
1992
+ zodSchema as zodSchema6,
1957
1993
  combineHeaders as combineHeaders2,
1958
1994
  createJsonResponseHandler as createJsonResponseHandler2,
1959
1995
  parseProviderOptions as parseProviderOptions3,
@@ -1962,56 +1998,79 @@ import {
1962
1998
  } from "@ai-sdk/provider-utils";
1963
1999
 
1964
2000
  // src/bedrock-embedding-options.ts
2001
+ import {
2002
+ lazySchema as lazySchema5,
2003
+ zodSchema as zodSchema5
2004
+ } from "@ai-sdk/provider-utils";
1965
2005
  import { z as z5 } from "zod/v4";
1966
- var amazonBedrockEmbeddingModelOptionsSchema = z5.object({
1967
- /**
1968
- * The number of dimensions the resulting output embeddings should have (defaults to 1024).
1969
- * Only supported in amazon.titan-embed-text-v2:0.
1970
- */
1971
- dimensions: z5.union([z5.literal(1024), z5.literal(512), z5.literal(256)]).optional(),
1972
- /**
1973
- * Flag indicating whether or not to normalize the output embeddings. Defaults to true.
1974
- * Only supported in amazon.titan-embed-text-v2:0.
1975
- */
1976
- normalize: z5.boolean().optional(),
1977
- /**
1978
- * The number of dimensions for Nova embedding models (defaults to 1024).
1979
- * Supported values: 256, 384, 1024, 3072.
1980
- * Only supported in amazon.nova-* embedding models.
1981
- */
1982
- embeddingDimension: z5.union([z5.literal(256), z5.literal(384), z5.literal(1024), z5.literal(3072)]).optional(),
1983
- /**
1984
- * The purpose of the embedding. Defaults to 'GENERIC_INDEX'.
1985
- * Only supported in amazon.nova-* embedding models.
1986
- */
1987
- embeddingPurpose: z5.enum([
1988
- "GENERIC_INDEX",
1989
- "TEXT_RETRIEVAL",
1990
- "IMAGE_RETRIEVAL",
1991
- "VIDEO_RETRIEVAL",
1992
- "DOCUMENT_RETRIEVAL",
1993
- "AUDIO_RETRIEVAL",
1994
- "GENERIC_RETRIEVAL",
1995
- "CLASSIFICATION",
1996
- "CLUSTERING"
1997
- ]).optional(),
1998
- /**
1999
- * Input type for Cohere embedding models on Bedrock.
2000
- * Common values: `search_document`, `search_query`, `classification`, `clustering`.
2001
- * If not set, the provider defaults to `search_query`.
2002
- */
2003
- inputType: z5.enum(["search_document", "search_query", "classification", "clustering"]).optional(),
2004
- /**
2005
- * Truncation behavior when input exceeds the model's context length.
2006
- * Supported in Cohere and Nova embedding models. Defaults to 'END' for Nova models.
2007
- */
2008
- truncate: z5.enum(["NONE", "START", "END"]).optional(),
2009
- /**
2010
- * The number of dimensions the resulting output embeddings should have (defaults to 1536).
2011
- * Only supported in cohere.embed-v4:0 and newer Cohere embedding models.
2012
- */
2013
- outputDimension: z5.union([z5.literal(256), z5.literal(512), z5.literal(1024), z5.literal(1536)]).optional()
2014
- });
2006
+ var amazonBedrockEmbeddingModelOptionsSchema = lazySchema5(
2007
+ () => zodSchema5(
2008
+ z5.object({
2009
+ /**
2010
+ * The number of dimensions the resulting output embeddings should have (defaults to 1024).
2011
+ * Only supported in amazon.titan-embed-text-v2:0.
2012
+ */
2013
+ dimensions: z5.union([z5.literal(1024), z5.literal(512), z5.literal(256)]).optional(),
2014
+ /**
2015
+ * Flag indicating whether or not to normalize the output embeddings. Defaults to true.
2016
+ * Only supported in amazon.titan-embed-text-v2:0.
2017
+ */
2018
+ normalize: z5.boolean().optional(),
2019
+ /**
2020
+ * The number of dimensions for Nova embedding models (defaults to 1024).
2021
+ * Supported values: 256, 384, 1024, 3072.
2022
+ * Only supported in amazon.nova-* embedding models.
2023
+ */
2024
+ embeddingDimension: z5.union([
2025
+ z5.literal(256),
2026
+ z5.literal(384),
2027
+ z5.literal(1024),
2028
+ z5.literal(3072)
2029
+ ]).optional(),
2030
+ /**
2031
+ * The purpose of the embedding. Defaults to 'GENERIC_INDEX'.
2032
+ * Only supported in amazon.nova-* embedding models.
2033
+ */
2034
+ embeddingPurpose: z5.enum([
2035
+ "GENERIC_INDEX",
2036
+ "TEXT_RETRIEVAL",
2037
+ "IMAGE_RETRIEVAL",
2038
+ "VIDEO_RETRIEVAL",
2039
+ "DOCUMENT_RETRIEVAL",
2040
+ "AUDIO_RETRIEVAL",
2041
+ "GENERIC_RETRIEVAL",
2042
+ "CLASSIFICATION",
2043
+ "CLUSTERING"
2044
+ ]).optional(),
2045
+ /**
2046
+ * Input type for Cohere embedding models on Bedrock.
2047
+ * Common values: `search_document`, `search_query`, `classification`, `clustering`.
2048
+ * If not set, the provider defaults to `search_query`.
2049
+ */
2050
+ inputType: z5.enum([
2051
+ "search_document",
2052
+ "search_query",
2053
+ "classification",
2054
+ "clustering"
2055
+ ]).optional(),
2056
+ /**
2057
+ * Truncation behavior when input exceeds the model's context length.
2058
+ * Supported in Cohere and Nova embedding models. Defaults to 'END' for Nova models.
2059
+ */
2060
+ truncate: z5.enum(["NONE", "START", "END"]).optional(),
2061
+ /**
2062
+ * The number of dimensions the resulting output embeddings should have (defaults to 1536).
2063
+ * Only supported in cohere.embed-v4:0 and newer Cohere embedding models.
2064
+ */
2065
+ outputDimension: z5.union([
2066
+ z5.literal(256),
2067
+ z5.literal(512),
2068
+ z5.literal(1024),
2069
+ z5.literal(1536)
2070
+ ]).optional()
2071
+ })
2072
+ )
2073
+ );
2015
2074
 
2016
2075
  // src/bedrock-embedding-model.ts
2017
2076
  import { z as z6 } from "zod/v4";
@@ -2124,36 +2183,42 @@ function isNovaEmbeddingModel(modelId) {
2124
2183
  function detectEmbeddingModelFamily(modelId) {
2125
2184
  return isNovaEmbeddingModel(modelId) ? "nova" : isCohereEmbeddingModel(modelId) ? "cohere" : "titan";
2126
2185
  }
2127
- var BedrockEmbeddingResponseSchema = z6.union([
2128
- // Titan-style response
2129
- z6.object({
2130
- embedding: z6.array(z6.number()),
2131
- inputTextTokenCount: z6.number()
2132
- }),
2133
- // Nova-style response
2134
- z6.object({
2135
- embeddings: z6.array(
2186
+ var BedrockEmbeddingResponseSchema = lazySchema6(
2187
+ () => zodSchema6(
2188
+ z6.union([
2189
+ // Titan-style response
2190
+ z6.object({
2191
+ embedding: z6.array(z6.number()),
2192
+ inputTextTokenCount: z6.number()
2193
+ }),
2194
+ // Nova-style response
2195
+ z6.object({
2196
+ embeddings: z6.array(
2197
+ z6.object({
2198
+ embeddingType: z6.string(),
2199
+ embedding: z6.array(z6.number())
2200
+ })
2201
+ ),
2202
+ inputTokenCount: z6.number().optional()
2203
+ }),
2204
+ // Cohere v3-style response
2205
+ z6.object({
2206
+ embeddings: z6.array(z6.array(z6.number()))
2207
+ }),
2208
+ // Cohere v4-style response
2136
2209
  z6.object({
2137
- embeddingType: z6.string(),
2138
- embedding: z6.array(z6.number())
2210
+ embeddings: z6.object({
2211
+ float: z6.array(z6.array(z6.number()))
2212
+ })
2139
2213
  })
2140
- ),
2141
- inputTokenCount: z6.number().optional()
2142
- }),
2143
- // Cohere v3-style response
2144
- z6.object({
2145
- embeddings: z6.array(z6.array(z6.number()))
2146
- }),
2147
- // Cohere v4-style response
2148
- z6.object({
2149
- embeddings: z6.object({
2150
- float: z6.array(z6.array(z6.number()))
2151
- })
2152
- })
2153
- ]);
2214
+ ])
2215
+ )
2216
+ );
2154
2217
 
2155
2218
  // src/bedrock-image-model.ts
2156
2219
  import {
2220
+ lazySchema as lazySchema7,
2221
+ zodSchema as zodSchema7,
2157
2222
  combineHeaders as combineHeaders3,
2158
2223
  convertUint8ArrayToBase64,
2159
2224
  createJsonResponseHandler as createJsonResponseHandler3,
@@ -2350,17 +2415,21 @@ function getBase64Data(file) {
2350
2415
  }
2351
2416
  return file.data;
2352
2417
  }
2353
- var bedrockImageResponseSchema = z7.object({
2354
- // Normal successful response
2355
- images: z7.array(z7.string()).optional(),
2356
- // Moderation response fields
2357
- id: z7.string().optional(),
2358
- status: z7.string().optional(),
2359
- result: z7.unknown().optional(),
2360
- progress: z7.unknown().optional(),
2361
- details: z7.record(z7.string(), z7.unknown()).optional(),
2362
- preview: z7.unknown().optional()
2363
- });
2418
+ var bedrockImageResponseSchema = lazySchema7(
2419
+ () => zodSchema7(
2420
+ z7.object({
2421
+ // Normal successful response
2422
+ images: z7.array(z7.string()).optional(),
2423
+ // Moderation response fields
2424
+ id: z7.string().optional(),
2425
+ status: z7.string().optional(),
2426
+ result: z7.unknown().optional(),
2427
+ progress: z7.unknown().optional(),
2428
+ details: z7.record(z7.string(), z7.unknown()).optional(),
2429
+ preview: z7.unknown().optional()
2430
+ })
2431
+ )
2432
+ );
2364
2433
 
2365
2434
  // src/bedrock-sigv4-fetch.ts
2366
2435
  import {
@@ -2372,7 +2441,7 @@ import {
2372
2441
  import { AwsV4Signer } from "aws4fetch";
2373
2442
 
2374
2443
  // src/version.ts
2375
- var VERSION = true ? "4.0.200" : "0.0.0-test";
2444
+ var VERSION = true ? "4.0.202" : "0.0.0-test";
2376
2445
 
2377
2446
  // src/bedrock-sigv4-fetch.ts
2378
2447
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
@@ -2472,10 +2541,10 @@ import {
2472
2541
  } from "@ai-sdk/provider-utils";
2473
2542
 
2474
2543
  // src/reranking/bedrock-reranking-api.ts
2475
- import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
2544
+ import { lazySchema as lazySchema8, zodSchema as zodSchema8 } from "@ai-sdk/provider-utils";
2476
2545
  import { z as z8 } from "zod/v4";
2477
- var bedrockRerankingResponseSchema = lazySchema(
2478
- () => zodSchema(
2546
+ var bedrockRerankingResponseSchema = lazySchema8(
2547
+ () => zodSchema8(
2479
2548
  z8.object({
2480
2549
  results: z8.array(
2481
2550
  z8.object({
@@ -2489,10 +2558,10 @@ var bedrockRerankingResponseSchema = lazySchema(
2489
2558
  );
2490
2559
 
2491
2560
  // src/reranking/bedrock-reranking-options.ts
2492
- import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
2561
+ import { lazySchema as lazySchema9, zodSchema as zodSchema9 } from "@ai-sdk/provider-utils";
2493
2562
  import { z as z9 } from "zod/v4";
2494
- var amazonBedrockRerankingModelOptionsSchema = lazySchema2(
2495
- () => zodSchema2(
2563
+ var amazonBedrockRerankingModelOptionsSchema = lazySchema9(
2564
+ () => zodSchema9(
2496
2565
  z9.object({
2497
2566
  /**
2498
2567
  * 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.