boto3, and TypeScript uses @aws-sdk/client-bedrock-runtime.
Both SDKs support the Amazon Titan and Cohere embedding model families.
Setup
-
Model access is automatic: Bedrock enables serverless foundation models on first invocation in AWS commercial regions, and the Model access page has been retired. Cohere models are served from AWS Marketplace, so an account’s first invocation must come from a principal with the
aws-marketplace:Subscribepermission; after that, any user in the account can invoke them. Browse the models available to you in the Bedrock model catalog. -
Install the AWS client for your language:
In TypeScript this package is an optional peer dependency, so it is only required when you actually use the Bedrock embedder.
-
Set up environment variables for authentication:
Usage
Choosing a model
Custom output sizes are model specific. In Python, only Titan Text Embeddings V2 accepts one. In TypeScript, Titan Text Embeddings V2 and Cohere Embed v4 both do, and
embeddingDims is ignored on Titan V1 and on Cohere v3, which have no such parameter. When you do set it, make sure your vector store dimension matches, otherwise inserts will fail.
Bedrock caps a Cohere embedding call at 96 texts. The TypeScript SDK splits larger batches into multiple requests for you, so a 200 text batch becomes 3 calls.
Config
Here are the parameters available for configuring AWS Bedrock embedder:- Python
- TypeScript