wandb/openui · error · HTTPException
Groq API key is not set.
Error message
Groq 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 'groq/' but the Groq client was never initialized because the GROQ_API_KEY environment variable was not set at startup. The endpoint checks `if groq is None` and aborts with HTTP 500 before calling the Groq API. It is a server-side configuration error, not an API error from Groq itself.
Source
Thrown at backend/openui/server.py:152
if data.get("model").startswith("gpt"):
if data["model"] == "gpt-4" or data["model"] == "gpt-4-32k":
raise HTTPException(status=400, data="Model not supported")
response: AsyncStream[
ChatCompletionChunk
] = await openai.chat.completions.create(
**data,
)
# gpt-4 tokens are 20x more expensive
multiplier = 20 if "gpt-4" in data["model"] else 1
return StreamingResponse(
openai_stream_generator(response, input_tokens, user_id, multiplier),
media_type="text/event-stream",
)
# 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,View on GitHub (pinned to 42d7ab4ab6)
Solutions
- Set the GROQ_API_KEY environment variable before starting the server (e.g. export GROQ_API_KEY=gsk_... or add it to .env) and restart OpenUI.
- Verify the key is loaded in the running process (docker exec env | grep GROQ or print os.environ in a startup log) since the check happens at import time.
- If you don't intend to use Groq, select a model from a provider whose key is configured instead of a groq/ prefixed model.
- Get a key from console.groq.com if you don't have one and add it to your deployment secrets.
Example fix
// before (start server without key -> 500) python -m uvicorn openui.server:app // after GROQ_API_KEY=gsk_yourkeyhere python -m uvicorn openui.server:app
Defensive patterns
Strategy: validation
Validate before calling
import os
def ensure_groq_ready():
if not os.environ.get("GROQ_API_KEY"):
raise RuntimeError("GROQ_API_KEY is not set; groq/ models are unavailable")
# call before issuing any groq/ model request Prevention
- Keep all provider keys in one .env / secret manifest checked at startup
- Fail fast: assert required env vars at server boot, not first request
- Document per-provider key requirements next to model selection UI
- Pin provider config in deployment templates (docker-compose, k8s secrets)
When it happens
Trigger: POSTing to /chat/completions with data.model starting with 'groq/' (e.g. 'groq/llama3-70b-8192') while the server process was started without GROQ_API_KEY set, so the module-level groq client is None.
Common situations: Deploying OpenUI without configuring the Groq key in the environment (.env not loaded, key omitted in docker-compose or k8s secrets), switching to a Groq model after deploying with only other providers' keys, or restarting a container that lost its env vars.
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
- LiteLLM 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/33cf0a4b1cd0c928.
Report an issue: GitHub.