{"record":{"id":"552bafe9c2b99655","repo":"BerriAI/litellm","slug":"optional-params-is-required","errorCode":null,"errorMessage":"optional_params is required","messagePattern":"optional_params is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/handler.py","lineNumber":122,"sourceCode":"        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\")\n        if logging_obj is None or not isinstance(logging_obj, LiteLLMLoggingObj):\n            raise ValueError(\"logging_obj is required\")\n\n        return ResponsesToCompletionBridgeHandlerInputKwargs(","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/completion_extras/litellm_responses_transformation/handler.py#L104-L140","documentation":"validate_input_kwargs raises when 'optional_params' is absent or not a dict. optional_params carries the cleaned inference parameters (temperature, stream, tools, ...) that the bridge maps onto the Responses API request. Missing it means the internal completion pipeline contract was broken — it is always populated by get_optional_params in normal litellm.completion flows.","triggerScenarios":"Direct bridge handler invocation with a kwargs dict that omits optional_params or sets it to None; a fork that renames the key.","commonSituations":"Custom integrations building kwargs by hand; version drift after upgrading litellm where optional_params construction moved earlier/later in the pipeline.","solutions":["Route through litellm.completion so optional_params is built by get_optional_params","If direct, pass at minimum an empty dict: optional_params={}","Regenerate any hand-copied kwargs template against the current ResponsesToCompletionBridgeHandlerInputKwargs definition"],"exampleFix":"# before\nkwargs = {\"model\": m, \"messages\": msgs}  # optional_params missing\n\n# after\nkwargs = {\"model\": m, \"messages\": msgs, \"optional_params\": {}}","handlingStrategy":"validation","validationCode":"def has_optional_params(kwargs: dict) -> bool:\n    return isinstance(kwargs.get(\"optional_params\"), dict)","typeGuard":"def is_dict_param(v) -> bool:\n    return isinstance(v, dict)","tryCatchPattern":null,"preventionTips":["Default optional_params to {} when building kwargs manually","Route calls through litellm.completion so params are assembled for you"],"tags":["validation","bridge","optional-params","internal-api"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}