{"record":{"id":"6af6dec3d2a43a18","repo":"BerriAI/litellm","slug":"api-base-not-set-for-litellm-proxy-route-set-in-e-6af6de","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/image_generation/transformation.py","lineNumber":35,"sourceCode":"        api_key: str | None = None,\n        api_base: str | None = None,\n    ) -> dict:\n        api_key = api_key or get_secret_str(\"LITELLM_PROXY_API_KEY\")\n        headers.update({\"Authorization\": f\"Bearer {api_key}\"})\n        return headers\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        api_key: str | None,\n        model: str,\n        optional_params: dict,\n        litellm_params: dict,\n        stream: bool | None = None,\n    ) -> str:\n        api_base = api_base or get_secret_str(\"LITELLM_PROXY_API_BASE\")\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        api_base = api_base.rstrip(\"/\")\n        return f\"{api_base}/images/generations\"\n","sourceCodeStart":17,"sourceCodeEnd":38,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/litellm_proxy/image_generation/transformation.py#L17-L38","documentation":"The image_generation transformation for the litellm_proxy provider targets {api_base}/images/generations on a downstream LiteLLM Proxy. It resolves api_base from the call parameter or LITELLM_PROXY_API_BASE and raises ValueError when neither is set, since it cannot construct the generations URL.","triggerScenarios":"Calling image generation with model=\"litellm_proxy/...\" while neither api_base nor LITELLM_PROXY_API_BASE is available to the process.","commonSituations":"Using a LiteLLM proxy as an image-generation backend but only configuring the key; env var defined in docker-compose but the service wasn't recreated; typo LITELLM_PROXY_APIBASE.","solutions":["export LITELLM_PROXY_API_BASE=\"http://downstream-proxy:4000\" and restart the service","Or add api_base to the model_list entry's litellm_params for the litellm_proxy image model","Verify with printenv LITELLM_PROXY_API_BASE inside the running container"],"exampleFix":"# before\nimg = litellm.image_generation(model=\"litellm_proxy/dall-e-3\", prompt=\"a cat\")\n\n# after\nimg = litellm.image_generation(\n    model=\"litellm_proxy/dall-e-3\",\n    prompt=\"a cat\",\n    api_base=\"http://downstream-proxy:4000\",\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef litellm_proxy_image_url() -> str:\n    base = os.getenv(\"LITELLM_PROXY_API_BASE\")\n    if not base:\n        raise ValueError(\"Set LITELLM_PROXY_API_BASE before generating images via the proxy\")\n    return f\"{base.rstrip('/')}/images/generations\"","typeGuard":null,"tryCatchPattern":"try:\n    img = litellm.image_generation(model=\"litellm_proxy/dall-e-3\", prompt=p)\nexcept ValueError as e:\n    if \"api_base not set for LiteLLM Proxy\" in str(e):\n        raise RuntimeError(\"Image route misconfigured: upstream proxy base missing\") from e","preventionTips":["Centralize proxy-chain config: one env block with LITELLM_PROXY_API_BASE + LITELLM_PROXY_API_KEY","Add a config-lint step that rejects litellm_proxy/* models lacking api_base","Recreate containers after changing env files so new variables actually load"],"tags":["litellm-proxy","images","config"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}