microsoft/semantic-kernel · error · ServiceInitializationError
The MistralAI embedding model ID is required.
Error message
The MistralAI embedding model ID is required.
What it means
Raised as ServiceInitializationError right after settings validation succeeds, when `mistralai_settings.embedding_model_id` is still falsy. The connector requires a concrete embedding model id and will not guess one (unlike NVIDIA which has a default). It fires whether or not an api_key is present.
Source
Thrown at python/semantic_kernel/connectors/ai/mistral_ai/services/mistral_ai_text_embedding.py:69
async_client : The Mistral AI client to use.
env_file_path : The path to the environment file.
env_file_encoding : The encoding of the environment file.
Raises:
ServiceInitializationError: If an error occurs during initialization.
"""
try:
mistralai_settings = MistralAISettings(
api_key=api_key,
embedding_model_id=ai_model_id,
env_file_path=env_file_path,
env_file_encoding=env_file_encoding,
)
except ValidationError as e:
raise ServiceInitializationError(f"Failed to validate Mistral AI settings: {e}") from e
if not mistralai_settings.embedding_model_id:
raise ServiceInitializationError("The MistralAI embedding model ID is required.")
if not async_client:
async_client = Mistral(
api_key=mistralai_settings.api_key.get_secret_value(),
)
super().__init__(
service_id=service_id or mistralai_settings.embedding_model_id,
ai_model_id=ai_model_id or mistralai_settings.embedding_model_id,
async_client=async_client,
)
@override
async def generate_embeddings(
self,
texts: list[str],
settings: "PromptExecutionSettings | None" = None,
**kwargs: Any,
) -> ndarray:View on GitHub (pinned to c028a0c7dc)
Solutions
- Pass ai_model_id explicitly: MistralAITextEmbedding(ai_model_id='mistral-embed').
- Set MISTRALAI_EMBEDDING_MODEL_ID in env/.env (note the EMBEDDING_ segment).
- Check for typos against the documented env var name.
Example fix
# before svc = MistralAITextEmbedding(api_key=key) # after svc = MistralAITextEmbedding(api_key=key, ai_model_id='mistral-embed')
Defensive patterns
Strategy: validation
Validate before calling
model_id = os.environ.get('MISTRALAI_EMBEDDING_MODEL_ID') or 'mistral-embed'
assert model_id, 'embedding model id required'
svc = MistralAITextEmbedding(ai_model_id=model_id, api_key=os.environ['MISTRALAI_API_KEY']) Type guard
def has_embedding_model_id(svc_cls, **kw) -> bool:
mid = kw.get('ai_model_id') or os.environ.get('MISTRALAI_EMBEDDING_MODEL_ID')
return bool(mid) Try / catch
from semantic_kernel.exceptions import ServiceInitializationError
try:
svc = MistralAITextEmbedding()
except ServiceInitializationError as e:
if 'embedding model ID is required' in str(e):
svc = MistralAITextEmbedding(ai_model_id='mistral-embed', api_key=os.environ['MISTRALAI_API_KEY'])
else:
raise Prevention
- Always pass ai_model_id for the embedding service.
- Use the exact env var MISTRALAI_EMBEDDING_MODEL_ID (note EMBEDDING).
- Distinguish embedding model ids from chat model ids.
When it happens
Trigger: Constructing `MistralAITextEmbedding()` (or with only api_key) without supplying `ai_model_id` AND without setting MISTRALAI_EMBEDDING_MODEL_ID in env/.env. Validation passed (api_key ok) but the model id resolved to None.
Common situations: Developer copied the chat completion setup (which may default model id) expecting embeddings to do the same; MISTRALAI_EMBEDDING_MODEL_ID typo'd as MISTRALAI_MODEL_ID or MISTRALAI_CHAT_MODEL_ID.
Related errors
- Failed to validate Mistral AI settings: {e}
- Failed to create NVIDIA settings.
- The Amazon Bedrock Text Embedding Model ID is missing.
- Failed to validate Google AI settings: {e}
- The Google AI embedding model ID is required.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/493f27f244fa3ad0.
Report an issue: GitHub.