vllm.entrypoints.openai.run_batch ¶
BatchFrontendArgs ¶
Bases: BaseFrontendArgs
Arguments for the batch runner frontend.
Source code in vllm/entrypoints/openai/run_batch.py
enable_metrics class-attribute instance-attribute ¶
enable_metrics: bool = False
Enable Prometheus metrics
host class-attribute instance-attribute ¶
host: str | None = None
Host name for the Prometheus metrics server (only needed if enable-metrics is set).
input_file class-attribute instance-attribute ¶
input_file: str | None = None
The path or url to a single input file. Currently supports local file paths, or the http protocol (http or https). If a URL is specified, the file should be available via HTTP GET.
output_file class-attribute instance-attribute ¶
output_file: str | None = None
The path or url to a single output file. Currently supports local file paths, or web (http or https) urls. If a URL is specified, the file should be available via HTTP PUT.
output_tmp_dir class-attribute instance-attribute ¶
output_tmp_dir: str | None = None
The directory to store the output file before uploading it to the output URL.
BatchRequestInput ¶
Bases: OpenAIBaseModel
The per-line object of the batch input file.
NOTE: Currently only the /v1/chat/completions endpoint is supported.
Source code in vllm/entrypoints/openai/run_batch.py
BatchRequestOutput ¶
Bases: OpenAIBaseModel
The per-line object of the batch output and error files
Source code in vllm/entrypoints/openai/run_batch.py
BatchTranscriptionRequest ¶
Bases: TranscriptionRequest
Batch transcription request that uses file_url instead of file.
This class extends TranscriptionRequest but replaces the file field with file_url to support batch processing from audio files written in JSON format.
Source code in vllm/entrypoints/openai/run_batch.py
validate_no_file classmethod ¶
validate_no_file(data: Any)
Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/openai/run_batch.py
BatchTranslationRequest ¶
Bases: TranslationRequest
Batch translation request that uses file_url instead of file.
This class extends TranslationRequest but replaces the file field with file_url to support batch processing from audio files written in JSON format.
Source code in vllm/entrypoints/openai/run_batch.py
validate_no_file classmethod ¶
validate_no_file(data: Any)
Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/openai/run_batch.py
build_endpoint_registry async ¶
build_endpoint_registry(
engine_client: EngineClient, args: Namespace
) -> dict[str, dict[str, Any]]
Build the endpoint registry with all serving objects and handler configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine_client | EngineClient | The engine client | required |
args | Namespace | Command line arguments | required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, Any]] | Dictionary mapping endpoint keys to their configurations |
Source code in vllm/entrypoints/openai/run_batch.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 | |
download_bytes_from_url async ¶
Download data from a URL or decode from a data URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url | str | Either an HTTP/HTTPS URL or a data URL (data:...;base64,...) | required |
Returns:
| Type | Description |
|---|---|
bytes | Data as bytes |
Source code in vllm/entrypoints/openai/run_batch.py
handle_endpoint_request ¶
handle_endpoint_request(
request: BatchRequestInput,
tracker: BatchProgressTracker,
url_matcher: Callable[[str], bool],
handler_getter: Callable[[], Callable | None],
wrapper_fn: WrapperFn | None = None,
) -> Awaitable[BatchRequestOutput] | None
Generic handler for endpoint requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request | BatchRequestInput | The batch request input | required |
tracker | BatchProgressTracker | Progress tracker for the batch | required |
url_matcher | Callable[[str], bool] | Function that takes a URL and returns True if it matches | required |
handler_getter | Callable[[], Callable | None] | Function that returns the handler function or None | required |
wrapper_fn | WrapperFn | None | Optional function to wrap the handler (e.g., for transcriptions) | None |
Returns:
| Type | Description |
|---|---|
Awaitable[BatchRequestOutput] | None | Awaitable[BatchRequestOutput] if the request was handled, |
Awaitable[BatchRequestOutput] | None | None if URL didn't match |
Source code in vllm/entrypoints/openai/run_batch.py
make_transcription_wrapper ¶
make_transcription_wrapper(
is_translation: bool,
) -> WrapperFn
Factory function to create a wrapper for transcription/translation handlers. The wrapper converts BatchTranscriptionRequest or BatchTranslationRequest to TranscriptionRequest or TranslationRequest and calls the appropriate handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_translation | bool | If True, process as translation; otherwise process as transcription | required |
Returns:
| Type | Description |
|---|---|
WrapperFn | A function that takes a handler and returns a wrapped handler |
Source code in vllm/entrypoints/openai/run_batch.py
upload_data async ¶
Upload a local file to a URL. output_url: The URL to upload the file to. data_or_file: Either the data to upload or the path to the file to upload. from_file: If True, data_or_file is the path to the file to upload.
Source code in vllm/entrypoints/openai/run_batch.py
write_file async ¶
write_file(
path_or_url: str,
batch_outputs: list[BatchRequestOutput],
output_tmp_dir: str,
) -> None
Write batch_outputs to a file or upload to a URL. path_or_url: The path or URL to write batch_outputs to. batch_outputs: The list of batch outputs to write. output_tmp_dir: The directory to store the output file before uploading it to the output URL.
Source code in vllm/entrypoints/openai/run_batch.py
write_local_file async ¶
write_local_file(
output_path: str,
batch_outputs: list[BatchRequestOutput],
) -> None
Write the responses to a local file. output_path: The path to write the responses to. batch_outputs: The list of batch outputs to write.