{"record":{"id":"198de84fcd1f6baf","repo":"microsoft/semantic-kernel","slug":"the-mistralai-chat-model-id-is-required","errorCode":null,"errorMessage":"The MistralAI chat model ID is required.","messagePattern":"The MistralAI chat model ID is required\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/mistral_ai/services/mistral_ai_chat_completion.py","lineNumber":97,"sourceCode":"            api_key : The optional API key to use. If provided will override,\n                the env vars or .env file value.\n            async_client : An existing client to use.\n            env_file_path : Use the environment settings file as a fallback\n                to environment variables.\n            env_file_encoding : The encoding of the environment settings file.\n        \"\"\"\n        try:\n            mistralai_settings = MistralAISettings(\n                api_key=api_key,\n                chat_model_id=ai_model_id,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as ex:\n            raise ServiceInitializationError(\"Failed to create MistralAI settings.\", ex) from ex\n\n        if not mistralai_settings.chat_model_id:\n            raise ServiceInitializationError(\"The MistralAI chat 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\n        super().__init__(\n            async_client=async_client,\n            service_id=service_id or mistralai_settings.chat_model_id,\n            ai_model_id=ai_model_id or mistralai_settings.chat_model_id,\n        )\n\n    # region Overriding base class methods\n\n    # Override from AIServiceClientBase\n    @override\n    def get_prompt_execution_settings_class(self) -> \"type[MistralAIChatPromptExecutionSettings]\":\n        \"\"\"Create a request settings object.\"\"\"","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/mistral_ai/services/mistral_ai_chat_completion.py#L79-L115","documentation":"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.","triggerScenarios":"Constructing MistralAIChatCompletion without ai_model_id and no chat model env var. Passing an empty string for the model id.","commonSituations":"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.","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."],"exampleFix":"# before\nsvc = MistralAIChatCompletion(api_key=os.environ['MISTRAL_API_KEY'])\n# after\nsvc = MistralAIChatCompletion(api_key=os.environ['MISTRAL_API_KEY'], ai_model_id='mistral-large-latest')","handlingStrategy":"validation","validationCode":"model_id = os.environ.get('MISTRAL_CHAT_MODEL_ID') or passed_model_id\nassert model_id, 'MistralAI chat model ID is required'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["mistral-ai","configuration","model-id","initialization"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}