microsoft/semantic-kernel · error · ServiceInitializationError

The Amazon Bedrock Chat Model ID is missing.

Error message

The Amazon Bedrock Chat Model ID is missing.

What it means

Raised during BedrockChatCompletion construction when BedrockSettings parses successfully but chat_model_id ends up None. This means no chat model id was supplied via the model_id argument, inferred from model_provider, or loaded from environment — the service cannot target any model.

Source

Thrown at python/semantic_kernel/connectors/ai/bedrock/services/bedrock_chat_completion.py:90

            model_provider: The Bedrock model provider to use.
            service_id: The Service ID for the completion 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.
            env_file_encoding: The encoding of the .env file.
        """
        try:
            bedrock_settings = BedrockSettings(
                chat_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 Chat Completion Service.") from e

        if bedrock_settings.chat_model_id is None:
            raise ServiceInitializationError("The Amazon Bedrock Chat Model ID is missing.")

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

    # region Overriding base class methods

    # Override from AIServiceClientBase
    @override
    def get_prompt_execution_settings_class(self) -> type["PromptExecutionSettings"]:
        return BedrockChatPromptExecutionSettings

    @override
    @trace_chat_completion(BedrockBase.MODEL_PROVIDER_NAME)

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Pass a valid chat model_id explicitly, e.g. BedrockChatCompletion(model_id="anthropic.claude-3-sonnet-20240229-v1:0").
  2. Set the relevant BEDROCK model env var if your settings expect one.
  3. If using model_provider, still supply the concrete model_id.

Example fix

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

# after
service = BedrockChatCompletion(model_id="anthropic.claude-3-sonnet-20240229-v1:0")
Defensive patterns

Strategy: validation

Validate before calling

assert model_id, "A chat model_id is required for BedrockChatCompletion"
service = BedrockChatCompletion(model_id=model_id)

Type guard

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

Try / catch

from semantic_kernel.exceptions import ServiceInitializationError
try:
    service = BedrockChatCompletion(model_id=model_id)
except ServiceInitializationError as e:
    if "Chat Model ID" in str(e):
        service = BedrockChatCompletion(model_id="anthropic.claude-3-sonnet-20240229-v1:0")

Prevention

When it happens

Trigger: Calling BedrockChatCompletion() without model_id and with no BEDROCK chat model id in the environment/settings, or passing model_provider without a corresponding chat_model_id that can be resolved.

Common situations: Forgetting to pass model_id; expecting it to come from env but the env var is unset; misconfiguring model_provider-only construction; CI without seeded model config.

Related errors


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