BerriAI/litellm · error · ValueError
api_base is required for PydanticAIProviderConfig
Error message
api_base is required for PydanticAIProviderConfig
What it means
PydanticAIProviderConfig.handle_non_streaming raises ValueError when api_base is None. Pydantic AI agents are reached over plain HTTP; there is no model-to-endpoint derivation, so the agent URL must be supplied.
Source
Thrown at litellm/a2a_protocol/providers/pydantic_ai_agents/config.py:29
class PydanticAIProviderConfig(BaseA2AProviderConfig):
"""
Provider configuration for Pydantic AI agents.
Pydantic AI agents follow A2A protocol but don't support streaming natively.
This config provides fake streaming by converting non-streaming responses into streaming chunks.
"""
async def handle_non_streaming(
self,
request_id: str,
params: dict[str, Any],
api_base: str | None = None,
**kwargs: Any,
) -> dict[str, Any]:
"""Handle non-streaming request to Pydantic AI agent."""
if api_base is None:
raise ValueError("api_base is required for PydanticAIProviderConfig")
return await PydanticAIHandler.handle_non_streaming(
request_id=request_id,
params=params,
api_base=api_base,
timeout=kwargs.get("timeout", 60.0),
agent_extra_headers=kwargs.get("agent_extra_headers"),
)
async def handle_streaming(
self,
request_id: str,
params: dict[str, Any],
api_base: str | None = None,
**kwargs,
) -> AsyncIterator[dict[str, Any]]:
"""Handle streaming request with fake streaming."""
if not api_base:
raise ValueError("api_base is required for Pydantic AI agents")View on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass api_base (the Pydantic AI agent server URL) to the handler
- In LiteLLM proxy config, set api_base on the pydantic-ai agent deployment
Example fix
# before resp = await config.handle_non_streaming(request_id=rid, params=params) # after resp = await config.handle_non_streaming(request_id=rid, params=params, api_base="http://localhost:8000")
Defensive patterns
Strategy: validation
Validate before calling
from urllib.parse import urlparse
if not api_base or not urlparse(api_base).scheme:
raise ValueError("pydantic-ai agent requires a valid api_base URL") Prevention
- Set api_base on every pydantic-ai deployment
- Resolve api_base from config at startup and fail fast if missing
When it happens
Trigger: Calling the pydantic_ai_agents config handler for a non-streaming request with api_base=None in kwargs.
Common situations: Model added in the proxy without `api_base`; assuming the handler reads the base URL from litellm_params like AgentCore does.
Related errors
- api_base is required for Pydantic AI agents
- api_base is required for Pydantic AI agents
- request is required
- Either a2a_client or api_base is required for standard A2A f
- litellm_params is required for BedrockAgentCoreA2AConfig (mu
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/25232ca07514169e.
Report an issue: GitHub.