{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/completion_extras/litellm_responses_transformation/handler.py#L116-L152","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nfrom litellm.types.utils import ModelResponse\nhandler.completion(..., model_response={}, ...)  # ValueError: model_response is required\n\n// after\nhandler.completion(..., model_response=ModelResponse(), ...)","handlingStrategy":"validation","validationCode":"from litellm.types.utils import ModelResponse\n\ndef has_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(obj) -> bool:\n    return isinstance(obj, ModelResponse)","tryCatchPattern":"try:\n    handler.completion(**kwargs)\nexcept ValueError as e:\n    if \"model_response is required\" in str(e):\n        from litellm.types.utils import ModelResponse\n        return handler.completion(**{**kwargs, \"model_response\": ModelResponse()})\n    raise","preventionTips":["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"],"tags":["validation","kwargs","model-response","internal-api"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}