@ai-sdk/amazon-bedrock 4.0.37 → 4.0.38
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 +6 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/08-amazon-bedrock.mdx +91 -11
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/anthropic/index.js
CHANGED
|
@@ -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.
|
|
38
|
+
var VERSION = true ? "4.0.38" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
package/dist/anthropic/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import { AwsV4Signer } from "aws4fetch";
|
|
25
25
|
|
|
26
26
|
// src/version.ts
|
|
27
|
-
var VERSION = true ? "4.0.
|
|
27
|
+
var VERSION = true ? "4.0.38" : "0.0.0-test";
|
|
28
28
|
|
|
29
29
|
// src/bedrock-sigv4-fetch.ts
|
|
30
30
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
package/dist/index.js
CHANGED
|
@@ -1868,7 +1868,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
1868
1868
|
var import_aws4fetch = require("aws4fetch");
|
|
1869
1869
|
|
|
1870
1870
|
// src/version.ts
|
|
1871
|
-
var VERSION = true ? "4.0.
|
|
1871
|
+
var VERSION = true ? "4.0.38" : "0.0.0-test";
|
|
1872
1872
|
|
|
1873
1873
|
// src/bedrock-sigv4-fetch.ts
|
|
1874
1874
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
package/dist/index.mjs
CHANGED
|
@@ -1885,7 +1885,7 @@ import {
|
|
|
1885
1885
|
import { AwsV4Signer } from "aws4fetch";
|
|
1886
1886
|
|
|
1887
1887
|
// src/version.ts
|
|
1888
|
-
var VERSION = true ? "4.0.
|
|
1888
|
+
var VERSION = true ? "4.0.38" : "0.0.0-test";
|
|
1889
1889
|
|
|
1890
1890
|
// src/bedrock-sigv4-fetch.ts
|
|
1891
1891
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
|
@@ -168,6 +168,27 @@ You can use the following optional settings to customize the Amazon Bedrock prov
|
|
|
168
168
|
Optional. The AWS credential provider chain that you want to use for the API calls.
|
|
169
169
|
It uses the specified credentials by default.
|
|
170
170
|
|
|
171
|
+
- **apiKey** _string_
|
|
172
|
+
|
|
173
|
+
Optional. API key for authenticating requests using Bearer token authentication.
|
|
174
|
+
When provided, this will be used instead of AWS SigV4 authentication.
|
|
175
|
+
It uses the `AWS_BEARER_TOKEN_BEDROCK` environment variable by default.
|
|
176
|
+
|
|
177
|
+
- **baseURL** _string_
|
|
178
|
+
|
|
179
|
+
Optional. Base URL for the Bedrock API calls.
|
|
180
|
+
Useful for custom endpoints or proxy configurations.
|
|
181
|
+
|
|
182
|
+
- **headers** _Record<string, string>_
|
|
183
|
+
|
|
184
|
+
Optional. Custom headers to include in the requests.
|
|
185
|
+
|
|
186
|
+
- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_
|
|
187
|
+
|
|
188
|
+
Optional. Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
|
|
189
|
+
You can use it as a middleware to intercept requests,
|
|
190
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
191
|
+
|
|
171
192
|
## Language Models
|
|
172
193
|
|
|
173
194
|
You can create models that call the Bedrock API using the provider instance.
|
|
@@ -491,7 +512,7 @@ They are available via the `tools` property of the provider instance.
|
|
|
491
512
|
The Bash Tool allows running bash commands. Here's how to create and use it:
|
|
492
513
|
|
|
493
514
|
```ts
|
|
494
|
-
const bashTool =
|
|
515
|
+
const bashTool = bedrock.tools.bash_20241022({
|
|
495
516
|
execute: async ({ command, restart }) => {
|
|
496
517
|
// Implement your bash command execution logic here
|
|
497
518
|
// Return the result of the command execution
|
|
@@ -511,7 +532,7 @@ The Text Editor Tool provides functionality for viewing and editing text files.
|
|
|
511
532
|
**For Claude 4 models (Opus & Sonnet):**
|
|
512
533
|
|
|
513
534
|
```ts
|
|
514
|
-
const textEditorTool =
|
|
535
|
+
const textEditorTool = bedrock.tools.textEditor_20250429({
|
|
515
536
|
execute: async ({
|
|
516
537
|
command,
|
|
517
538
|
path,
|
|
@@ -530,7 +551,7 @@ const textEditorTool = anthropic.tools.textEditor_20250429({
|
|
|
530
551
|
**For Claude 3.5 Sonnet and earlier models:**
|
|
531
552
|
|
|
532
553
|
```ts
|
|
533
|
-
const textEditorTool =
|
|
554
|
+
const textEditorTool = bedrock.tools.textEditor_20241022({
|
|
534
555
|
execute: async ({
|
|
535
556
|
command,
|
|
536
557
|
path,
|
|
@@ -588,7 +609,7 @@ const response = await generateText({
|
|
|
588
609
|
The Computer Tool enables control of keyboard and mouse actions on a computer:
|
|
589
610
|
|
|
590
611
|
```ts
|
|
591
|
-
const computerTool =
|
|
612
|
+
const computerTool = bedrock.tools.computer_20241022({
|
|
592
613
|
displayWidthPx: 1920,
|
|
593
614
|
displayHeightPx: 1080,
|
|
594
615
|
displayNumber: 0, // Optional, for X11 environments
|
|
@@ -749,22 +770,81 @@ The following optional provider options are available for Bedrock Titan embeddin
|
|
|
749
770
|
|
|
750
771
|
Flag indicating whether or not to normalize the output embeddings. Defaults to true.
|
|
751
772
|
|
|
773
|
+
### Nova Embedding Models
|
|
774
|
+
|
|
775
|
+
Amazon Nova embedding models support additional provider options:
|
|
776
|
+
|
|
777
|
+
```ts
|
|
778
|
+
import { bedrock } from '@ai-sdk/amazon-bedrock';
|
|
779
|
+
import { embed } from 'ai';
|
|
780
|
+
|
|
781
|
+
const { embedding } = await embed({
|
|
782
|
+
model: bedrock.embedding('amazon.nova-embed-text-v2:0'),
|
|
783
|
+
value: 'sunny day at the beach',
|
|
784
|
+
providerOptions: {
|
|
785
|
+
bedrock: {
|
|
786
|
+
embeddingDimension: 1024, // optional, number of dimensions
|
|
787
|
+
embeddingPurpose: 'TEXT_RETRIEVAL', // optional, purpose of embedding
|
|
788
|
+
truncate: 'END', // optional, truncation behavior
|
|
789
|
+
},
|
|
790
|
+
},
|
|
791
|
+
});
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
The following optional provider options are available for Nova embedding models:
|
|
795
|
+
|
|
796
|
+
- **embeddingDimension** _number_
|
|
797
|
+
|
|
798
|
+
The number of dimensions for the output embeddings. Supported values: 256, 384, 1024 (default), 3072.
|
|
799
|
+
|
|
800
|
+
- **embeddingPurpose** _string_
|
|
801
|
+
|
|
802
|
+
The purpose of the embedding. Accepts: `GENERIC_INDEX` (default), `TEXT_RETRIEVAL`, `IMAGE_RETRIEVAL`, `VIDEO_RETRIEVAL`, `DOCUMENT_RETRIEVAL`, `AUDIO_RETRIEVAL`, `GENERIC_RETRIEVAL`, `CLASSIFICATION`, `CLUSTERING`.
|
|
803
|
+
|
|
804
|
+
- **truncate** _string_
|
|
805
|
+
|
|
806
|
+
Truncation behavior when input exceeds the model's context length. Accepts: `NONE`, `START`, `END` (default).
|
|
807
|
+
|
|
808
|
+
### Cohere Embedding Models
|
|
809
|
+
|
|
810
|
+
Cohere embedding models on Bedrock require an `inputType` and support truncation:
|
|
811
|
+
|
|
812
|
+
```ts
|
|
813
|
+
import { bedrock } from '@ai-sdk/amazon-bedrock';
|
|
814
|
+
import { embed } from 'ai';
|
|
815
|
+
|
|
816
|
+
const { embedding } = await embed({
|
|
817
|
+
model: bedrock.embedding('cohere.embed-english-v3'),
|
|
818
|
+
value: 'sunny day at the beach',
|
|
819
|
+
providerOptions: {
|
|
820
|
+
bedrock: {
|
|
821
|
+
inputType: 'search_document', // required for Cohere
|
|
822
|
+
truncate: 'END', // optional, truncation behavior
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
});
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
The following provider options are available for Cohere embedding models:
|
|
829
|
+
|
|
830
|
+
- **inputType** _string_
|
|
831
|
+
|
|
832
|
+
Input type for Cohere embedding models. Accepts: `search_document`, `search_query` (default), `classification`, `clustering`.
|
|
833
|
+
|
|
834
|
+
- **truncate** _string_
|
|
835
|
+
|
|
836
|
+
Truncation behavior when input exceeds the model's context length. Accepts: `NONE`, `START`, `END`.
|
|
837
|
+
|
|
752
838
|
### Model Capabilities
|
|
753
839
|
|
|
754
840
|
| Model | Default Dimensions | Custom Dimensions |
|
|
755
841
|
| ------------------------------ | ------------------ | ------------------- |
|
|
756
842
|
| `amazon.titan-embed-text-v1` | 1536 | <Cross size={18} /> |
|
|
757
843
|
| `amazon.titan-embed-text-v2:0` | 1024 | <Check size={18} /> |
|
|
844
|
+
| `amazon.nova-embed-text-v2:0` | 1024 | <Check size={18} /> |
|
|
758
845
|
| `cohere.embed-english-v3` | 1024 | <Cross size={18} /> |
|
|
759
846
|
| `cohere.embed-multilingual-v3` | 1024 | <Cross size={18} /> |
|
|
760
847
|
|
|
761
|
-
<Note>
|
|
762
|
-
Cohere embedding models on Bedrock require an <code>input_type</code>. Set it
|
|
763
|
-
via
|
|
764
|
-
<code>providerOptions.bedrock.inputType</code> (defaults to{' '}
|
|
765
|
-
<code>search_query</code>).
|
|
766
|
-
</Note>
|
|
767
|
-
|
|
768
848
|
## Reranking Models
|
|
769
849
|
|
|
770
850
|
You can create models that call the [Bedrock Rerank API](https://docs.aws.amazon.com/bedrock/latest/userguide/rerank-api.html)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/amazon-bedrock",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.38",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"tsup": "^8.3.0",
|
|
48
48
|
"typescript": "5.8.3",
|
|
49
49
|
"zod": "3.25.76",
|
|
50
|
-
"@ai-
|
|
51
|
-
"@
|
|
50
|
+
"@vercel/ai-tsconfig": "0.0.0",
|
|
51
|
+
"@ai-sdk/test-server": "1.0.3"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"zod": "^3.25.76 || ^4.1.8"
|