{"record":{"id":"da5b9b7ac52eb435","repo":"wandb/openui","slug":"litellm-api-key-is-not-set","errorCode":null,"errorMessage":"LiteLLM API key is not set.","messagePattern":"LiteLLM API key is not set\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/openui/server.py","lineNumber":166,"sourceCode":"        # Groq Models\n        elif data.get(\"model\").startswith(\"groq/\"):\n            data[\"model\"] = data[\"model\"].replace(\"groq/\", \"\")\n            if groq is None:\n                raise HTTPException(status=500, detail=\"Groq API key is not set.\")\n            response: AsyncStream[\n                ChatCompletionChunk\n            ] = await groq.chat.completions.create(\n                **data,\n            )\n            return StreamingResponse(\n                openai_stream_generator(response, input_tokens, user_id, 1),\n                media_type=\"text/event-stream\",\n            )\n        # Litellm Models\n        elif data.get(\"model\").startswith(\"litellm/\"):\n            data[\"model\"] = data[\"model\"].replace(\"litellm/\", \"\")\n            if litellm is None:\n                raise HTTPException(status=500, detail=\"LiteLLM API key is not set.\")\n            response: AsyncStream[\n                ChatCompletionChunk\n            ] = await litellm.chat.completions.create(\n                **data,\n            )\n            return StreamingResponse(\n                openai_stream_generator(response, input_tokens, user_id, 1),\n                media_type=\"text/event-stream\",\n            )\n        # Ollama Time\n        elif data.get(\"model\").startswith(\"ollama/\"):\n            data[\"model\"] = data[\"model\"].replace(\"ollama/\", \"\")\n            data.pop(\"max_tokens\")\n            data[\"messages\"] = openai_to_ollama(data)\n            ollama_vision_models = [\"llava\", \"moondream\"]\n            if any([data[\"model\"].startswith(m) for m in ollama_vision_models]):\n                # The Ollama OpenAPI compatibility layer doesn't support images\n                # see: https://github.com/ollama/ollama/issues/3690","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/wandb/openui/blob/42d7ab4ab6650433486dfb12eb3783c393a3e475/backend/openui/server.py#L148-L184","documentation":"This error is raised by OpenUI's chat_completions endpoint when a request targets a model prefixed with 'litellm/' but the LiteLLM client was never initialized because the required LiteLLM API key environment variable was absent at startup. The handler detects `litellm is None` and returns HTTP 500. Like the Groq case, it is a local configuration problem rather than a remote API failure.","triggerScenarios":"POSTing to /chat/completions with data.model starting with 'litellm/' (e.g. 'litellm/gpt-4o') while the server started without the LITELLM_API_KEY env var, leaving the litellm client as None.","commonSituations":"Running OpenUI behind a LiteLLM proxy without exporting the key, .env file not mounted in the container, key renamed or typo'd in the environment, or deploying with secrets for other providers only.","solutions":["Set the LITELLM_API_KEY environment variable (and any LiteLLM proxy URL if used) before launching the server, then restart.","Confirm the variable name matches exactly what server.py reads at import time — the check runs once at startup, not per request.","Use a model from a provider you have configured if LiteLLM support is not needed.","Check your docker-compose/k8s secret wiring to ensure the key reaches the container environment."],"exampleFix":"// before (docker-compose: key missing -> 500 on litellm/ models)\n// after\nenvironment:\n  - LITELLM_API_KEY=sk-1234\n// then restart: docker compose up -d","handlingStrategy":"validation","validationCode":"import os\ndef ensure_litellm_ready():\n    if not os.environ.get(\"LITELLM_API_KEY\"):\n        raise RuntimeError(\"LITELLM_API_KEY is not set; litellm/ models are unavailable\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify env vars in your container entrypoint before starting uvicorn","Use a single secrets file listing every provider the deployment supports","Test litellm-routed models in CI with the key injected as a secret","Avoid renaming env vars without a migration note"],"tags":["http-500","api-key","configuration","litellm","fastapi"],"backgroundTag":"missing-env-var","analyzedSha":"42d7ab4ab6650433486dfb12eb3783c393a3e475","analyzedAt":"2026-09-01T05:00:32.200Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}