BerriAI/litellm · error · ValueError

LEMONADE_API_BASE is not set. Please set the environment…

Error message

LEMONADE_API_BASE is not set. Please set the environment variable to query Lemonade's /models endpoint.

What it means

Lemonade get_models needs a base URL to query {api_base}/models. It resolves api_base via _get_openai_compatible_provider_info (LEMONADE_API_BASE env var or explicit parameter) and, if it is still None, raises ValueError telling you to set LEMONADE_API_BASE before the /models query can be made.

Solutions

  1. Export LEMONADE_API_BASE (e.g. export LEMONADE_API_BASE=http://localhost:8000) in the calling process
  2. Or pass api_base directly to the get_models call
  3. Add the variable to your .env / container env so every process that lists models has it
  4. Verify with printenv LEMONADE_API_BASE from the same runtime

Example fix

# before
models = LemonadeConfig().get_models()  # ValueError: LEMONADE_API_BASE is not set

# after
os.environ["LEMONADE_API_BASE"] = "http://localhost:8000"
models = LemonadeConfig().get_models()
# or: models = LemonadeConfig().get_models(api_base="http://localhost:8000")
Defensive patterns

Strategy: validation

Validate before calling

import os

LEMONADE_BASE = os.getenv("LEMONADE_API_BASE")
if not LEMONADE_BASE:
    raise SystemExit("Set LEMONADE_API_BASE (e.g. http://localhost:8000) before listing models")
# then: LemonadeConfig().get_models() or litellm model discovery works

Try / catch

try:
    models = LemonadeConfig().get_models()
except ValueError as e:
    if "LEMONADE_API_BASE is not set" in str(e):
        raise ConfigError("LEMONADE_API_BASE missing") from e
    raise

Prevention

When it happens

Trigger: Calling lemonade model discovery (litellm.get_models / get_models on the lemonade config) with neither an api_base argument nor LEMONADE_API_BASE set in the process; unlike the chat path there is no localhost fallback in this check.

Common situations: Running on a fresh machine/CI where the env var was never set; .env not loaded before the discovery call; assuming the default http://localhost:8000 applies to model listing when the env var is absent.

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


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/db4029d957974b11. Report an issue: GitHub.

Appendix: 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 77b7c6c40c)