{"record":{"id":"7c5971ee2cfe498e","repo":"microsoft/semantic-kernel","slug":"failed-to-initialize-the-amazon-bedrock-text-compl","errorCode":null,"errorMessage":"Failed to initialize the Amazon Bedrock Text Completion Service.","messagePattern":"Failed to initialize the Amazon Bedrock Text Completion Service\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/bedrock/services/bedrock_text_completion.py","lineNumber":71,"sourceCode":"\n        Args:\n            model_id: The Amazon Bedrock text model ID to use.\n            model_provider: The Bedrock model provider to use.\n            service_id: The Service ID for the text completion service.\n            runtime_client: The Amazon Bedrock runtime client to use.\n            client: The Amazon Bedrock client to use.\n            env_file_path: The path to the .env file to load settings from.\n            env_file_encoding: The encoding of the .env file.\n        \"\"\"\n        try:\n            bedrock_settings = BedrockSettings(\n                text_model_id=model_id,\n                model_provider=model_provider,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as e:\n            raise ServiceInitializationError(\"Failed to initialize the Amazon Bedrock Text Completion Service.\") from e\n\n        if bedrock_settings.text_model_id is None:\n            raise ServiceInitializationError(\"The Amazon Bedrock Text Model ID is missing.\")\n\n        super().__init__(\n            ai_model_id=bedrock_settings.text_model_id,\n            service_id=service_id or bedrock_settings.text_model_id,\n            runtime_client=runtime_client,\n            client=client,\n            bedrock_model_provider=bedrock_settings.model_provider,\n        )\n\n    # region Overriding base class methods\n\n    # Override from AIServiceClientBase\n    @override\n    def get_prompt_execution_settings_class(self) -> type[\"PromptExecutionSettings\"]:\n        return BedrockTextPromptExecutionSettings","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/bedrock/services/bedrock_text_completion.py#L53-L89","documentation":"Raised during BedrockTextCompletion construction when BedrockSettings (text_model_id, model_provider, env vars) fails Pydritic validation. Mirrors the chat-completion init error: a ServiceInitializationError thrown before the client is created, with the ValidationError chained.","triggerScenarios":"BedrockSettings validation fails — invalid model_provider, malformed env, missing/invalid required config for the text-completion settings path.","commonSituations":"Unsupported model_provider string; wrong env_file_path; settings schema change after an SDK upgrade; typos in configuration.","solutions":["Inspect the chained ValidationError (e.__cause__) to find the failing field.","Supply a valid text_model_id and supported model_provider.","Verify env file path/encoding if loading from .env."],"exampleFix":"# before\nservice = BedrockTextCompletion(model_id=\"amazon.titan-text\", model_provider=\"bogus\")\n\n# after\nservice = BedrockTextCompletion(model_id=\"amazon.titan-text-express-v1\", model_provider=\"amazon\")","handlingStrategy":"try-catch","validationCode":"SUPPORTED_PROVIDERS = {\"anthropic\", \"amazon\", \"meta\", \"mistral\", \"ai21\", \"cohere\", \"stability\"}\nassert model_provider is None or model_provider in SUPPORTED_PROVIDERS","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import ServiceInitializationError\ntry:\n    service = BedrockTextCompletion(model_id=model_id, model_provider=model_provider)\nexcept ServiceInitializationError as e:\n    print(\"Bedrock settings error:\", e.__cause__)","preventionTips":["Use a supported model_provider or omit to infer from model_id.","Inspect __cause__ for the failing field.","Verify env file path/encoding."],"tags":["bedrock","configuration","service-init","text-completion","python"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}