BerriAI/litellm · error · ValueError
Either a2a_client or api_base is required for standard A2A…
Error message
Either a2a_client or api_base is required for standard A2A flow
What it means
The standard A2A flow of asend_message needs either an existing a2a_client or an api_base from which LiteLLM fetches the agent card and builds a client (attaching trace headers). With both None it cannot proceed and raises this ValueError as an argument-combination guard before doing anything else.
Solutions
- Pass api_base='http://host:port' of the A2A agent
- Or pass a client built via litellm.a2a_protocol.create_a2a_client(base_url=...)
- Log/validate that the configured agent URL is non-empty at startup rather than at call time
Example fix
# before await asend_message(request=req) # no client, no base # after await asend_message(request=req, api_base='http://agent-svc:10001')
Defensive patterns
Strategy: validation
Validate before calling
if a2a_client is None and not api_base:
raise ValueError(
f'asend_message needs a2a_client or api_base; got api_base={api_base!r}'
)
resp = await asend_message(request=request, api_base=api_base, a2a_client=a2a_client) Try / catch
try:
resp = await asend_message(request=request, api_base=api_base)
except ValueError as e:
if 'a2a_client or api_base' in str(e):
raise ValueError(f'Agent URL missing in config: {agent_config!r}') from e
raise Prevention
- Validate agent config (non-empty URL) at process startup
- Fail config load when an A2A route has neither client nor base URL
- Use typed config models so a missing URL cannot reach the call site
When it happens
Trigger: Calling asend_message(request=req) with neither a2a_client nor api_base; api_base coming from config/env and resolving to None; passing an empty string is likewise unusable.
Common situations: Missing agent URL in proxy/deployment config; env var name typo yielding None; tests calling the function with only a request.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- request is required
- request is required for completion bridge
- api_base is required for Pydantic AI agents
- api_base is required for Pydantic AI agents
- api_base is required for PydanticAIProviderConfig
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/849f8bea093d77ef.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/a2a_protocol/main.py:464
if custom_llm_provider:
if request is None:
raise ValueError("request is required for completion bridge")
return await _send_message_via_completion_bridge(
request=request,
custom_llm_provider=custom_llm_provider,
api_base=api_base,
litellm_params=litellm_params,
agent_extra_headers=agent_extra_headers,
)
# Standard A2A client flow
if request is None:
raise ValueError("request is required")
# Create A2A client if not provided but api_base is available
if a2a_client is None:
if api_base is None:
raise ValueError("Either a2a_client or api_base is required for standard A2A flow")
trace_id = trace_id or str(uuid.uuid4())
extra_headers: Final[dict[str, str]] = {"X-LiteLLM-Trace-Id": trace_id}
if agent_id:
extra_headers["X-LiteLLM-Agent-Id"] = agent_id
# Overlay agent-level headers (agent headers take precedence over LiteLLM internal ones)
if agent_extra_headers:
extra_headers.update(agent_extra_headers)
a2a_client = await create_a2a_client(base_url=api_base, extra_headers=extra_headers)
# Type assertion: a2a_client is guaranteed to be non-None here
assert a2a_client is not None
agent_name: Final = _get_a2a_model_info(a2a_client, kwargs)
verbose_logger.info("A2A send_message request_id=%s, agent=%s", request.id, agent_name)
# Get agent card URL for localhost retry logic
agent_card: Final = _get_a2a_client_agent_card(a2a_client)View on GitHub (pinned to 77b7c6c40c)