{"record":{"id":"3fed4d5d7cc26a60","repo":"BerriAI/litellm","slug":"missing-model-or-messages","errorCode":null,"errorMessage":"Missing model or messages","messagePattern":"Missing model or messages","errorType":"exception","errorClass":"AzureOpenAIError","httpStatus":422,"severity":"error","filePath":"litellm/llms/azure/azure.py","lineNumber":220,"sourceCode":"        api_type: str,\n        azure_ad_token: str | None,\n        azure_ad_token_provider: Callable | None,\n        dynamic_params: bool,\n        print_verbose: Callable,\n        timeout: float | httpx.Timeout,\n        logging_obj: LiteLLMLoggingObj,\n        optional_params,\n        litellm_params,\n        logger_fn,\n        acompletion: bool = False,\n        headers: dict | None = None,\n        client=None,\n    ):\n        if headers:\n            optional_params[\"extra_headers\"] = headers\n        try:\n            if model is None or messages is None:\n                raise AzureOpenAIError(status_code=422, message=\"Missing model or messages\")\n\n            max_retries = optional_params.pop(\"max_retries\", None)\n            if max_retries is None:\n                max_retries = DEFAULT_MAX_RETRIES\n            json_mode: Final[bool | None] = optional_params.pop(\"json_mode\", False)\n\n            ### CHECK IF CLOUDFLARE AI GATEWAY ###\n            ### if so - set the model as part of the base url\n            if api_base is not None and \"gateway.ai.cloudflare.com\" in api_base:\n                client = self._init_azure_client_for_cloudflare_ai_gateway(\n                    api_base=api_base,\n                    model=model,\n                    api_version=api_version,\n                    max_retries=max_retries,\n                    timeout=timeout,\n                    api_key=api_key,\n                    azure_ad_token=azure_ad_token,\n                    azure_ad_token_provider=azure_ad_token_provider,","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure/azure.py#L202-L238","documentation":"This 422 from the Azure OpenAI chat completion path fires when `model` or `messages` is None at call time. It is a defensive check at the top of the completion handler before any client is constructed. In normal usage LiteLLM's router fills these from your request, so hitting it usually means a programmatic caller passed None explicitly.","triggerScenarios":"Calling the internal AzureOpenAI completion function directly with model=None or messages=None; a custom provider wrapper or mocked router that forwards unset values; dynamic model resolution code that returns None and is passed through unchecked.","commonSituations":"Building the model string from config/env and the lookup silently failing to None; refactors that renamed parameters and left a stale kwarg; test fixtures that omit messages.","solutions":["Check the call site: log the exact model and messages values right before the LiteLLM call.","Default or fail fast on missing values in your own resolution logic instead of passing None.","If you call litellm.completion, ensure the first positional model argument is a non-empty string and messages is a non-empty list."],"exampleFix":"# before\nmodel = config.get('model')  # may be None\nresp = litellm.completion(model=model, messages=msg_list, custom_llm_provider='azure')\n\n# after\nmodel = config.get('model')\nif not model:\n    raise ValueError('config[\"model\"] is missing')\nresp = litellm.completion(model=model, messages=msg_list, custom_llm_provider='azure')","handlingStrategy":"validation","validationCode":"assert isinstance(model, str) and model, 'model must be a non-empty string'\nassert isinstance(messages, list) and messages, 'messages must be a non-empty list'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast on None in your model-resolution helpers instead of forwarding None to LiteLLM.","Type-annotate call sites so mypy catches None before runtime."],"tags":["azure","openai","validation","invalid-arguments"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}