BerriAI/litellm · error · ValueError
model_response is required
Error message
model_response is required
What it means
validate_input_kwargs raises when 'model_response' is missing or is not a litellm ModelResponse instance. The bridge fills this pre-allocated ModelResponse in place with choices/usage from the Responses API output. Normal completion calls create it in the main pipeline; only manual handler invocations can omit or mistype it.
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 6c2dcb801b)
Solutions
- Use litellm.completion — the ModelResponse is created and threaded internally
- If direct, build it: from litellm.types.utils import ModelResponse; kwargs['model_response'] = ModelResponse()
- In tests, ensure mocks use ModelResponse instances or patch at the transport layer instead
Example fix
# before
kwargs = {..., "model_response": {"choices": []}}
# after
from litellm.types.utils import ModelResponse
kwargs = {..., "model_response": ModelResponse()} Defensive patterns
Strategy: type-guard
Validate before calling
from litellm.types.utils import ModelResponse
def has_valid_model_response(kwargs: dict) -> bool:
return isinstance(kwargs.get("model_response"), ModelResponse) Type guard
from litellm.types.utils import ModelResponse
def is_model_response(v) -> bool:
return isinstance(v, ModelResponse) Prevention
- Construct model_response with ModelResponse(), never a dict
- Avoid mocking the response object in integration paths
When it happens
Trigger: Passing model_response=None, a dict, or omitting the key when calling the bridge handler directly.
Common situations: Custom code that constructs a plain dict instead of litellm.types.utils.ModelResponse; tests with mock objects that fail the isinstance check.
Related errors
- model is required
- custom_llm_provider is required
- messages is required
- optional_params is required
- litellm_params is required
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/6c18c70d78c3dcf1.
Report an issue: GitHub.