BerriAI/litellm · error · ValueError
api_base not set for LiteLLM Proxy route. Set in env via `LI
Error message
api_base not set for LiteLLM Proxy route. Set in env via `LITELLM_PROXY_API_BASE`
What it means
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.
Source
Thrown at litellm/llms/litellm_proxy/image_edit/transformation.py:23
class LiteLLMProxyImageEditConfig(OpenAIImageEditConfig):
"""Configuration for image edit requests routed through LiteLLM Proxy."""
def validate_environment(
self,
headers: dict,
model: str,
api_key: str | None = None,
litellm_params: dict | None = None,
api_base: str | None = None,
) -> dict:
api_key = api_key or get_secret_str("LITELLM_PROXY_API_KEY")
headers.update({"Authorization": f"Bearer {api_key}"})
return headers
def get_complete_url(self, model: str, api_base: str | None, litellm_params: dict) -> str:
api_base = api_base or get_secret_str("LITELLM_PROXY_API_BASE")
if api_base is None:
raise ValueError("api_base not set for LiteLLM Proxy route. Set in env via `LITELLM_PROXY_API_BASE`")
api_base = api_base.rstrip("/")
return f"{api_base}/images/edits"
View on GitHub (pinned to 6c2dcb801b)
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
Example fix
# before
resp = litellm.image_edit(model="litellm_proxy/gpt-image-1", image=..., prompt=...)
# after
resp = litellm.image_edit(
model="litellm_proxy/gpt-image-1",
image=..., prompt=...,
api_base="http://downstream-proxy:4000",
api_key="sk-upstream",
) Defensive patterns
Strategy: validation
Validate before calling
import os
def ensure_proxy_base_for_images(api_base: str | None = None) -> str:
base = (api_base or os.getenv("LITELLM_PROXY_API_BASE", "")).rstrip("/")
if not base:
raise ValueError("Downstream proxy base URL required for image edits")
return base Try / catch
try:
resp = litellm.image_edit(model="litellm_proxy/gpt-image-1", image=img, prompt=p, api_base=ensure_proxy_base_for_images())
except ValueError as e:
if "api_base not set for LiteLLM Proxy" in str(e):
# config error — provision the env var; no retry will help
raise Prevention
- 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
When it happens
Trigger: Calling image editing (model="litellm_proxy/<name>") without api_base on the call and without LITELLM_PROXY_API_BASE in the environment.
Common situations: 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.
Related errors
- api_base not set for LiteLLM Proxy route. Set in env via `LI
- GCS Bucket logging is a premium feature. Please upgrade to u
- api_base not set for LiteLLM Proxy route. Set in env via `LI
- api_base not set for LiteLLM Proxy responses API. Set via ap
- File not found. blocked_user_list={blocked_user_list}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/e824155bfdebf7d3.
Report an issue: GitHub.