Amazon Bedrock Embeddor

Embeddings
Amazon Bedrock Embeddor Diagram

Overview

Generate embeddings using Amazon Bedrock's embedding models. Supports multiple model options and flexible AWS authentication methods.

Key Features

  • Multiple AWS auth methods
  • Custom endpoint support
  • Region flexibility
  • Profile-based config

Supported Models

  • amazon.titan-embed-text-v1
  • cohere.embed-english-v3
  • cohere.embed-multilingual-v3

Configuration

Required Parameters

  • modelIdBedrock model identifier

Authentication (One Required)

  • awsAccessKeyId &awsSecretAccessKey
  • credentialsProfileName

Optional Parameters

  • awsSessionTokenTemporary session token
  • regionNameAWS region (default: us-east-1)
  • endpointUrlCustom endpoint URL

Example Usage

const embeddor = new AmazonBedrockEmbeddor({
  modelId: "amazon.titan-embed-text-v1",
  awsAccessKeyId: "YOUR_ACCESS_KEY",
  awsSecretAccessKey: "YOUR_SECRET_KEY",
  regionName: "us-west-2"
});

// Generate embeddings
const result = await embeddor.embed({
  input: "Your text to embed"
});

// Using profile-based auth
const profileEmbeddor = new AmazonBedrockEmbeddor({
  modelId: "cohere.embed-english-v3",
  credentialsProfileName: "my-aws-profile",
  regionName: "us-east-1"
});

Best Practices

  • Use environment variables for credentials
  • Implement proper error handling
  • Monitor token usage and costs

Tips

  • Cache embeddings for repeated content
  • Batch requests when possible
  • Use appropriate model for your use case

Response Format

{
  "embeddings": number[],
  "metadata": {
    "model_id": string,
    "dimensions": number,
    "processing_time": number
  },
  "usage": {
    "input_tokens": number,
    "total_tokens": number
  },
  "status": {
    "success": boolean,
    "error": string | null
  }
}