@ai-sdk/amazon-bedrock 5.0.0-beta.7 → 5.0.0-beta.85
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 +677 -4
- package/README.md +2 -0
- package/dist/anthropic/index.d.ts +10 -10
- package/dist/anthropic/index.js +151 -117
- package/dist/anthropic/index.js.map +1 -1
- package/dist/index.d.ts +36 -23
- package/dist/index.js +881 -604
- package/dist/index.js.map +1 -1
- package/dist/mantle/index.cjs +253 -0
- package/dist/mantle/index.cjs.map +1 -0
- package/dist/mantle/index.d.cts +99 -0
- package/dist/mantle/index.d.ts +99 -0
- package/dist/mantle/index.js +240 -0
- package/dist/mantle/index.js.map +1 -0
- package/docs/08-amazon-bedrock.mdx +310 -84
- package/mantle/index.d.ts +1 -0
- package/package.json +27 -20
- package/src/amazon-bedrock-api-types.ts +228 -0
- package/src/{bedrock-chat-options.ts → amazon-bedrock-chat-language-model-options.ts} +27 -8
- package/src/{bedrock-chat-language-model.ts → amazon-bedrock-chat-language-model.ts} +350 -180
- package/src/{bedrock-embedding-options.ts → amazon-bedrock-embedding-model-options.ts} +1 -1
- package/src/{bedrock-embedding-model.ts → amazon-bedrock-embedding-model.ts} +61 -29
- package/src/{bedrock-error.ts → amazon-bedrock-error.ts} +1 -1
- package/src/{bedrock-event-stream-decoder.ts → amazon-bedrock-event-stream-decoder.ts} +1 -1
- package/src/{bedrock-event-stream-response-handler.ts → amazon-bedrock-event-stream-response-handler.ts} +6 -6
- package/src/{bedrock-image-model.ts → amazon-bedrock-image-model.ts} +62 -38
- package/src/amazon-bedrock-image-settings.ts +9 -0
- package/src/{bedrock-prepare-tools.ts → amazon-bedrock-prepare-tools.ts} +22 -18
- package/src/{bedrock-provider.ts → amazon-bedrock-provider.ts} +53 -46
- package/src/amazon-bedrock-reasoning-metadata.ts +10 -0
- package/src/{bedrock-sigv4-fetch.ts → amazon-bedrock-sigv4-fetch.ts} +17 -9
- package/src/anthropic/amazon-bedrock-anthropic-fetch.ts +104 -0
- package/src/anthropic/{bedrock-anthropic-options.ts → amazon-bedrock-anthropic-options.ts} +7 -1
- package/src/anthropic/{bedrock-anthropic-provider.ts → amazon-bedrock-anthropic-provider.ts} +40 -24
- package/src/anthropic/index.ts +19 -7
- package/src/{convert-bedrock-usage.ts → convert-amazon-bedrock-usage.ts} +4 -4
- package/src/convert-to-amazon-bedrock-chat-messages.ts +556 -0
- package/src/index.ts +15 -8
- package/src/inject-fetch-headers.ts +1 -1
- package/src/mantle/bedrock-mantle-options.ts +15 -0
- package/src/mantle/bedrock-mantle-provider.ts +283 -0
- package/src/mantle/index.ts +6 -0
- package/src/{map-bedrock-finish-reason.ts → map-amazon-bedrock-finish-reason.ts} +4 -4
- package/src/reranking/{bedrock-reranking-api.ts → amazon-bedrock-reranking-api.ts} +3 -3
- package/src/reranking/{bedrock-reranking-options.ts → amazon-bedrock-reranking-model-options.ts} +1 -1
- package/src/reranking/{bedrock-reranking-model.ts → amazon-bedrock-reranking-model.ts} +32 -25
- package/dist/anthropic/index.d.mts +0 -91
- package/dist/anthropic/index.mjs +0 -397
- package/dist/anthropic/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -194
- package/dist/index.mjs +0 -2329
- package/dist/index.mjs.map +0 -1
- package/src/anthropic/bedrock-anthropic-fetch.ts +0 -68
- package/src/bedrock-api-types.ts +0 -216
- package/src/bedrock-image-settings.ts +0 -6
- package/src/convert-to-bedrock-chat-messages.ts +0 -468
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { anthropicTools } from '@ai-sdk/anthropic/internal';
|
|
|
4
4
|
import { ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, RerankingModelV4 } from '@ai-sdk/provider';
|
|
5
5
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
6
6
|
|
|
7
|
-
type
|
|
7
|
+
type AmazonBedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
|
|
8
8
|
declare const amazonBedrockEmbeddingModelOptionsSchema: z.ZodObject<{
|
|
9
9
|
dimensions: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1024>, z.ZodLiteral<512>, z.ZodLiteral<256>]>>;
|
|
10
10
|
normalize: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -35,8 +35,8 @@ declare const amazonBedrockEmbeddingModelOptionsSchema: z.ZodObject<{
|
|
|
35
35
|
}, z.core.$strip>;
|
|
36
36
|
type AmazonBedrockEmbeddingModelOptions = z.infer<typeof amazonBedrockEmbeddingModelOptionsSchema>;
|
|
37
37
|
|
|
38
|
-
type
|
|
39
|
-
declare const
|
|
38
|
+
type AmazonBedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | '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-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
|
+
declare const amazonBedrockLanguageModelChatOptions: z.ZodObject<{
|
|
40
40
|
additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
41
41
|
reasoningConfig: z.ZodOptional<z.ZodObject<{
|
|
42
42
|
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">, z.ZodLiteral<"adaptive">]>>;
|
|
@@ -45,23 +45,34 @@ declare const amazonBedrockLanguageModelOptions: z.ZodObject<{
|
|
|
45
45
|
low: "low";
|
|
46
46
|
medium: "medium";
|
|
47
47
|
high: "high";
|
|
48
|
+
xhigh: "xhigh";
|
|
48
49
|
max: "max";
|
|
49
50
|
}>>;
|
|
51
|
+
display: z.ZodOptional<z.ZodEnum<{
|
|
52
|
+
omitted: "omitted";
|
|
53
|
+
summarized: "summarized";
|
|
54
|
+
}>>;
|
|
50
55
|
}, z.core.$strip>>;
|
|
51
56
|
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
57
|
+
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
58
|
+
default: "default";
|
|
59
|
+
reserved: "reserved";
|
|
60
|
+
priority: "priority";
|
|
61
|
+
flex: "flex";
|
|
62
|
+
}>>;
|
|
52
63
|
}, z.core.$strip>;
|
|
53
|
-
type
|
|
64
|
+
type AmazonBedrockLanguageModelChatOptions = z.infer<typeof amazonBedrockLanguageModelChatOptions>;
|
|
54
65
|
|
|
55
|
-
type
|
|
66
|
+
type AmazonBedrockImageModelId = 'amazon.nova-canvas-v1:0' | (string & {});
|
|
56
67
|
|
|
57
|
-
interface
|
|
68
|
+
interface AmazonBedrockCredentials {
|
|
58
69
|
region: string;
|
|
59
70
|
accessKeyId: string;
|
|
60
71
|
secretAccessKey: string;
|
|
61
72
|
sessionToken?: string;
|
|
62
73
|
}
|
|
63
74
|
|
|
64
|
-
type
|
|
75
|
+
type AmazonBedrockRerankingModelId = 'amazon.rerank-v1:0' | 'cohere.rerank-v3-5:0' | (string & {});
|
|
65
76
|
type AmazonBedrockRerankingModelOptions = {
|
|
66
77
|
/**
|
|
67
78
|
* 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.
|
|
@@ -114,8 +125,10 @@ interface AmazonBedrockProviderSettings {
|
|
|
114
125
|
*/
|
|
115
126
|
secretAccessKey?: string;
|
|
116
127
|
/**
|
|
117
|
-
* The AWS session token to use for the Bedrock provider.
|
|
118
|
-
* `
|
|
128
|
+
* The AWS session token to use for the Bedrock provider. When `accessKeyId` and
|
|
129
|
+
* `secretAccessKey` are both passed explicitly as options, only this field is used
|
|
130
|
+
* If either access key field is omitted and resolved from the environment, the
|
|
131
|
+
* session token also falls back to `AWS_SESSION_TOKEN` when not set here.
|
|
119
132
|
*/
|
|
120
133
|
sessionToken?: string;
|
|
121
134
|
/**
|
|
@@ -137,44 +150,44 @@ interface AmazonBedrockProviderSettings {
|
|
|
137
150
|
* credential values to be used instead of the `accessKeyId`, `secretAccessKey`,
|
|
138
151
|
* and `sessionToken` settings.
|
|
139
152
|
*/
|
|
140
|
-
credentialProvider?: () => PromiseLike<Omit<
|
|
153
|
+
credentialProvider?: () => PromiseLike<Omit<AmazonBedrockCredentials, 'region'>>;
|
|
141
154
|
generateId?: () => string;
|
|
142
155
|
}
|
|
143
156
|
interface AmazonBedrockProvider extends ProviderV4 {
|
|
144
|
-
(modelId:
|
|
145
|
-
languageModel(modelId:
|
|
157
|
+
(modelId: AmazonBedrockChatModelId): LanguageModelV4;
|
|
158
|
+
languageModel(modelId: AmazonBedrockChatModelId): LanguageModelV4;
|
|
146
159
|
/**
|
|
147
160
|
* Creates a model for text embeddings.
|
|
148
161
|
*/
|
|
149
|
-
embedding(modelId:
|
|
162
|
+
embedding(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
|
|
150
163
|
/**
|
|
151
164
|
* Creates a model for text embeddings.
|
|
152
165
|
*/
|
|
153
|
-
embeddingModel(modelId:
|
|
166
|
+
embeddingModel(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
|
|
154
167
|
/**
|
|
155
168
|
* @deprecated Use `embedding` instead.
|
|
156
169
|
*/
|
|
157
|
-
textEmbedding(modelId:
|
|
170
|
+
textEmbedding(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
|
|
158
171
|
/**
|
|
159
172
|
* @deprecated Use `embeddingModel` instead.
|
|
160
173
|
*/
|
|
161
|
-
textEmbeddingModel(modelId:
|
|
174
|
+
textEmbeddingModel(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
|
|
162
175
|
/**
|
|
163
176
|
* Creates a model for image generation.
|
|
164
177
|
*/
|
|
165
|
-
image(modelId:
|
|
178
|
+
image(modelId: AmazonBedrockImageModelId): ImageModelV4;
|
|
166
179
|
/**
|
|
167
180
|
* Creates a model for image generation.
|
|
168
181
|
*/
|
|
169
|
-
imageModel(modelId:
|
|
182
|
+
imageModel(modelId: AmazonBedrockImageModelId): ImageModelV4;
|
|
170
183
|
/**
|
|
171
184
|
* Creates a model for reranking documents.
|
|
172
185
|
*/
|
|
173
|
-
reranking(modelId:
|
|
186
|
+
reranking(modelId: AmazonBedrockRerankingModelId): RerankingModelV4;
|
|
174
187
|
/**
|
|
175
188
|
* Creates a model for reranking documents.
|
|
176
189
|
*/
|
|
177
|
-
rerankingModel(modelId:
|
|
190
|
+
rerankingModel(modelId: AmazonBedrockRerankingModelId): RerankingModelV4;
|
|
178
191
|
/**
|
|
179
192
|
* Anthropic-specific tools that can be used with Anthropic models on Bedrock.
|
|
180
193
|
*/
|
|
@@ -185,10 +198,10 @@ interface AmazonBedrockProvider extends ProviderV4 {
|
|
|
185
198
|
*/
|
|
186
199
|
declare function createAmazonBedrock(options?: AmazonBedrockProviderSettings): AmazonBedrockProvider;
|
|
187
200
|
/**
|
|
188
|
-
* Default Bedrock provider instance.
|
|
201
|
+
* Default Amazon Bedrock provider instance.
|
|
189
202
|
*/
|
|
190
|
-
declare const
|
|
203
|
+
declare const amazonBedrock: AmazonBedrockProvider;
|
|
191
204
|
|
|
192
205
|
declare const VERSION: string;
|
|
193
206
|
|
|
194
|
-
export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type
|
|
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 };
|