{"record":{"id":"db6551fabf390d32","repo":"BerriAI/litellm","slug":"could-not-reach-the-litellm-proxy-at-base-url-rst","errorCode":null,"errorMessage":"Could not reach the LiteLLM proxy at {base_url.rstrip('/')}: {e}. Is it running, and is --base-url (or LITELLM_PROXY_URL) correct?","messagePattern":"Could not reach the LiteLLM proxy at (.+?): (.+?)\\. Is it running, and is --base-url \\(or LITELLM_PROXY_URL\\) correct\\?","errorType":"exception","errorClass":"AgentRunError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/client/cli/commands/agents.py","lineNumber":135,"sourceCode":"    return builder(base_url) if builder else []\n\n\ndef verify_proxy_key(\n    base_url: str,\n    api_key: str,\n    *,\n    get: Callable[..., requests.Response] = requests.get,\n) -> None:\n    \"\"\"Probe the proxy with the key so bad creds fail here, not inside the agent.\n\n    Raises AgentRunError when the proxy is unreachable or rejects the key. Other\n    non-2xx responses are tolerated; the agent's own call is the real test.\n    \"\"\"\n    url: Final = base_url.rstrip(\"/\") + \"/v1/models\"\n    try:\n        resp: Final = get(url, headers={\"Authorization\": f\"Bearer {api_key}\"}, timeout=10)\n    except requests.RequestException as e:\n        raise AgentRunError(\n            f\"Could not reach the LiteLLM proxy at {base_url.rstrip('/')}: {e}. \"\n            \"Is it running, and is --base-url (or LITELLM_PROXY_URL) correct?\"\n        )\n    if resp.status_code in (401, 403):\n        raise AgentRunError(\n            f\"LiteLLM rejected your key (HTTP {resp.status_code}). \"\n            \"Run `lite login` to refresh it, or pass a valid --api-key.\"\n        )\n\n\n_WINDOWS_SHIM_SUFFIXES: Final[frozenset[str]] = frozenset({\".cmd\", \".bat\"})\n_CMD_PERCENT_GUARD: Final = \"%%cd:~,%\"\n_CMD_LINE_BREAKS: Final = (\"\\r\", \"\\n\")\n\n\ndef _double_trailing_backslashes(segment: str) -> str:\n    bare: Final = segment.rstrip(\"\\\\\")\n    return bare + \"\\\\\" * 2 * (len(segment) - len(bare))","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/client/cli/commands/agents.py#L117-L153","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/client/cli/commands/agents.py:135 when the library encounters an invalid state.","commonSituations":"The CLI could not connect to the proxy (not running or wrong URL).","solutions":["Start the LiteLLM proxy before running the CLI command.","Verify --base-url or LITELLM_PROXY_URL points to the running proxy."],"exampleFix":"export LITELLM_PROXY_URL=http://localhost:4000","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}