{"record":{"id":"c7dda0f1e2c96bed","repo":"BerriAI/litellm","slug":"api-base-not-set-for-litellm-proxy-route-set-in-e","errorCode":null,"errorMessage":"api_base not set for LiteLLM Proxy route. Set in env via `LITELLM_PROXY_API_BASE`","messagePattern":"api_base not set for LiteLLM Proxy route\\. Set in env via `LITELLM_PROXY_API_BASE`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/litellm_proxy/chat/transformation.py","lineNumber":48,"sourceCode":"        supported_openai_params: Final = self.get_supported_openai_params(model)\n        for param, value in non_default_params.items():\n            if param == \"thinking\":\n                optional_params.setdefault(\"extra_body\", {})[\"thinking\"] = value\n            elif param in supported_openai_params:\n                optional_params[param] = value\n        return optional_params\n\n    def _get_openai_compatible_provider_info(\n        self, api_base: str | None, api_key: str | None\n    ) -> tuple[str | None, str | None]:\n        api_base = api_base or get_secret_str(\"LITELLM_PROXY_API_BASE\")\n        dynamic_api_key: Final = api_key or get_secret_str(\"LITELLM_PROXY_API_KEY\")\n        return api_base, dynamic_api_key\n\n    def get_models(self, api_key: str | None = None, api_base: str | None = None) -> list[str]:\n        api_base, api_key = self._get_openai_compatible_provider_info(api_base, api_key)\n        if api_base is None:\n            raise ValueError(\"api_base not set for LiteLLM Proxy route. Set in env via `LITELLM_PROXY_API_BASE`\")\n        models: Final = super().get_models(api_key=api_key, api_base=api_base)\n        return [f\"litellm_proxy/{model}\" for model in models]\n\n    @staticmethod\n    def get_api_key(api_key: str | None = None) -> str | None:\n        return api_key or get_secret_str(\"LITELLM_PROXY_API_KEY\")\n\n    @staticmethod\n    def _should_use_litellm_proxy_by_default(\n        litellm_params: LiteLLM_Params | None = None,\n    ):\n        \"\"\"\n        Returns True if litellm proxy should be used by default for a given request\n\n        Issue: https://github.com/BerriAI/litellm/issues/10559\n\n        Use case:\n        - When using Google ADK, users want a flag to dynamically enable sending the request to litellm proxy or not","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/litellm_proxy/chat/transformation.py#L30-L66","documentation":"The litellm_proxy provider forwards OpenAI-compatible calls to another LiteLLM proxy instance. Its get_models must query that upstream proxy, which requires knowing where it is: api_base argument or the LITELLM_PROXY_API_BASE secret/env var. When both are absent it raises ValueError before any HTTP call.","triggerScenarios":"Model discovery on a litellm_proxy model (litellm.get_models / router model list, model names prefixed litellm_proxy/) with no api_base on the deployment and no LITELLM_PROXY_API_BASE set — the handler cannot know which proxy to ask for /models.","commonSituations":"Chaining proxies (proxy A routes to proxy B) but the env var was only configured on one; adding a litellm_proxy/ model to the router without an api_base field; fresh environment missing the chaining secrets.","solutions":["Set LITELLM_PROXY_API_BASE to the upstream proxy URL (e.g. http://proxy-b:4000) in the calling process","Or add api_base directly to the litellm_proxy model deployment in the router/proxy config","Also set LITELLM_PROXY_API_KEY if the upstream proxy requires auth","Restart the process after setting the variable"],"exampleFix":"# before\nfrom litellm.llms.litellm_proxy.chat.transformation import LiteLLMProxyChatConfig\nLiteLLMProxyChatConfig().get_models()  # ValueError: api_base not set for LiteLLM Proxy route\n\n# after\nos.environ[\"LITELLM_PROXY_API_BASE\"] = \"http://proxy-b:4000\"\nos.environ[\"LITELLM_PROXY_API_KEY\"] = \"sk-...\"\nLiteLLMProxyChatConfig().get_models()","handlingStrategy":"validation","validationCode":"import os\n\nPROXY_BASE = os.getenv(\"LITELLM_PROXY_API_BASE\")\nif not PROXY_BASE:\n    raise SystemExit(\"Set LITELLM_PROXY_API_BASE (URL of the upstream LiteLLM proxy) for litellm_proxy models\")","typeGuard":null,"tryCatchPattern":"try:\n    models = LiteLLMProxyChatConfig().get_models()\nexcept ValueError as e:\n    if \"api_base not set\" in str(e):\n        raise ConfigError(\"LITELLM_PROXY_API_BASE missing for proxy chaining\") from e\n    raise","preventionTips":["Configure api_base (and api_key) on every litellm_proxy deployment entry in router/proxy config","Treat LITELLM_PROXY_API_BASE/KEY as required secrets whenever chaining proxies","Validate chaining env vars at proxy startup"],"tags":["litellm-proxy","api-base","get-models","env-var"],"backgroundTag":"missing-api-base-url","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}