BerriAI/litellm · error · OpenAIError

Missing model or messages

Error message

Missing model or messages

What it means

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.

Solutions

  1. Pass both model and messages arguments to the completion call.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/openai/completion/handler.py:58 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/8d84c5b835041944. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/openai/completion/handler.py:58

        custom_llm_provider: str,
        logging_obj: LiteLLMLoggingObj,
        optional_params: dict,
        print_verbose: Callable | None = None,
        api_base: str | None = None,
        acompletion: bool = False,
        litellm_params=None,
        logger_fn=None,
        client=None,
        organization: str | None = None,
        headers: dict | None = None,
    ):
        try:
            if headers:
                optional_params = {**optional_params, "extra_headers": headers}
            if headers is None:
                headers = self.validate_environment(api_key=api_key)
            if model is None or messages is None:
                raise OpenAIError(status_code=422, message="Missing model or messages")

            # don't send max retries to the api, if set

            provider_config: Final = ProviderConfigManager.get_provider_text_completion_config(
                model=model,
                provider=LlmProviders(custom_llm_provider),
            )

            data: Final = provider_config.transform_text_completion_request(
                model=model,
                messages=messages,
                optional_params=optional_params,
                headers=headers,
            )
            max_retries: Final = data.pop("max_retries", 2)
            ## LOGGING
            logging_obj.pre_call(
                input=messages,

View on GitHub (pinned to 77b7c6c40c)