vllm.entrypoints.openai.run_batch ¶
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 ¶
build_endpoint_registry(
engine_client: EngineClient,
args: Namespace,
base_model_paths: list[BaseModelPath],
request_logger: RequestLogger | None,
supported_tasks: tuple[SupportedTask, ...],
) -> 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 |
base_model_paths | list[BaseModelPath] | List of base model paths | required |
request_logger | RequestLogger | None | Optional request logger | required |
supported_tasks | tuple[SupportedTask, ...] | Tuple of supported tasks | 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
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 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 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | |
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.