microsoft/semantic-kernel · error · ServiceInitializationError

The Amazon Bedrock Text Embedding Model ID is missing.

Error message

The Amazon Bedrock Text Embedding Model ID is missing.

What it means

Raised during BedrockTextEmbedding construction when BedrockSettings parses but embedding_model_id resolves to None. The embedding service needs a concrete embedding model id; without one it cannot target a model for generate_embeddings.

Source

Thrown at python/semantic_kernel/connectors/ai/bedrock/services/bedrock_text_embedding.py:71

            model_provider: The Bedrock model provider to use.
            service_id: The Service ID for the text embedding service.
            runtime_client: The Amazon Bedrock runtime client to use.
            client: The Amazon Bedrock client to use.
            env_file_path: The path to the .env file to load settings from.
            env_file_encoding: The encoding of the .env file.
        """
        try:
            bedrock_settings = BedrockSettings(
                embedding_model_id=model_id,
                model_provider=model_provider,
                env_file_path=env_file_path,
                env_file_encoding=env_file_encoding,
            )
        except ValidationError as e:
            raise ServiceInitializationError("Failed to initialize the Amazon Bedrock Text Embedding Service.") from e

        if bedrock_settings.embedding_model_id is None:
            raise ServiceInitializationError("The Amazon Bedrock Text Embedding Model ID is missing.")

        super().__init__(
            ai_model_id=bedrock_settings.embedding_model_id,
            service_id=service_id or bedrock_settings.embedding_model_id,
            runtime_client=runtime_client,
            client=client,
            bedrock_model_provider=bedrock_settings.model_provider,
        )

    @override
    async def generate_embeddings(
        self,
        texts: list[str],
        settings: "PromptExecutionSettings | None" = None,
        **kwargs: Any,
    ) -> ndarray:
        if not settings:
            settings = BedrockEmbeddingPromptExecutionSettings()

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Pass a valid embedding model_id explicitly.
  2. Set the relevant BEDROCK embedding model env var if configured.
  3. Always supply model_id even when model_provider is given.

Example fix

# before
service = BedrockTextEmbedding()  # no model id → error

# after
service = BedrockTextEmbedding(model_id="amazon.titan-embed-text-v2:0")
Defensive patterns

Strategy: validation

Validate before calling

assert model_id, "An embedding model_id is required for BedrockTextEmbedding"
service = BedrockTextEmbedding(model_id=model_id)

Type guard

def has_embedding_model_id(model_id) -> bool:
    return bool(model_id)

Try / catch

from semantic_kernel.exceptions import ServiceInitializationError
try:
    service = BedrockTextEmbedding(model_id=model_id)
except ServiceInitializationError as e:
    if "Embedding Model ID" in str(e):
        service = BedrockTextEmbedding(model_id="amazon.titan-embed-text-v2:0")

Prevention

When it happens

Trigger: Calling BedrockTextEmbedding() without model_id and no BEDROCK embedding model id in the environment, or providing only model_provider without a resolvable embedding_model_id.

Common situations: Forgetting to pass model_id; expecting env to provide it but it is unset; constructing from provider only.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/e31653f2267fedec. Report an issue: GitHub.