Bedrock embedding models supported
Bedrock supports the following embedding models: amazon.titan-embed-text-v1 with 1536 default dimensions and no custom dimensions support, amazon.titan-embed-text-v2:0 with 1024 default dimensions and custom dimensions support, amazon.nova-embed-text-v2:0 with 1024 default dimensions and custom dimensions support, cohere.embed-english-v3 with 1024 default dimensions and no custom dimensions support, cohere.embed-multilingual-v3 with 1024 default dimensions and no custom dimensions support.
Bedrock Titan embedding model options
For amazon.titan-embed-text-v2:0, the following optional provider options are available under providerOptions.bedrock: dimensions (number, accepted values 1024 (default), 512, 256), normalize (boolean, defaults to true).
Bedrock Nova embedding model options
For amazon.nova-embed-text-v2:0, the following optional provider options are available under providerOptions.bedrock: embeddingDimension (number, supported values 256, 384, 1024 (default), 3072), embeddingPurpose (string, accepts GENERIC_INDEX (default), TEXT_RETRIEVAL, IMAGE_RETRIEVAL, VIDEO_RETRIEVAL, DOCUMENT_RETRIEVAL, AUDIO_RETRIEVAL, GENERIC_RETRIEVAL, CLASSIFICATION, CLUSTERING), truncate (string, accepts NONE, START, END (default)).
Bedrock Cohere embedding model options
For Cohere embedding models on Bedrock, the following provider options are available under providerOptions.bedrock: inputType (string, required, accepts search_document, search_query (default), classification, clustering), truncate (string, optional, accepts NONE, START, END).
Bedrock application inference profile for embeddings
When using application inference profile ARNs with embeddings, pass the modelFamily parameter when creating an embedding model. Example: amazonBedrock.embedding(profileArn, { modelFamily: 'cohere' }). This allows the provider to select the correct request format and batch size.
Example: Create Bedrock embedding model
const model = amazonBedrock.embedding('amazon.titan-embed-text-v1');
Example: Bedrock Titan embedding with options
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { embed } from 'ai';
const { embedding } = await embed({
model: amazonBedrock.embedding('amazon.titan-embed-text-v2:0'),
value: 'sunny day at the beach',
providerOptions: {
bedrock: {
dimensions: 512,
normalize: true,
},
},
});
Example: Bedrock Nova embedding with options
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { embed } from 'ai';
const { embedding } = await embed({
model: amazonBedrock.embedding('amazon.nova-embed-text-v2:0'),
value: 'sunny day at the beach',
providerOptions: {
bedrock: {
embeddingDimension: 1024,
embeddingPurpose: 'TEXT_RETRIEVAL',
truncate: 'END',
},
},
});
Example: Bedrock Cohere embedding with inputType
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { embed } from 'ai';
const { embedding } = await embed({
model: amazonBedrock.embedding('cohere.embed-english-v3'),
value: 'sunny day at the beach',
providerOptions: {
bedrock: {
inputType: 'search_document',
truncate: 'END',
},
},
});
Example: Bedrock application inference profile for embeddings
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { embedMany } from 'ai';
const profileArn = 'arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/qibm5eutlkcy';
const { embeddings } = await embedMany({
model: amazonBedrock.embedding(profileArn, {
modelFamily: 'cohere',
}),
values: ['hello', 'world'],
});