diff --git a/vllm/entrypoints/openai/completion/protocol.py b/vllm/entrypoints/openai/completion/protocol.py index 30a4f20084..1d61ca3c59 100644 --- a/vllm/entrypoints/openai/completion/protocol.py +++ b/vllm/entrypoints/openai/completion/protocol.py @@ -346,6 +346,14 @@ class CompletionRequest(OpenAIBaseModel): thinking_token_budget=self.thinking_token_budget, ) + @model_validator(mode="before") + @classmethod + def normalize_null_max_tokens(cls, data): + if isinstance(data, dict) and data.get("max_tokens") is None: + data = data.copy() + data["max_tokens"] = cls.model_fields["max_tokens"].default + return data + @model_validator(mode="before") @classmethod def validate_response_format(cls, data):