{"record":{"id":"493f27f244fa3ad0","repo":"microsoft/semantic-kernel","slug":"the-mistralai-embedding-model-id-is-required","errorCode":null,"errorMessage":"The MistralAI embedding model ID is required.","messagePattern":"The MistralAI embedding model ID is required\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/mistral_ai/services/mistral_ai_text_embedding.py","lineNumber":69,"sourceCode":"            async_client : The Mistral AI client to use.\n            env_file_path : The path to the environment file.\n            env_file_encoding : The encoding of the environment file.\n\n        Raises:\n            ServiceInitializationError: If an error occurs during initialization.\n        \"\"\"\n        try:\n            mistralai_settings = MistralAISettings(\n                api_key=api_key,\n                embedding_model_id=ai_model_id,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as e:\n            raise ServiceInitializationError(f\"Failed to validate Mistral AI settings: {e}\") from e\n\n        if not mistralai_settings.embedding_model_id:\n            raise ServiceInitializationError(\"The MistralAI embedding model ID is required.\")\n\n        if not async_client:\n            async_client = Mistral(\n                api_key=mistralai_settings.api_key.get_secret_value(),\n            )\n        super().__init__(\n            service_id=service_id or mistralai_settings.embedding_model_id,\n            ai_model_id=ai_model_id or mistralai_settings.embedding_model_id,\n            async_client=async_client,\n        )\n\n    @override\n    async def generate_embeddings(\n        self,\n        texts: list[str],\n        settings: \"PromptExecutionSettings | None\" = None,\n        **kwargs: Any,\n    ) -> ndarray:","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/mistral_ai/services/mistral_ai_text_embedding.py#L51-L87","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nsvc = MistralAITextEmbedding(api_key=key)\n\n# after\nsvc = MistralAITextEmbedding(api_key=key, ai_model_id='mistral-embed')","handlingStrategy":"validation","validationCode":"model_id = os.environ.get('MISTRALAI_EMBEDDING_MODEL_ID') or 'mistral-embed'\nassert model_id, 'embedding model id required'\nsvc = MistralAITextEmbedding(ai_model_id=model_id, api_key=os.environ['MISTRALAI_API_KEY'])","typeGuard":"def has_embedding_model_id(svc_cls, **kw) -> bool:\n    mid = kw.get('ai_model_id') or os.environ.get('MISTRALAI_EMBEDDING_MODEL_ID')\n    return bool(mid)","tryCatchPattern":"from semantic_kernel.exceptions import ServiceInitializationError\ntry:\n    svc = MistralAITextEmbedding()\nexcept ServiceInitializationError as e:\n    if 'embedding model ID is required' in str(e):\n        svc = MistralAITextEmbedding(ai_model_id='mistral-embed', api_key=os.environ['MISTRALAI_API_KEY'])\n    else:\n        raise","preventionTips":["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."],"tags":["mistral-ai","embeddings","settings","model-id","service-initialization-error"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}