{"record":{"id":"4936bcb2c08faac7","repo":"HKUDS/DeepTutor","slug":"openai-api-key-is-not-configured-set-it-in-settin","errorCode":null,"errorMessage":"OpenAI API key is not configured. Set it in Settings > Catalog, or select a local provider such as Ollama.","messagePattern":"OpenAI API key is not configured\\. Set it in Settings > Catalog, or select a local provider such as Ollama\\.","errorType":"validation","errorClass":"LLMConfigError","httpStatus":null,"severity":"critical","filePath":"deeptutor/services/llm/config.py","lineNumber":187,"sourceCode":"\ndef _get_llm_config_from_resolver() -> LLMConfig:\n    \"\"\"Resolve LLM config from the TutorBot-style runtime adapter.\"\"\"\n    resolved = resolve_llm_runtime_config()\n    if not resolved.model:\n        raise LLMConfigError(\n            \"No active LLM model is configured. Please set it in Settings > Catalog.\"\n        )\n    if not resolved.effective_url and resolved.provider_mode != \"oauth\":\n        raise LLMConfigError(\n            \"No effective LLM endpoint resolved. Please configure base_url or provider defaults.\"\n        )\n    is_placeholder_key = resolved.api_key in {\"\", \"no-key\", \"sk-no-key-required\"}\n    if (\n        resolved.provider_name == \"openai\"\n        and resolved.provider_mode == \"standard\"\n        and is_placeholder_key\n    ):\n        raise LLMConfigError(\n            \"OpenAI API key is not configured. Set it in Settings > Catalog, \"\n            \"or select a local provider such as Ollama.\"\n        )\n    return LLMConfig(\n        model=resolved.model,\n        api_key=resolved.api_key,\n        base_url=resolved.base_url,\n        effective_url=resolved.effective_url,\n        binding=resolved.binding,\n        provider_name=resolved.provider_name,\n        provider_mode=resolved.provider_mode,\n        api_version=resolved.api_version,\n        extra_headers=resolved.extra_headers,\n        reasoning_effort=resolved.reasoning_effort,\n        context_window=resolved.context_window,\n    )\n\n","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/llm/config.py#L169-L205","documentation":"After resolving model and URL, the config loader enforces authentication for official OpenAI: if the provider is openai, mode is standard (not oauth), and the api_key is one of the placeholder values ('', 'no-key', 'sk-no-key-required'), it raises LLMConfigError with actionable guidance. Local providers like Ollama are explicitly offered as the alternative.","triggerScenarios":"Provider=openai with no API key stored and mode=standard; key still at the shipped placeholder 'sk-no-key-required' from a template settings file; OPENAI_API_KEY unset in the environment fallback.","commonSituations":"Users running the default profile unchanged; template/docker setups shipping placeholder keys; env var present in one shell but the server launched from another; CI without secrets.","solutions":["Set the OpenAI key in Settings > Catalog or via OPENAI_API_KEY.","If you intended local inference, switch the provider to Ollama (or set its base_url) instead of OpenAI.","Remove placeholder strings like 'sk-no-key-required' from settings templates.","For OAuth flows, set provider_mode to 'oauth' so this check is bypassed."],"exampleFix":"// before\nexport OPENAI_API_KEY=sk-no-key-required\n\n# after\nexport OPENAI_API_KEY=sk-...your-real-key...","handlingStrategy":"validation","validationCode":"PLACEHOLDERS = {\"\", \"no-key\", \"sk-no-key-required\"}\nresolved = resolve_llm_runtime_config()\nif resolved.provider_name == \"openai\" and resolved.provider_mode == \"standard\" and resolved.api_key in PLACEHOLDERS:\n    raise RuntimeError(\"Set an OpenAI key or switch to a local provider\")\ncfg = get_llm_config()","typeGuard":"def is_placeholder_key(api_key: str | None) -> bool:\n    return (api_key or \"\") in {\"\", \"no-key\", \"sk-no-key-required\"}","tryCatchPattern":"try:\n    cfg = get_llm_config()\nexcept LLMConfigError as e:\n    if \"OpenAI API key is not configured\" in str(e):\n        prompt_for_openai_key_or_switch_to_ollama()\n    raise","preventionTips":["Scrub placeholder keys from templates and docker images.","Export OPENAI_API_KEY in the same shell/session that launches the server.","Default fresh installs to a local provider when no cloud key is present."],"tags":["llm","openai","authentication","api-key","configuration"],"backgroundTag":"missing-api-key","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}