litellm/litellm/a2a_protocol/litellm_completion_bridge
Mateo Wang 3f38730d2c
refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986)
* refactor(typing): clear basedpyright Any errors (wave 1)

* refactor(typing): clear basedpyright Any errors (wave 2)

* refactor(typing): clear basedpyright Any errors (wave 3)

* refactor(typing): clear basedpyright Any errors (wave 4)

* refactor(typing): clear basedpyright Any errors (wave 5)

* refactor(typing): clear basedpyright Any errors (wave 6)

* fix(typing): keep the cached-plan fallback's direct query_first calls so span naming resolves

* fix(logging): keep callbacks running when litellm_params is a params model

should_run_callback and the sync success and failure handlers read litellm_params through any object with a get method again, as they did before this branch, so a logging hook that returns a GenericLiteLLMParams no longer stops sync logging for that request

Adds behavior tests for the changed lines codecov listed as not run

* fix: read the regional uplift for every data residency again and reuse one dict TypeAdapter

The typed lookup only read the eu and us multipliers, so a deployment that set regional_processing_uplift_multiplier_fedramp stopped applying it. /model/update and the model write paths now share one module-level TypeAdapter instead of building one per call.

* fix: bill regional uplift multipliers float() accepts, bytes included

* fix: raise the in operator's own error from one shared json_contains, and name the bad uplift type
2026-11-06 13:31:15 -08:00
..
__init__.py refactor(lint): apply every safe ruff autofix and zero 28 strict-rule budgets 2026-08-01 15:43:29 -07:00
handler.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
README.md feat(a2a): support a2a-sdk 1.x proxy routing for 0.3 and 1.0 agents (#30950) 2026-06-29 09:32:39 +05:30
transformation.py refactor(types): replace Any with real types across 178 backend files 2026-08-27 10:14:58 +00:00

A2A to LiteLLM Completion Bridge

Routes A2A protocol requests through litellm.acompletion, enabling any LiteLLM-supported provider to be invoked via A2A.

Flow

A2A Request → Transform → litellm.acompletion → Transform → A2A Response

SDK Usage

Use the existing asend_message and asend_message_streaming functions with litellm_params:

from litellm.a2a_protocol import asend_message, asend_message_streaming
from a2a.types import SendMessageRequest, SendStreamingMessageRequest, MessageSendParams
from uuid import uuid4

# Non-streaming
request = SendMessageRequest(
    id=str(uuid4()),
    params=MessageSendParams(
        message={"role": "user", "parts": [{"kind": "text", "text": "Hello!"}], "messageId": uuid4().hex}
    )
)
response = await asend_message(
    request=request,
    api_base="http://localhost:2024",
    litellm_params={"custom_llm_provider": "langgraph", "model": "agent"},
)

# Streaming
stream_request = SendStreamingMessageRequest(
    id=str(uuid4()),
    params=MessageSendParams(
        message={"role": "user", "parts": [{"kind": "text", "text": "Hello!"}], "messageId": uuid4().hex}
    )
)
async for chunk in asend_message_streaming(
    request=stream_request,
    api_base="http://localhost:2024",
    litellm_params={"custom_llm_provider": "langgraph", "model": "agent"},
):
    print(chunk)

Proxy Usage

Configure an agent with custom_llm_provider in litellm_params:

agents:
  - agent_name: my-langgraph-agent
    agent_card_params:
      name: "LangGraph Agent"
      url: "http://localhost:2024"  # Used as api_base
    litellm_params:
      custom_llm_provider: langgraph
      model: agent

When an A2A request hits /a2a/{agent_id}/message/send, the bridge:

  1. Detects custom_llm_provider in agent's litellm_params
  2. Transforms A2A message → OpenAI messages
  3. Calls litellm.acompletion(model="langgraph/agent", api_base="http://localhost:2024")
  4. Transforms response → A2A format

The proxy then normalizes the client-facing response to the agent's pinned protocolVersion (0.3 or 1.0). No extra provider config is required for completion-bridge agents — pin protocolVersion only if your client expects a specific wire format.

Classes

  • A2ACompletionBridgeTransformation - Static methods for message format conversion
  • A2ACompletionBridgeHandler - Static methods for handling requests (streaming/non-streaming)