{"record":{"id":"849f8bea093d77ef","repo":"BerriAI/litellm","slug":"either-a2a-client-or-api-base-is-required-for-stan","errorCode":null,"errorMessage":"Either a2a_client or api_base is required for standard A2A flow","messagePattern":"Either a2a_client or api_base is required for standard A2A flow","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/a2a_protocol/main.py","lineNumber":464,"sourceCode":"    if custom_llm_provider:\n        if request is None:\n            raise ValueError(\"request is required for completion bridge\")\n        return await _send_message_via_completion_bridge(\n            request=request,\n            custom_llm_provider=custom_llm_provider,\n            api_base=api_base,\n            litellm_params=litellm_params,\n            agent_extra_headers=agent_extra_headers,\n        )\n\n    # Standard A2A client flow\n    if request is None:\n        raise ValueError(\"request is required\")\n\n    # Create A2A client if not provided but api_base is available\n    if a2a_client is None:\n        if api_base is None:\n            raise ValueError(\"Either a2a_client or api_base is required for standard A2A flow\")\n        trace_id = trace_id or str(uuid.uuid4())\n        extra_headers: Final[dict[str, str]] = {\"X-LiteLLM-Trace-Id\": trace_id}\n        if agent_id:\n            extra_headers[\"X-LiteLLM-Agent-Id\"] = agent_id\n        # Overlay agent-level headers (agent headers take precedence over LiteLLM internal ones)\n        if agent_extra_headers:\n            extra_headers.update(agent_extra_headers)\n        a2a_client = await create_a2a_client(base_url=api_base, extra_headers=extra_headers)\n\n    # Type assertion: a2a_client is guaranteed to be non-None here\n    assert a2a_client is not None\n\n    agent_name: Final = _get_a2a_model_info(a2a_client, kwargs)\n\n    verbose_logger.info(\"A2A send_message request_id=%s, agent=%s\", request.id, agent_name)\n\n    # Get agent card URL for localhost retry logic\n    agent_card: Final = _get_a2a_client_agent_card(a2a_client)","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/a2a_protocol/main.py#L446-L482","documentation":"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.","triggerScenarios":"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.","commonSituations":"Missing agent URL in proxy/deployment config; env var name typo yielding None; tests calling the function with only a request.","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"],"exampleFix":"# before\nawait asend_message(request=req)  # no client, no base\n\n# after\nawait asend_message(request=req, api_base='http://agent-svc:10001')","handlingStrategy":"validation","validationCode":"if a2a_client is None and not api_base:\n    raise ValueError(\n        f'asend_message needs a2a_client or api_base; got api_base={api_base!r}'\n    )\nresp = await asend_message(request=request, api_base=api_base, a2a_client=a2a_client)","typeGuard":null,"tryCatchPattern":"try:\n    resp = await asend_message(request=request, api_base=api_base)\nexcept ValueError as e:\n    if 'a2a_client or api_base' in str(e):\n        raise ValueError(f'Agent URL missing in config: {agent_config!r}') from e\n    raise","preventionTips":["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"],"tags":["a2a","validation","parameter","configuration"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}