mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-30 01:08:33 +00:00
* 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 |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| handler.py | ||
| README.md | ||
| transformation.py | ||
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:
- Detects
custom_llm_providerin agent'slitellm_params - Transforms A2A message → OpenAI messages
- Calls
litellm.acompletion(model="langgraph/agent", api_base="http://localhost:2024") - 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 conversionA2ACompletionBridgeHandler- Static methods for handling requests (streaming/non-streaming)