{"record":{"id":"6c18c70d78c3dcf1","repo":"BerriAI/litellm","slug":"model-response-is-required","errorCode":null,"errorMessage":"model_response is required","messagePattern":"model_response is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/handler.py","lineNumber":134,"sourceCode":"        messages: Final = typed_kwargs.get(\"messages\")\n        if messages is None or not isinstance(messages, list):\n            raise ValueError(\"messages is required\")\n\n        optional_params: Final = typed_kwargs.get(\"optional_params\")\n        if optional_params is None or not isinstance(optional_params, dict):\n            raise ValueError(\"optional_params is required\")\n\n        litellm_params: Final = typed_kwargs.get(\"litellm_params\")\n        if litellm_params is None or not isinstance(litellm_params, dict):\n            raise ValueError(\"litellm_params is required\")\n\n        headers: Final = typed_kwargs.get(\"headers\")\n        if headers is None or not isinstance(headers, dict):\n            raise ValueError(\"headers is required\")\n\n        model_response: Final = typed_kwargs.get(\"model_response\")\n        if model_response is None or not isinstance(model_response, ModelResponse):\n            raise ValueError(\"model_response is required\")\n\n        logging_obj: Final = typed_kwargs.get(\"logging_obj\")\n        if logging_obj is None or not isinstance(logging_obj, LiteLLMLoggingObj):\n            raise ValueError(\"logging_obj is required\")\n\n        return ResponsesToCompletionBridgeHandlerInputKwargs(\n            model=model,\n            messages=messages,\n            optional_params=optional_params,\n            litellm_params=litellm_params,\n            headers=headers,\n            model_response=model_response,\n            logging_obj=logging_obj,\n            custom_llm_provider=custom_llm_provider,\n            encoding=typed_kwargs.get(\"encoding\"),\n        )\n\n    def completion(","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/completion_extras/litellm_responses_transformation/handler.py#L116-L152","documentation":"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.","triggerScenarios":"Passing model_response=None, a dict, or omitting the key when calling the bridge handler directly.","commonSituations":"Custom code that constructs a plain dict instead of litellm.types.utils.ModelResponse; tests with mock objects that fail the isinstance check.","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"],"exampleFix":"# before\nkwargs = {..., \"model_response\": {\"choices\": []}}\n\n# after\nfrom litellm.types.utils import ModelResponse\nkwargs = {..., \"model_response\": ModelResponse()}","handlingStrategy":"type-guard","validationCode":"from litellm.types.utils import ModelResponse\n\ndef has_valid_model_response(kwargs: dict) -> bool:\n    return isinstance(kwargs.get(\"model_response\"), ModelResponse)","typeGuard":"from litellm.types.utils import ModelResponse\n\ndef is_model_response(v) -> bool:\n    return isinstance(v, ModelResponse)","tryCatchPattern":null,"preventionTips":["Construct model_response with ModelResponse(), never a dict","Avoid mocking the response object in integration paths"],"tags":["validation","bridge","model-response","internal-api"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}