microsoft/semantic-kernel · error · ServiceInitializationError
The MistralAI chat model ID is required.
Error message
The MistralAI chat model ID is required.
What it means
Raised by MistralAIChatCompletion.__init__ after settings validate but chat_model_id resolves to a falsy value. Without a model id the service cannot target a Mistral model, so initialization aborts even though credentials are valid.
Source
Thrown at python/semantic_kernel/connectors/ai/mistral_ai/services/mistral_ai_chat_completion.py:97
api_key : The optional API key to use. If provided will override,
the env vars or .env file value.
async_client : An existing client to use.
env_file_path : Use the environment settings file as a fallback
to environment variables.
env_file_encoding : The encoding of the environment settings file.
"""
try:
mistralai_settings = MistralAISettings(
api_key=api_key,
chat_model_id=ai_model_id,
env_file_path=env_file_path,
env_file_encoding=env_file_encoding,
)
except ValidationError as ex:
raise ServiceInitializationError("Failed to create MistralAI settings.", ex) from ex
if not mistralai_settings.chat_model_id:
raise ServiceInitializationError("The MistralAI chat model ID is required.")
if not async_client:
async_client = Mistral(
api_key=mistralai_settings.api_key.get_secret_value(),
)
super().__init__(
async_client=async_client,
service_id=service_id or mistralai_settings.chat_model_id,
ai_model_id=ai_model_id or mistralai_settings.chat_model_id,
)
# region Overriding base class methods
# Override from AIServiceClientBase
@override
def get_prompt_execution_settings_class(self) -> "type[MistralAIChatPromptExecutionSettings]":
"""Create a request settings object."""View on GitHub (pinned to c028a0c7dc)
Solutions
- Pass ai_model_id explicitly to MistralAIChatCompletion (e.g. 'mistral-large-latest').
- Set the chat model id via environment variable / .env.
- Confirm the model id is non-empty and references a valid Mistral model.
Example fix
# before svc = MistralAIChatCompletion(api_key=os.environ['MISTRAL_API_KEY']) # after svc = MistralAIChatCompletion(api_key=os.environ['MISTRAL_API_KEY'], ai_model_id='mistral-large-latest')
Defensive patterns
Strategy: validation
Validate before calling
model_id = os.environ.get('MISTRAL_CHAT_MODEL_ID') or passed_model_id
assert model_id, 'MistralAI chat model ID is required' Prevention
- Always pass ai_model_id explicitly or via a verified env var.
- Fail fast if the model id is empty.
- Centralize model ids in one config source.
When it happens
Trigger: Constructing MistralAIChatCompletion without ai_model_id and no chat model env var. Passing an empty string for the model id.
Common situations: Forgetting to set the model id env var. Assuming a default model. Sample code that omits the model argument while .env doesn't define it.
Related errors
- The Google AI Gemini model ID is required.
- The Vertex AI Gemini model ID is required.
- The Vertex AI Gemini model ID is required.
- The Vertex AI embedding model ID is required.
- Failed to create MistralAI settings.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/198de84fcd1f6baf.
Report an issue: GitHub.