vllm.entrypoints.openai.api_server ¶
ENDPOINT_LOAD_METRICS_FORMAT_HEADER_LABEL module-attribute ¶
parser module-attribute ¶
parser = FlexibleArgumentParser(
description="vLLM OpenAI-Compatible RESTful API server."
)
AuthenticationMiddleware ¶
Pure ASGI middleware that authenticates each request by checking if the Authorization Bearer token exists and equals anyof "{api_key}".
Notes¶
There are two cases in which authentication is skipped: 1. The HTTP method is OPTIONS. 2. The request path doesn't start with /v1 (e.g. /health).
Source code in vllm/entrypoints/openai/api_server.py
__call__ ¶
__call__(
scope: Scope, receive: Receive, send: Send
) -> Awaitable[None]
Source code in vllm/entrypoints/openai/api_server.py
__init__ ¶
verify_token ¶
verify_token(headers: Headers) -> bool
Source code in vllm/entrypoints/openai/api_server.py
SSEDecoder ¶
Robust Server-Sent Events decoder for streaming responses.
Source code in vllm/entrypoints/openai/api_server.py
__init__ ¶
decode_chunk ¶
Decode a chunk of SSE data and return parsed events.
Source code in vllm/entrypoints/openai/api_server.py
extract_content ¶
XRequestIdMiddleware ¶
Middleware the set's the X-Request-Id header for each response to a random uuid4 (hex) value if the header isn't already present in the request, otherwise use the provided request id.
Source code in vllm/entrypoints/openai/api_server.py
__call__ ¶
__call__(
scope: Scope, receive: Receive, send: Send
) -> Awaitable[None]
Source code in vllm/entrypoints/openai/api_server.py
_extract_content_from_chunk ¶
Extract content from a streaming response chunk.
Source code in vllm/entrypoints/openai/api_server.py
_log_non_streaming_response ¶
_log_non_streaming_response(response_body: list) -> None
Log non-streaming response.
Source code in vllm/entrypoints/openai/api_server.py
_log_streaming_response ¶
_log_streaming_response(
response, response_body: list
) -> None
Log streaming response with robust SSE parsing.
Source code in vllm/entrypoints/openai/api_server.py
base ¶
base(request: Request) -> OpenAIServing
build_app ¶
build_app(args: Namespace) -> FastAPI
Source code in vllm/entrypoints/openai/api_server.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 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 745 746 747 748 749 750 751 752 753 754 755 756 | |
build_async_engine_client async ¶
build_async_engine_client(
args: Namespace,
*,
usage_context: UsageContext = OPENAI_API_SERVER,
disable_frontend_multiprocessing: bool | None = None,
client_config: dict[str, Any] | None = None,
) -> AsyncIterator[EngineClient]
Source code in vllm/entrypoints/openai/api_server.py
build_async_engine_client_from_engine_args async ¶
build_async_engine_client_from_engine_args(
engine_args: AsyncEngineArgs,
*,
usage_context: UsageContext = OPENAI_API_SERVER,
disable_frontend_multiprocessing: bool = False,
client_config: dict[str, Any] | None = None,
) -> AsyncIterator[EngineClient]
Create EngineClient, either: - in-process using the AsyncLLMEngine Directly - multiprocess using AsyncLLMEngine RPC
Returns the Client or None if the creation failed.
Source code in vllm/entrypoints/openai/api_server.py
chat ¶
chat(request: Request) -> OpenAIServingChat | None
completion ¶
completion(
request: Request,
) -> OpenAIServingCompletion | None
create_completion async ¶
create_completion(
request: CompletionRequest, raw_request: Request
)
Source code in vllm/entrypoints/openai/api_server.py
create_messages async ¶
create_messages(
request: AnthropicMessagesRequest, raw_request: Request
)
Source code in vllm/entrypoints/openai/api_server.py
create_server_socket ¶
Source code in vllm/entrypoints/openai/api_server.py
create_server_unix_socket ¶
engine_client ¶
engine_client(request: Request) -> EngineClient
get_server_load_metrics async ¶
Source code in vllm/entrypoints/openai/api_server.py
init_app_state async ¶
init_app_state(
engine_client: EngineClient,
state: State,
args: Namespace,
) -> None
Source code in vllm/entrypoints/openai/api_server.py
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 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 | |
lifespan async ¶
Source code in vllm/entrypoints/openai/api_server.py
load_log_config ¶
Source code in vllm/entrypoints/openai/api_server.py
messages ¶
messages(request: Request) -> AnthropicServingMessages
models ¶
models(request: Request) -> OpenAIServingModels
run_server async ¶
Run a single-worker API server.
Source code in vllm/entrypoints/openai/api_server.py
run_server_worker async ¶
Run a single API server worker.
Source code in vllm/entrypoints/openai/api_server.py
setup_server ¶
Validate API server args, set up signal handler, create socket ready to serve.
Source code in vllm/entrypoints/openai/api_server.py
show_available_models async ¶
show_version async ¶
tokenization ¶
tokenization(request: Request) -> OpenAIServingTokenization