{"record":{"id":"489d4ce3f6d7a31d","repo":"BerriAI/litellm","slug":"api-base-is-required-for-a2a-provider-either-prov","errorCode":null,"errorMessage":"api_base is required for A2A provider. Either provide api_base parameter, set A2A_API_BASE environment variable, or register the agent in the proxy with model='a2a/<agent-name>'.","messagePattern":"api_base is required for A2A provider\\. Either provide api_base parameter, set A2A_API_BASE environment variable, or register the agent in the proxy with model='a2a/<agent-name>'\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/main.py","lineNumber":2102,"sourceCode":"    timeout: Final = ctx.timeout\n\n    (\n        api_base,\n        api_key,\n        headers,\n    ) = litellm.A2AConfig.resolve_agent_config_from_registry(\n        model=model,\n        api_base=api_base,\n        api_key=api_key,\n        headers=headers,\n        optional_params=optional_params,\n    )\n\n    # Fall back to environment variables and defaults\n    api_base = api_base or litellm.api_base or get_secret_str(\"A2A_API_BASE\")\n\n    if api_base is None:\n        raise Exception(\n            \"api_base is required for A2A provider. \"\n            \"Either provide api_base parameter, set A2A_API_BASE environment variable, \"\n            \"or register the agent in the proxy with model='a2a/<agent-name>'.\"\n        )\n\n    headers = headers or litellm.headers\n\n    return base_llm_http_handler.completion(\n        model=model,\n        stream=stream,\n        messages=messages,\n        acompletion=acompletion,\n        api_base=api_base,\n        model_response=model_response,\n        optional_params=optional_params,\n        litellm_params=litellm_params,\n        shared_session=shared_session,\n        custom_llm_provider=custom_llm_provider,","sourceCodeStart":2084,"sourceCodeEnd":2120,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/main.py#L2084-L2120","documentation":"Exception raised on the A2A (agent-to-agent) provider path when no target agent URL could be determined: the registry lookup resolve_agent_config_from_registry returned nothing (agent not registered), and api_base, litellm.api_base, and A2A_API_BASE are all unset. A2A calls need the remote agent's endpoint to know where to send the message.","triggerScenarios":"completion(model='a2a/<name-or-url>', ...) where the agent is not in the proxy registry, no api_base kwarg is given, and A2A_API_BASE is not exported.","commonSituations":"Using the a2a/ route in plain SDK code (registry only exists in the proxy); agent registered in proxy config under a different name than the one in the model string; env var missing in the container running the caller.","solutions":["Pass api_base pointing directly at the remote agent's A2A endpoint URL","Or export A2A_API_BASE with that endpoint","Or register the agent in the LiteLLM proxy and call it as model='a2a/<registered-name>' so the registry resolves it","Check the model string name exactly matches the registry key if you intended registry resolution"],"exampleFix":"# before\nresp = litellm.completion(model='a2a/my-agent', messages=m)  # Exception\n\n# after\nimport os\nos.environ['A2A_API_BASE'] = 'https://agent.example.com/a2a/v1/agent'\nresp = litellm.completion(model='a2a/my-agent', messages=m)","handlingStrategy":"validation","validationCode":"import os\nif model.startswith('a2a/') and not (api_base or os.getenv('A2A_API_BASE') or agent_in_registry(model)):\n    raise SystemExit(f'No endpoint for {model!r}: pass api_base, set A2A_API_BASE, or register the agent')","typeGuard":"def a2a_target_resolved(model: str, api_base: str | None, registered: set[str]) -> bool:\n    return not model.startswith('a2a/') or bool(api_base or os.getenv('A2A_API_BASE') or model.split('/', 1)[-1] in registered)","tryCatchPattern":"try:\n    resp = litellm.completion(model='a2a/my-agent', messages=m)\nexcept Exception as e:\n    if 'api_base is required for A2A' in str(e):\n        raise RuntimeError('Register the agent in the proxy or set A2A_API_BASE') from e\n    raise","preventionTips":["Register A2A agents in the LiteLLM proxy config so callers never need raw URLs","Keep agent names in the model string identical to registry keys (exact match)","Set A2A_API_BASE in the runtime that actually issues the calls, not just your laptop","Health-check each registered agent endpoint periodically so dead URLs surface early"],"tags":["a2a","agents","api-base","env-var","litellm"],"backgroundTag":"missing-api-base","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}