BerriAI/litellm · error · ValueError
api_base is required
Error message
api_base is required
What it means
The base InteractionsAPIConfig get_complete_url raises ValueError when api_base is None. Interactions (OpenAI Responses-style agent/model interaction endpoints) require a concrete base URL; the default implementation just returns api_base, so a None value is rejected before the HTTP client would produce a nonsense request.
Source
Thrown at litellm/llms/base_llm/interactions/transformation.py:118
stream: bool | None = None,
) -> str:
"""
Get the complete URL for the interaction request.
Per OpenAPI spec: POST /{api_version}/interactions
Args:
api_base: Base URL for the API
model: The model name (for model interactions)
agent: The agent name (for agent interactions)
litellm_params: LiteLLM parameters
stream: Whether this is a streaming request
Returns:
The complete URL for the request
"""
if api_base is None:
raise ValueError("api_base is required")
return api_base
@abstractmethod
def transform_request(
self,
model: str | None,
agent: str | None,
input: InteractionInput | None,
optional_params: InteractionsAPIOptionalRequestParams,
litellm_params: GenericLiteLLMParams,
headers: dict,
) -> dict:
"""
Transform the input request into the provider's expected format.
Per OpenAPI spec, the request body should be either:
- CreateModelInteractionParams (with model)
- CreateAgentInteractionParams (with agent)View on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass api_base with the request (litellm_params={'api_base': ...}).
- Set the matching provider env var (e.g. OPENAI_API_BASE).
- Add api_base to the proxy model config used by interactions routes.
- Provider authors: override get_complete_url in the InteractionsAPIConfig subclass with a sane default.
Example fix
# before litellm.interactions(model='my-provider/agent-1', input='hi') # api_base None # after litellm.interactions(model='my-provider/agent-1', input='hi', api_base='https://host/v1')
Defensive patterns
Strategy: validation
Validate before calling
def validate_interactions_call(api_base: str | None) -> None:
if api_base is None and not os.environ.get('OPENAI_API_BASE'):
raise ConfigError('interactions API requires api_base') Try / catch
try:
litellm.interactions(...)
except ValueError as e:
if 'api_base is required' in str(e):
raise ConfigError('set api_base or OPENAI_API_BASE for interactions') from e
raise Prevention
- Centralize provider base URLs in a typed settings object loaded at startup.
- Validate required params per API surface (interactions, responses, evals) before dispatch.
- Log resolved api_base (not secrets) once at client init to catch env issues early.
When it happens
Trigger: Calling the interactions API (litellm.interactions / proxy /v1/interactions routes) for a provider whose params contain no api_base: missing <PROVIDER>_API_BASE env, custom provider registered without a default base URL, or proxy model entry lacking api_base.
Common situations: Self-hosted OpenAI-compatible servers used for interactions without base URL configuration; new provider configs that only set transform_request; environment differences between local (env set) and CI/deploy (env missing).
Related errors
- api_base is required for Azure AI Studio. Please set the api
- api_base is required
- api_base is required
- api_base is required
- API base is required for OpenAI image variations
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/fd31b5b362781ac8.
Report an issue: GitHub.