BerriAI/litellm · error · ValueError
model_response is required
Error message
model_response is required
What it means
The bridge requires 'model_response' to be an instance of litellm.types.utils.ModelResponse — the pre-allocated response object that transform_response fills in-place (choices, usage, hidden params). Passing None, a dict, or a differently-typed object fails validation. Only direct/internal callers ever supply this kwarg.
Solutions
- Construct and pass a fresh ModelResponse() for each call
- Prefer litellm.completion, which allocates model_response for you
- Assert isinstance(model_response, ModelResponse) in custom pipelines before forwarding
- After upgrades, re-check the bridge TypedDict for new type requirements
Example fix
// before
from litellm.types.utils import ModelResponse
handler.completion(..., model_response={}, ...) # ValueError: model_response is required
// after
handler.completion(..., model_response=ModelResponse(), ...) Defensive patterns
Strategy: validation
Validate before calling
from litellm.types.utils import ModelResponse
def has_model_response(kwargs: dict) -> bool:
return isinstance(kwargs.get("model_response"), ModelResponse) Type guard
from litellm.types.utils import ModelResponse
def is_model_response(obj) -> bool:
return isinstance(obj, ModelResponse) Try / catch
try:
handler.completion(**kwargs)
except ValueError as e:
if "model_response is required" in str(e):
from litellm.types.utils import ModelResponse
return handler.completion(**{**kwargs, "model_response": ModelResponse()})
raise Prevention
- Allocate a fresh ModelResponse() per call in custom pipelines
- Never substitute dicts or Mocks for ModelResponse in production
- Assert isinstance on internally forwarded objects at adapter boundaries
When it happens
Trigger: Calling the bridge handler without constructing ModelResponse(); passing a dict or Mock instead of a real ModelResponse; custom pipelines that reuse a response object of the wrong type after an API change.
Common situations: Test doubles standing in for ModelResponse; code written against an older litellm where the field was typed differently; copy-pasted integration code missing the constructor call.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- custom_llm_provider is required
- custom_llm_provider is required
- headers is required
- headers is required
- input is required
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/6c18c70d78c3dcf1.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/completion_extras/litellm_responses_transformation/handler.py:134
messages: Final = typed_kwargs.get("messages")
if messages is None or not isinstance(messages, list):
raise ValueError("messages is required")
optional_params: Final = typed_kwargs.get("optional_params")
if optional_params is None or not isinstance(optional_params, dict):
raise ValueError("optional_params is required")
litellm_params: Final = typed_kwargs.get("litellm_params")
if litellm_params is None or not isinstance(litellm_params, dict):
raise ValueError("litellm_params is required")
headers: Final = typed_kwargs.get("headers")
if headers is None or not isinstance(headers, dict):
raise ValueError("headers is required")
model_response: Final = typed_kwargs.get("model_response")
if model_response is None or not isinstance(model_response, ModelResponse):
raise ValueError("model_response is required")
logging_obj: Final = typed_kwargs.get("logging_obj")
if logging_obj is None or not isinstance(logging_obj, LiteLLMLoggingObj):
raise ValueError("logging_obj is required")
return ResponsesToCompletionBridgeHandlerInputKwargs(
model=model,
messages=messages,
optional_params=optional_params,
litellm_params=litellm_params,
headers=headers,
model_response=model_response,
logging_obj=logging_obj,
custom_llm_provider=custom_llm_provider,
encoding=typed_kwargs.get("encoding"),
)
def completion(View on GitHub (pinned to 77b7c6c40c)