Skip to content

Embedding Model Connectors

To compute vector representations of user questions and conversation logs for similarity searches, Elsai provides a modular embeddings interface under elsai.integrations.elsai_embeddings.

This module lets you build standalone embedding clients using AWS Bedrock or Azure OpenAI as backends.


Installation

To use embedding connectors, ensure you have the elsai-embeddings extra (or the standalone elsai-model package) installed:

bash
pip install --extra-index-url https://core-packages.elsai.ai/root/elsai-model/ elsai-model

Embedding Clients Factory

Elsai provides two main entry-points to initialize embedding clients:

1. build_embedding_client(config: EmbeddingBackendConfig)

Initializes an embedding client from an explicit configuration object.

python
from elsai.integrations.elsai_embeddings import EmbeddingBackendConfig, build_embedding_client

config = EmbeddingBackendConfig(
    provider="bedrock",
    aws_region="us-east-1",
    model_name="amazon.titan-embed-text-v1",
)
client = build_embedding_client(config)

2. build_embedding_client_from_env(provider=None)

Loads credentials and backend settings directly from standard environment variables (e.g. EMBEDDING_PROVIDER="azure" or EMBEDDING_PROVIDER="bedrock").

python
import os
from elsai.integrations.elsai_embeddings import build_embedding_client_from_env

# Configure environment
os.environ["EMBEDDING_PROVIDER"] = "bedrock"
os.environ["AWS_REGION"] = "us-east-1"
os.environ["BEDROCK_EMBEDDING_MODEL_NAME"] = "amazon.titan-embed-text-v1"

# Initialize
client = build_embedding_client_from_env()

Provider Support

Amazon Bedrock

AWS Bedrock hosting allows you to compute high-performance embeddings using models like Titan or Cohere Embed.

  • Client configuration attributes (EmbeddingBackendConfig):
    • provider: "bedrock"
    • model_name: Bedrock embedding model name. Defaults to BEDROCK_EMBEDDING_MODEL_NAME env var.
    • aws_access_key_id: AWS Access Key. Defaults to AWS_ACCESS_KEY_ID env var.
    • aws_secret_access_key: AWS Secret Access Key. Defaults to AWS_SECRET_ACCESS_KEY env var.
    • aws_region: AWS Region. Defaults to AWS_REGION env var.

Example

python
from elsai.integrations.elsai_embeddings import EmbeddingBackendConfig, build_embedding_client

client = build_embedding_client(
    EmbeddingBackendConfig(
        provider="bedrock",
        model_name="amazon.titan-embed-text-v1",
        aws_region="us-east-1",
    )
)

# Returns a float vector list
vector = client.embed_query("Sample query for similarity search")

Azure OpenAI

Azure OpenAI provides robust, managed endpoints for models like text-embedding-3-small or text-embedding-ada-002.

  • Client configuration attributes (EmbeddingBackendConfig):
    • provider: "azure"
    • azure_api_key: Azure OpenAI API Key. Defaults to AZURE_OPENAI_API_KEY env var.
    • azure_endpoint: Azure OpenAI resource endpoint URL. Defaults to AZURE_OPENAI_ENDPOINT env var.
    • azure_api_version: OpenAI API Version. Defaults to OPENAI_API_VERSION env var.
    • azure_deployment: Deployment name for your embedding model. Defaults to AZURE_EMBEDDING_DEPLOYMENT_NAME env var.

Example

python
import os
from elsai.integrations.elsai_embeddings import EmbeddingBackendConfig, build_embedding_client

client = build_embedding_client(
    EmbeddingBackendConfig(
        provider="azure",
        azure_api_key=os.environ.get("AZURE_OPENAI_API_KEY"),
        azure_endpoint="https://my-resource.openai.azure.com",
        azure_api_version="2024-02-01",
        azure_deployment="my-embedding-deployment",
    )
)

vector = client.embed_query("Query statement")

Copyright © 2026 Elsai Foundry.