BerriAI/litellm · error · ValueError
LEMONADE_API_BASE is not set. Please set the environment var
Error message
LEMONADE_API_BASE is not set. Please set the environment variable to query Lemonade's /models endpoint.
What it means
The Lemonade provider (AMD's LLM inference server) has no usable api_base default by the time get_models runs its check, so listing models raises ValueError. Resolution order is the api_base argument, then provider env vars, then LEMONADE_API_BASE; if all are None the /models query cannot proceed.
Source
Thrown at litellm/llms/lemonade/chat/transformation.py:84
return super().get_config()
def get_models(self, api_key: str | None = None, api_base: str | None = None):
"""
Get available models from Lemonade API.
This method queries the Lemonade /models endpoint to retrieve the list of available models.
Args:
api_key: Optional API key for authenticated Lemonade servers
api_base: Optional API base URL (defaults to LEMONADE_API_BASE env var or http://localhost:8000)
Returns:
List of model names prefixed with "lemonade/"
"""
api_base, api_key = self._get_openai_compatible_provider_info(api_base=api_base, api_key=api_key)
if api_base is None:
raise ValueError(
"LEMONADE_API_BASE is not set. Please set the environment variable to query Lemonade's /models endpoint."
)
# Getting the list of models from lemonade
try:
response: Final = litellm.module_level_client.get(
url=f"{api_base}/models",
headers=self._get_auth_headers(api_key),
)
except Exception as e:
raise ValueError(
f"Failed to fetch models from Lemonade. Set Lemonade API Base via `LEMONADE_API_BASE` environment variable. Error: {e}"
)
if response.status_code != 200:
raise ValueError(
f"Failed to fetch models from Lemonade. Status code: {response.status_code}, Response: {response.text}"
)View on GitHub (pinned to 6c2dcb801b)
Solutions
- export LEMONADE_API_BASE="http://localhost:8000" (or your Lemonade server URL) and restart the process
- Or pass api_base explicitly when calling get_models / configuring the model entry
- Confirm the Lemonade server is running: curl http://localhost:8000/models
Example fix
# before models = provider.get_models() # ValueError # after import os os.environ["LEMONADE_API_BASE"] = "http://localhost:8000" models = provider.get_models()
Defensive patterns
Strategy: validation
Validate before calling
import os
def ensure_lemonade_base() -> str:
base = os.getenv("LEMONADE_API_BASE")
if not base:
raise ValueError("LEMONADE_API_BASE must be set before listing Lemonade models")
return base Try / catch
try:
models = provider.get_models()
except ValueError as e:
if "LEMONADE_API_BASE is not set" in str(e):
os.environ["LEMONADE_API_BASE"] = "http://localhost:8000"
models = provider.get_models() Prevention
- Set LEMONADE_API_BASE explicitly even if you expect the localhost default — the fallback chain can yield None
- Add the variable to your service manifest / .env loaded at process start
- Health-check {base}/models on boot before populating model lists
When it happens
Trigger: Calling the models-list path (e.g. proxy model population or provider get_models) without api_base and without LEMONADE_API_BASE in the environment.
Common situations: Fresh setup expecting the documented http://localhost:8000 default but the env var fallback chain resolves to None; Lemonade server not started yet; env var set in a different session/container.
Related errors
- Missing `LLM_GUARD_API_BASE` from environment
- ANTHROPIC_API_BASE/ANTHROPIC_BASE_URL or ANTHROPIC_API_KEY/A
- Missing Azure Document Intelligence API Key - Set AZURE_DOCU
- Missing Azure Document Intelligence Endpoint - Set AZURE_DOC
- Missing Azure AI API Key - A call is being made to Azure AI
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/db4029d957974b11.
Report an issue: GitHub.