BerriAI/litellm · error · ValueError
Either 'model' or 'agent' must be provided
Error message
Either 'model' or 'agent' must be provided
What it means
Error "Either 'model' or 'agent' must be provided" thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/gemini/interactions/transformation.py:154
- ``response_mime_type`` is folded into ``response_format`` and stripped from
the body (the field was removed in Api-Revision 2026-05-20).
- ``generation_config.image_config`` is moved to a ``response_format`` entry
with ``"type": "image"`` (also removed from generation_config in 2026-05-20).
When on the legacy schema (use_legacy_interactions_schema=True):
- All fields are forwarded as-is.
"""
use_legacy: Final[bool] = litellm.use_legacy_interactions_schema
request_body: Final[dict[str, Any]] = {}
# Model or Agent (one required)
if model:
request_body["model"] = GeminiModelInfo.get_base_model(model) or model
elif agent:
request_body["agent"] = agent
else:
raise ValueError("Either 'model' or 'agent' must be provided")
# Input
if input is not None:
request_body["input"] = input
# Pass through optional params — legacy schema keeps all fields as-is.
optional_keys: Final = [
"tools",
"system_instruction",
"stream",
"store",
"background",
"environment",
"response_modalities",
"previous_interaction_id",
]
for key in optional_keys:
if optional_params.get(key) is not None:View on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass either model or agent in the interactions request.
When it happens
Trigger: Thrown at litellm/llms/gemini/interactions/transformation.py:154 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/07a3759fb385f20a.
Report an issue: GitHub.