{"record":{"id":"ed443c88bd0cad96","repo":"microsoft/semantic-kernel","slug":"the-deepseek-model-id-is-required","errorCode":null,"errorMessage":"The DeepSeek model ID is required.","messagePattern":"The DeepSeek model ID is required\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/samples/concepts/setup/chat_completion_services.py","lineNumber":396,"sourceCode":"    The request settings control the behavior of the service. The default settings are sufficient to get started.\n    However, you can adjust the settings to suit your needs.\n    Note: Some of the settings are NOT meant to be set by the user.\n    Please refer to the Semantic Kernel Python documentation for more information:\n    https://learn.microsoft.com/en-us/python/api/semantic-kernel/semantic_kernel?view=semantic-kernel-python\n    \"\"\"\n    from openai import AsyncOpenAI\n\n    from semantic_kernel.connectors.ai.open_ai import (\n        OpenAIChatCompletion,\n        OpenAIChatPromptExecutionSettings,\n        OpenAISettings,\n    )\n\n    openai_settings = OpenAISettings()\n    if not openai_settings.api_key:\n        raise ServiceInitializationError(\"The DeepSeek API key is required.\")\n    if not openai_settings.chat_model_id:\n        raise ServiceInitializationError(\"The DeepSeek model ID is required.\")\n\n    chat_service = OpenAIChatCompletion(\n        ai_model_id=openai_settings.chat_model_id,\n        service_id=service_id,\n        async_client=AsyncOpenAI(\n            api_key=openai_settings.api_key.get_secret_value(),\n            base_url=\"https://api.deepseek.com\",\n        ),\n    )\n    request_settings = OpenAIChatPromptExecutionSettings(service_id=service_id)\n\n    return chat_service, request_settings\n\n\ndef get_nvidia_chat_completion_service_and_request_settings() -> tuple[\n    \"ChatCompletionClientBase\", \"PromptExecutionSettings\"\n]:\n    \"\"\"Return NVIDIA chat completion service and request settings.","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/samples/concepts/setup/chat_completion_services.py#L378-L414","documentation":"This ServiceInitializationError is raised in the DeepSeek sample when instantiating OpenAISettings reveals no chat model ID. The sample reuses the OpenAI connector (DeepSeek's API is OpenAI-compatible), so it reads the standard OpenAI settings object whose chat_model_id is populated from the OPENAI_CHAT_MODEL_ID environment variable. If that value is absent or empty, the service cannot be constructed and startup aborts.","triggerScenarios":"Calling get_deepseek_chat_completion_service_and_request_settings() when OPENAI_CHAT_MODEL_ID is unset/empty. OpenAISettings() loads at construction time from env vars and/or a .env file; a falsy chat_model_id trips the guard at line 396.","commonSituations":"The .env file is missing or not on the load path; the variable was named OPENAI_MODEL_ID instead of OPENAI_CHAT_MODEL_ID; the key (OPENAI_API_KEY) was set but the model id was forgotten; running the sample in a fresh shell without exporting the variable.","solutions":["Set OPENAI_CHAT_MODEL_ID to a DeepSeek model id (deepseek-chat or deepseek-reasoner) in your environment or .env file.","Verify the .env file lives in the working directory the sample is launched from so OpenAISettings picks it up.","Print/inspect openai_settings.chat_model_id immediately after construction to confirm the value resolves before the guard fires.","If setting via code, construct OpenAISettings(chat_model_id='deepseek-chat') explicitly instead of relying on env."],"exampleFix":"// before\nOPENAI_API_KEY=sk-...\n# (no model id set)\n\n// after\nOPENAI_API_KEY=sk-...\nOPENAI_CHAT_MODEL_ID=deepseek-chat","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.ai.open_ai import OpenAISettings\n\nsettings = OpenAISettings()\nif not settings.chat_model_id:\n    raise SystemExit(\"Set OPENAI_CHAT_MODEL_ID (deepseek-chat or deepseek-reasoner) before running.\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a checked .env template listing OPENAI_API_KEY and OPENAI_CHAT_MODEL_ID for the DeepSeek sample.","Validate settings presence in a startup hook before constructing the chat service."],"tags":["configuration","env-vars","deepseek","openai-connector","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}