{"record":{"id":"e824155bfdebf7d3","repo":"BerriAI/litellm","slug":"api-base-not-set-for-litellm-proxy-route-set-in-e-e82415","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_edit/transformation.py","lineNumber":23,"sourceCode":"class LiteLLMProxyImageEditConfig(OpenAIImageEditConfig):\n    \"\"\"Configuration for image edit requests routed through LiteLLM Proxy.\"\"\"\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        api_key: str | None = None,\n        litellm_params: dict | 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(self, model: str, api_base: str | None, litellm_params: dict) -> 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/edits\"\n","sourceCodeStart":5,"sourceCodeEnd":26,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/litellm_proxy/image_edit/transformation.py#L5-L26","documentation":"The image_edit transformation for the litellm_proxy provider builds the URL {api_base}/images/edits for forwarding image edits to a downstream LiteLLM Proxy. api_base is resolved from the parameter or LITELLM_PROXY_API_BASE; when both are None, get_complete_url raises ValueError before any request is sent.","triggerScenarios":"Calling image editing (model=\"litellm_proxy/<name>\") without api_base on the call and without LITELLM_PROXY_API_BASE in the environment.","commonSituations":"Proxy-to-proxy image editing configured with only an API key, no base URL; env var present in dev shell but missing in the container running the edits.","solutions":["Set LITELLM_PROXY_API_BASE to the downstream proxy base URL","Or pass api_base=\"http://downstream-proxy:4000\" on the image_edit call / model config","Pair it with LITELLM_PROXY_API_KEY (or api_key) so the Authorization header is valid"],"exampleFix":"# before\nresp = litellm.image_edit(model=\"litellm_proxy/gpt-image-1\", image=..., prompt=...)\n\n# after\nresp = litellm.image_edit(\n    model=\"litellm_proxy/gpt-image-1\",\n    image=..., prompt=...,\n    api_base=\"http://downstream-proxy:4000\",\n    api_key=\"sk-upstream\",\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef ensure_proxy_base_for_images(api_base: str | None = None) -> str:\n    base = (api_base or os.getenv(\"LITELLM_PROXY_API_BASE\", \"\")).rstrip(\"/\")\n    if not base:\n        raise ValueError(\"Downstream proxy base URL required for image edits\")\n    return base","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.image_edit(model=\"litellm_proxy/gpt-image-1\", image=img, prompt=p, api_base=ensure_proxy_base_for_images())\nexcept ValueError as e:\n    if \"api_base not set for LiteLLM Proxy\" in str(e):\n        # config error — provision the env var; no retry will help\n        raise","preventionTips":["Put api_base in the litellm_proxy image model's litellm_params so callers never pass it manually","Validate image-model deployments at config load: litellm_proxy/* entries must resolve a base URL","Keep LITELLM_PROXY_API_BASE set in every environment that routes images through another proxy"],"tags":["litellm-proxy","images","config"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}