{"record":{"id":"318abedf7c0f5451","repo":"BerriAI/litellm","slug":"failed-to-fetch-models-from-lemonade-set-lemonade","errorCode":null,"errorMessage":"Failed to fetch models from Lemonade. Set Lemonade API Base via `LEMONADE_API_BASE` environment variable. Error: {e}","messagePattern":"Failed to fetch models from Lemonade\\. Set Lemonade API Base via `LEMONADE_API_BASE` environment variable\\. Error: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/lemonade/chat/transformation.py","lineNumber":95,"sourceCode":"\n        Returns:\n            List of model names prefixed with \"lemonade/\"\n        \"\"\"\n        api_base, api_key = self._get_openai_compatible_provider_info(api_base=api_base, api_key=api_key)\n\n        if api_base is None:\n            raise ValueError(\n                \"LEMONADE_API_BASE is not set. Please set the environment variable to query Lemonade's /models endpoint.\"\n            )\n\n        # Getting the list of models from lemonade\n        try:\n            response: Final = litellm.module_level_client.get(\n                url=f\"{api_base}/models\",\n                headers=self._get_auth_headers(api_key),\n            )\n        except Exception as e:\n            raise ValueError(\n                f\"Failed to fetch models from Lemonade. Set Lemonade API Base via `LEMONADE_API_BASE` environment variable. Error: {e}\"\n            )\n\n        if response.status_code != 200:\n            raise ValueError(\n                f\"Failed to fetch models from Lemonade. Status code: {response.status_code}, Response: {response.text}\"\n            )\n\n        model_list: Final = response.json().get(\"data\", [])\n        return [\"lemonade/\" + model[\"id\"] for model in model_list]\n\n    @staticmethod\n    def _get_positive_int(value: Any) -> int | None:\n        if isinstance(value, bool):\n            return None\n        if isinstance(value, int) and value > 0:\n            return value\n        if isinstance(value, str):","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/lemonade/chat/transformation.py#L77-L113","documentation":"While fetching Lemonade's /models endpoint to enumerate available models, the HTTP request itself threw (connection refused, DNS failure, timeout, TLS error). The exception text is embedded in a ValueError that also reminds you to set LEMONADE_API_BASE, because a wrong base URL is the most common root cause.","triggerScenarios":"LEMONADE_API_BASE pointing at a host/port where nothing listens (connection refused); wrong hostname (DNS resolution failure); server behind a proxy that blocks the request; self-signed cert causing TLS errors.","commonSituations":"Lemonade server not running or still loading models; base URL copied with a typo; firewall/proxy blocking localhost replacement; container networking where 'localhost' refers to the wrong namespace.","solutions":["Start/verify the Lemonade server: curl {LEMONADE_API_BASE}/models","Fix the base URL (correct host/port; inside Docker use the service name, not localhost)","Add allowrules for the proxy or disable the proxy for the Lemonade host","Retry once the server has finished model loading (first load can take minutes)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"def lemonade_reachable(api_base: str) -> bool:\n    import socket\n    from urllib.parse import urlparse\n    u = urlparse(api_base)\n    try:\n        with socket.create_connection((u.hostname, u.port or 80), timeout=3):\n            return True\n    except OSError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    models = provider.get_models()\nexcept ValueError as e:\n    if \"Failed to fetch models\" in str(e) and lemonade_reachable(base):\n        time.sleep(2)\n        models = provider.get_models()  # one bounded retry\n    else:\n        raise","preventionTips":["Wait for the Lemonade server's readiness signal (models loaded) before listing models — first load is slow","In Docker, use service names instead of localhost in LEMONADE_API_BASE","Distinguish connection errors (this case) from HTTP error statuses by checking for 'Status code' in the message"],"tags":["lemonade","network","config"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}