{"record":{"id":"8d84c5b835041944","repo":"BerriAI/litellm","slug":"missing-model-or-messages-8d84c5","errorCode":null,"errorMessage":"Missing model or messages","messagePattern":"Missing model or messages","errorType":"validation","errorClass":"OpenAIError","httpStatus":422,"severity":"error","filePath":"litellm/llms/openai/completion/handler.py","lineNumber":58,"sourceCode":"        custom_llm_provider: str,\n        logging_obj: LiteLLMLoggingObj,\n        optional_params: dict,\n        print_verbose: Callable | None = None,\n        api_base: str | None = None,\n        acompletion: bool = False,\n        litellm_params=None,\n        logger_fn=None,\n        client=None,\n        organization: str | None = None,\n        headers: dict | None = None,\n    ):\n        try:\n            if headers:\n                optional_params = {**optional_params, \"extra_headers\": headers}\n            if headers is None:\n                headers = self.validate_environment(api_key=api_key)\n            if model is None or messages is None:\n                raise OpenAIError(status_code=422, message=\"Missing model or messages\")\n\n            # don't send max retries to the api, if set\n\n            provider_config: Final = ProviderConfigManager.get_provider_text_completion_config(\n                model=model,\n                provider=LlmProviders(custom_llm_provider),\n            )\n\n            data: Final = provider_config.transform_text_completion_request(\n                model=model,\n                messages=messages,\n                optional_params=optional_params,\n                headers=headers,\n            )\n            max_retries: Final = data.pop(\"max_retries\", 2)\n            ## LOGGING\n            logging_obj.pre_call(\n                input=messages,","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/openai/completion/handler.py#L40-L76","documentation":"Guard inside the OpenAI text-completion path: the request is missing the 'model' or 'messages' argument, so the call cannot be formed or routed to a provider. It fires before any network I/O when the caller (or a router misconfiguration) omits these required parameters.","triggerScenarios":"Thrown at litellm/llms/openai/completion/handler.py:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass both model and messages arguments to the completion call."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}