vllm.entrypoints.openai.api_server ¶
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
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
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
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
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 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 | |
lifespan async ¶
Source code in vllm/entrypoints/openai/api_server.py
load_log_config ¶
Source code in vllm/entrypoints/openai/api_server.py
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_version async ¶
tokenization ¶
tokenization(request: Request) -> OpenAIServingTokenization