wandb/openui · error · HTTPException
LiteLLM API key is not set.
Error message
LiteLLM API key is not set.
What it means
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.
Source
Thrown at backend/openui/server.py:166
# Groq Models
elif data.get("model").startswith("groq/"):
data["model"] = data["model"].replace("groq/", "")
if groq is None:
raise HTTPException(status=500, detail="Groq API key is not set.")
response: AsyncStream[
ChatCompletionChunk
] = await groq.chat.completions.create(
**data,
)
return StreamingResponse(
openai_stream_generator(response, input_tokens, user_id, 1),
media_type="text/event-stream",
)
# Litellm Models
elif data.get("model").startswith("litellm/"):
data["model"] = data["model"].replace("litellm/", "")
if litellm is None:
raise HTTPException(status=500, detail="LiteLLM API key is not set.")
response: AsyncStream[
ChatCompletionChunk
] = await litellm.chat.completions.create(
**data,
)
return StreamingResponse(
openai_stream_generator(response, input_tokens, user_id, 1),
media_type="text/event-stream",
)
# Ollama Time
elif data.get("model").startswith("ollama/"):
data["model"] = data["model"].replace("ollama/", "")
data.pop("max_tokens")
data["messages"] = openai_to_ollama(data)
ollama_vision_models = ["llava", "moondream"]
if any([data["model"].startswith(m) for m in ollama_vision_models]):
# The Ollama OpenAPI compatibility layer doesn't support images
# see: https://github.com/ollama/ollama/issues/3690View on GitHub (pinned to 42d7ab4ab6)
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.
Example fix
// before (docker-compose: key missing -> 500 on litellm/ models) // after environment: - LITELLM_API_KEY=sk-1234 // then restart: docker compose up -d
Defensive patterns
Strategy: validation
Validate before calling
import os
def ensure_litellm_ready():
if not os.environ.get("LITELLM_API_KEY"):
raise RuntimeError("LITELLM_API_KEY is not set; litellm/ models are unavailable") Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- Groq API key is not set.
- Login required to use OpenUI
- You've exceeded our usage quota, come back tomorrow to gener
- Model not supported
- Invalid model
AI-assisted analysis of wandb/openui@42d7ab4ab6 (2026-09-01).
Data as JSON: /api/errors/da5b9b7ac52eb435.
Report an issue: GitHub.