BerriAI/litellm · error · AgentRunError
Could not reach the LiteLLM proxy at {base_url.rstrip('/')}:
Error message
Could not reach the LiteLLM proxy at {base_url.rstrip('/')}: {e}. Is it running, and is --base-url (or LITELLM_PROXY_URL) correct? What it means
CLI pre-flight verify_proxy_key wraps a requests.RequestException from probing /v1/models into AgentRunError, telling the user the proxy is unreachable or --base-url/LITELLM_PROXY_URL is wrong before launching the agent.
Source
Thrown at litellm/proxy/client/cli/commands/agents.py:135
return builder(base_url) if builder else []
def verify_proxy_key(
base_url: str,
api_key: str,
*,
get: Callable[..., requests.Response] = requests.get,
) -> None:
"""Probe the proxy with the key so bad creds fail here, not inside the agent.
Raises AgentRunError when the proxy is unreachable or rejects the key. Other
non-2xx responses are tolerated; the agent's own call is the real test.
"""
url: Final = base_url.rstrip("/") + "/v1/models"
try:
resp: Final = get(url, headers={"Authorization": f"Bearer {api_key}"}, timeout=10)
except requests.RequestException as e:
raise AgentRunError(
f"Could not reach the LiteLLM proxy at {base_url.rstrip('/')}: {e}. "
"Is it running, and is --base-url (or LITELLM_PROXY_URL) correct?"
)
if resp.status_code in (401, 403):
raise AgentRunError(
f"LiteLLM rejected your key (HTTP {resp.status_code}). "
"Run `lite login` to refresh it, or pass a valid --api-key."
)
_WINDOWS_SHIM_SUFFIXES: Final[frozenset[str]] = frozenset({".cmd", ".bat"})
_CMD_PERCENT_GUARD: Final = "%%cd:~,%"
_CMD_LINE_BREAKS: Final = ("\r", "\n")
def _double_trailing_backslashes(segment: str) -> str:
bare: Final = segment.rstrip("\\")
return bare + "\\" * 2 * (len(segment) - len(bare))View on GitHub (pinned to 77b7c6c40c)
Solutions
- Start the LiteLLM proxy before running the CLI command.
- Verify --base-url or LITELLM_PROXY_URL points to the running proxy.
Example fix
export LITELLM_PROXY_URL=http://localhost:4000
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at litellm/proxy/client/cli/commands/agents.py:135 when the library encounters an invalid state.
Common situations: The CLI could not connect to the proxy (not running or wrong URL).
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/db6551fabf390d32.
Report an issue: GitHub.