Skip to content

vllm.entrypoints.openai.chat_completion.batch_serving

Classes:

OpenAIServingChatBatch

Bases: OpenAIServingChat

Extends OpenAIServingChat with the /v1/chat/completions/batch endpoint.

Processes N conversations from a single request concurrently and returns one choice per conversation indexed 0, 1, ..., N-1.

Methods:

chat_completion_full_generator_batch(request, generators, request_id, model_name, all_conversations, tokenizer, request_metadata, parser_cls=None, mm_token_counts=None) async

Handle batched (non-streaming) chat completions.

Fans out N generators (one per conversation in the batch), collects the final output for each, and assembles a single ChatCompletionResponse whose choices are indexed 0,...,N-1.

Tool-use and streaming are rejected upstream by the check_batch_mode validator, so neither needs to be handled here.

create_batch_chat_completion(request, raw_request=None) async

Batch Chat Completion endpoint (/v1/chat/completions/batch).

Processes N conversations from a single request concurrently and returns one choice per conversation indexed 0, 1, ..., N-1. Streaming, tool use, and beam search are not supported.

render_batch_chat_request(request) async

Validate the model and preprocess a batched chat completion request.

Performs engine-aware checks then delegates per-conversation preprocessing to OnlineRenderer, validating the chat template once for the whole batch.

Returns:

_sum_or_none(counts)

Sum per-prompt counts; None unless every prompt reported one.