vllm.entrypoints.openai.run_batch ¶
Classes:
-
BatchFrontendArgs–Arguments for the batch runner frontend.
-
BatchRequestInput–The per-line object of the batch input file.
-
BatchRequestOutput–The per-line object of the batch output and error files
-
BatchTranscriptionRequest–Batch transcription request that uses file_url instead of file.
-
BatchTranslationRequest–Batch translation request that uses file_url instead of file.
Functions:
-
build_endpoint_registry–Build the endpoint registry with all serving objects and handler configurations.
-
download_bytes_from_url–Download data from a URL or decode from a data URL.
-
handle_endpoint_request–Generic handler for endpoint requests.
-
make_transcription_wrapper–Factory function to create a wrapper for transcription/translation handlers.
-
upload_data–Upload a local file to a URL.
-
write_file–Write batch_outputs to a file or upload to a URL.
-
write_local_file–Write the responses to a local file.
BatchFrontendArgs ¶
Bases: BaseFrontendArgs
Arguments for the batch runner frontend.
Attributes:
-
enable_metrics(bool) –Enable Prometheus metrics
-
host(str | None) –Host name for the Prometheus metrics server
-
input_file(str | None) –The path or url to a single input file. Currently supports local file
-
output_file(str | None) –The path or url to a single output file. Currently supports
-
output_tmp_dir(str | None) –The directory to store the output file before uploading it
-
port(int) –Port number for the Prometheus metrics server
-
url(str) –[DEPRECATED] Host name for the Prometheus metrics server
Source code in vllm/entrypoints/openai/run_batch.py
enable_metrics = False class-attribute instance-attribute ¶
Enable Prometheus metrics
host = None class-attribute instance-attribute ¶
Host name for the Prometheus metrics server (only needed if enable-metrics is set).
input_file = None class-attribute instance-attribute ¶
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 = None class-attribute instance-attribute ¶
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 = None class-attribute instance-attribute ¶
The directory to store the output file before uploading it to the output URL.
port = 8000 class-attribute instance-attribute ¶
Port number for the Prometheus metrics server (only needed if enable-metrics is set).
url = '0.0.0.0' class-attribute instance-attribute ¶
[DEPRECATED] Host name for the Prometheus metrics server (only needed if enable-metrics is set). Use --host instead.
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.
Methods:
-
validate_no_file–Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/openai/run_batch.py
validate_no_file(data) classmethod ¶
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.
Methods:
-
validate_no_file–Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/openai/run_batch.py
validate_no_file(data) classmethod ¶
Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/openai/run_batch.py
build_endpoint_registry(engine_client, args) async ¶
Build the endpoint registry with all serving objects and handler configurations.
Parameters:
-
(engine_client¶EngineClient) –The engine client
-
(args¶Namespace) –Command line arguments
Returns:
Source code in vllm/entrypoints/openai/run_batch.py
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 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | |
download_bytes_from_url(url, allowed_media_domains=None) async ¶
Download data from a URL or decode from a data URL.
Parameters:
-
(url¶str) –Either an HTTP/HTTPS URL or a data URL (data:...;base64,...)
-
(allowed_media_domains¶list[str] | None, default:None) –If set, only HTTP/HTTPS URLs whose hostname is in this list are permitted. data: URLs are not subject to this restriction.
Returns:
-
bytes–Data as bytes
Source code in vllm/entrypoints/openai/run_batch.py
handle_endpoint_request(request, tracker, url_matcher, handler_getter, wrapper_fn=None) ¶
Generic handler for endpoint requests.
Parameters:
-
(request¶BatchRequestInput) –The batch request input
-
(tracker¶BatchProgressTracker) –Progress tracker for the batch
-
(url_matcher¶Callable[[str], bool]) –Function that takes a URL and returns True if it matches
-
(handler_getter¶Callable[[], Callable | None]) –Function that returns the handler function or None
-
(wrapper_fn¶WrapperFn | None, default:None) –Optional function to wrap the handler (e.g., for transcriptions)
Returns:
-
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(is_translation, allowed_media_domains=None) ¶
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:
-
(is_translation¶bool) –If True, process as translation; otherwise process as transcription
-
(allowed_media_domains¶list[str] | None, default:None) –If set, only URLs from these domains are permitted for HTTP/HTTPS fetches.
Returns:
-
WrapperFn–A function that takes a handler and returns a wrapped handler
Source code in vllm/entrypoints/openai/run_batch.py
upload_data(output_url, data_or_file, from_file) 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(path_or_url, batch_outputs, output_tmp_dir) async ¶
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(output_path, batch_outputs) async ¶
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.