microsoft/semantic-kernel · error · ServiceInitializationError

The Amazon Bedrock Text Model ID is missing.

Error message

The Amazon Bedrock Text Model ID is missing.

What it means

Raised during BedrockTextCompletion construction when BedrockSettings parses but text_model_id resolves to None. The text completion service requires a concrete text model id (supplied via model_id, inferred, or from env); without it the service has no target model.

Source

Thrown at python/semantic_kernel/connectors/ai/bedrock/services/bedrock_text_completion.py:74

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

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

        super().__init__(
            ai_model_id=bedrock_settings.text_model_id,
            service_id=service_id or bedrock_settings.text_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 BedrockTextPromptExecutionSettings

    @override
    @trace_text_completion(BedrockBase.MODEL_PROVIDER_NAME)

View on GitHub (pinned to c028a0c7dc)

Solutions

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

Example fix

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

# after
service = BedrockTextCompletion(model_id="amazon.titan-text-express-v1")
Defensive patterns

Strategy: validation

Validate before calling

assert model_id, "A text model_id is required for BedrockTextCompletion"
service = BedrockTextCompletion(model_id=model_id)

Type guard

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

Try / catch

from semantic_kernel.exceptions import ServiceInitializationError
try:
    service = BedrockTextCompletion(model_id=model_id)
except ServiceInitializationError as e:
    if "Text Model ID" in str(e):
        service = BedrockTextCompletion(model_id="amazon.titan-text-express-v1")

Prevention

When it happens

Trigger: Calling BedrockTextCompletion() without model_id and no BEDROCK text model id in the environment, or providing only model_provider without a resolvable text_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/b8f4ef2a376c077e. Report an issue: GitHub.