microsoft/semantic-kernel · error · ValueError
Model ID {model_id} does not contain a valid model provider
Error message
Model ID {model_id} does not contain a valid model provider name. What it means
Raised by BedrockModelProvider.to_model_provider when none of the known provider substrings ('ai21', 'amazon', 'anthropic', 'cohere', 'meta', 'mistral') appear in the supplied model_id. The connector routes requests to provider-specific builders by matching the provider name inside the model ID string, so an unrecognized ID cannot be routed.
Source
Thrown at python/semantic_kernel/connectors/ai/bedrock/services/model_provider/bedrock_model_provider.py:43
"""Amazon Bedrock Model Provider Enum.
This list contains the providers of all base models available on Amazon Bedrock.
"""
AI21LABS = "ai21"
AMAZON = "amazon"
ANTHROPIC = "anthropic"
COHERE = "cohere"
META = "meta"
MISTRALAI = "mistral"
@classmethod
def to_model_provider(cls, model_id: str) -> "BedrockModelProvider":
"""Convert a model ID to a model provider."""
try:
return next(provider for provider in cls if provider.value in model_id)
except StopIteration:
raise ValueError(f"Model ID {model_id} does not contain a valid model provider name.")
# region Text Completion
TEXT_COMPLETION_REQUEST_BODY_MAPPING: dict[
BedrockModelProvider, Callable[[str, BedrockTextPromptExecutionSettings], Any]
] = {
BedrockModelProvider.AMAZON: bedrock_amazon_titan.get_text_completion_request_body,
BedrockModelProvider.ANTHROPIC: bedrock_anthropic_claude.get_text_completion_request_body,
BedrockModelProvider.COHERE: bedrock_cohere.get_text_completion_request_body,
BedrockModelProvider.AI21LABS: bedrock_ai21_labs.get_text_completion_request_body,
BedrockModelProvider.META: bedrock_meta_llama.get_text_completion_request_body,
BedrockModelProvider.MISTRALAI: bedrock_mistralai.get_text_completion_request_body,
}
TEXT_COMPLETION_RESPONSE_MAPPING: dict[BedrockModelProvider, Callable[[dict[str, Any], str], list[TextContent]]] = {
BedrockModelProvider.AMAZON: bedrock_amazon_titan.parse_text_completion_response,View on GitHub (pinned to c028a0c7dc)
Solutions
- Use the full Bedrock model ID including the provider prefix, e.g. 'anthropic.claude-3-5-sonnet-20240620-v1:0', 'amazon.titan-embed-text-v2:0', 'meta.llama3-8b-instruct-v1:0'.
- If using a cross-region or provisioned inference profile ARN, resolve the underlying base model ID first, or pass an explicit model_provider argument to bypass string matching.
- If the provider is genuinely new (not in the BedrockModelProvider enum), request a library update; do not edit the enum in a fork unless you own the build.
- Validate the model_id against your Bedrock account's list of available foundation models before constructing the service.
Example fix
// before service = BedrockChatCompletion(model_id="claude-3-sonnet") // after service = BedrockChatCompletion(model_id="anthropic.claude-3-5-sonnet-20240620-v1:0")
Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED_PROVIDERS = ("ai21", "amazon", "anthropic", "cohere", "meta", "mistral")
def has_valid_bedrock_provider(model_id: str) -> bool:
return any(p in model_id for p in SUPPORTED_PROVIDERS) Type guard
SUPPORTED_PROVIDERS = ("ai21", "amazon", "anthropic", "cohere", "meta", "mistral")
def is_valid_bedrock_model_id(model_id: object) -> bool:
return isinstance(model_id, str) and any(p in model_id for p in SUPPORTED_PROVIDERS) Try / catch
try:
service = BedrockChatCompletion(model_id=model_id)
except ValueError as e:
if "does not contain a valid model provider name" in str(e):
raise ValueError(f"Use a full Bedrock model ID like 'anthropic.claude-3-5-sonnet-...'. Got: {model_id}") from e
raise Prevention
- Always pass the full Bedrock model ID with provider prefix.
- Validate the model ID against Bedrock's list-foundation-models output before constructing the service.
- For inference-profile ARNs, pass model_provider explicitly to bypass string matching.
When it happens
Trigger: Any Bedrock text/chat/embedding call that goes through get_*_request_body or parse_*_response without an explicit model_provider argument. Fires for a model_id like 'my-custom-model', 'llama-3-8b' (missing 'meta'), or an ARN/provisioned-model ID that does not contain one of the six provider keywords.
Common situations: User passes a short model alias instead of the full Bedrock model ID (e.g. 'claude-3' instead of 'anthropic.claude-3-sonnet'); using a new provider Bedrock added that SK has not mapped yet; passing an inference-profile ARN; copy-paste typo in the model ID.
Related errors
- The Amazon Bedrock Chat Model ID is missing.
- The Amazon Bedrock Text Model ID is missing.
- The Amazon Bedrock Text Embedding Model ID is missing.
- Unsupported AI21 model: {modelId}
- Unsupported Amazon model: {modelId}
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/ea8245fca8df7dbf.
Report an issue: GitHub.