{"record":{"id":"94b47104eb3dcd64","repo":"BerriAI/litellm","slug":"messages-is-required","errorCode":null,"errorMessage":"messages is required","messagePattern":"messages is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/handler.py","lineNumber":118,"sourceCode":"        return response\n\n    def validate_input_kwargs(self, kwargs: dict) -> ResponsesToCompletionBridgeHandlerInputKwargs:\n        from litellm import LiteLLMLoggingObj\n        from litellm.types.utils import ModelResponse\n\n        typed_kwargs: Final[dict[str, object]] = kwargs\n\n        model: Final = typed_kwargs.get(\"model\")\n        if model is None or not isinstance(model, str):\n            raise ValueError(\"model is required\")\n\n        custom_llm_provider: Final = typed_kwargs.get(\"custom_llm_provider\")\n        if custom_llm_provider is None or not isinstance(custom_llm_provider, str):\n            raise ValueError(\"custom_llm_provider is required\")\n\n        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\")","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/completion_extras/litellm_responses_transformation/handler.py#L100-L136","documentation":"validate_input_kwargs raises when 'messages' is missing from kwargs or is not a list. The bridge converts chat messages into Responses API input items, so a valid list of message dicts is mandatory. This is an internal-API contract check; normal litellm.completion calls always supply messages.","triggerScenarios":"Calling the bridge handler with kwargs where messages is None, a string, a single dict, or absent.","commonSituations":"Direct handler use in custom pipelines; passing a bare prompt string where a messages list is expected; tests with incomplete fixture data.","solutions":["Pass messages as a list of role/content dicts: [{\"role\": \"user\", \"content\": \"...\"}]","Prefer litellm.completion(model=..., messages=[...]) which validates and forwards everything","Check upstream code that builds kwargs for a mutation that drops or replaces the messages key"],"exampleFix":"# before\nkwargs = {\"model\": \"gpt-4o\", \"messages\": \"hello\"}\n\n# after\nkwargs = {\"model\": \"gpt-4o\", \"messages\": [{\"role\": \"user\", \"content\": \"hello\"}]}","handlingStrategy":"validation","validationCode":"def has_messages_kwarg(kwargs: dict) -> bool:\n    return isinstance(kwargs.get(\"messages\"), list) and len(kwargs[\"messages\"]) > 0","typeGuard":"def is_message_list(v) -> bool:\n    return isinstance(v, list) and all(\n        isinstance(m, dict) and isinstance(m.get(\"role\"), str) for m in v\n    )","tryCatchPattern":null,"preventionTips":["Always pass messages as a list of {role, content} dicts","Validate message shape at your API boundary before calling litellm"],"tags":["validation","bridge","messages","internal-api"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}