vllm.entrypoints.openai.api_server ¶
Functions:
-
build_and_serve–Build FastAPI app, initialize state, and start serving.
-
build_and_serve_renderer–Build FastAPI app for a CPU-only render server, initialize state, and
-
build_async_engine_client_from_engine_args–Create EngineClient, either:
-
init_render_app_state–Initialise FastAPI app state for a CPU-only render server.
-
run_server–Run a single-worker API server.
-
run_server_worker–Run a single API server worker.
-
setup_server–Validate API server args and create the server socket.
_attach_endpoint_plugins(app, supported_tasks) ¶
Phase A of endpoint plugin wiring: discover, gate and attach routes.
Attached last after all core routers. This is so endpoint plugin routes can shadow core routes with the same path (see EndpointPlugin.attach_router docstring). No-ops when no plugins are discovered/allowlisted.
Source code in vllm/entrypoints/openai/api_server.py
_init_endpoint_plugins_state(engine_client, state, args) async ¶
Phase B of endpoint plugin wiring: initialize per app plugin state.
state.endpoint_plugins is set by _attach_endpoint_plugins (Phase A) in build_app. Some init_app_state callers (e.g. run_batch.py) build their own bare State without going through build_app. As a result endpoint_plugins may be absent and are treated that the same as "none attached".
engine_client is None for the CPU only render server which has no engine (see init_render_app_state). Plugins must handle a None engine_client themselves (see EndpointPlugin.init_state).
Source code in vllm/entrypoints/openai/api_server.py
build_and_serve(engine_client, listen_address, sock, args, **uvicorn_kwargs) async ¶
Build FastAPI app, initialize state, and start serving.
Returns the shutdown task for the caller to await.
Source code in vllm/entrypoints/openai/api_server.py
build_and_serve_renderer(vllm_config, listen_address, sock, args, **uvicorn_kwargs) async ¶
Build FastAPI app for a CPU-only render server, initialize state, and start serving.
Returns the shutdown task for the caller to await.
Source code in vllm/entrypoints/openai/api_server.py
build_async_engine_client_from_engine_args(engine_args, *, usage_context=UsageContext.OPENAI_API_SERVER, client_config=None) async ¶
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
init_render_app_state(vllm_config, state, args) async ¶
Initialise FastAPI app state for a CPU-only render server.
Unlike :func:init_app_state this function does not require an :class:~vllm.engine.protocol.EngineClient; it bootstraps the preprocessing pipeline (renderer, input_processor) directly from the :class:~vllm.config.VllmConfig.
Source code in vllm/entrypoints/openai/api_server.py
481 482 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 | |
run_server(args, **uvicorn_kwargs) async ¶
Run a single-worker API server.
Source code in vllm/entrypoints/openai/api_server.py
run_server_worker(listen_address, sock, args, client_config=None, **uvicorn_kwargs) async ¶
Run a single API server worker.
Source code in vllm/entrypoints/openai/api_server.py
setup_server(args, *, reuse_port) ¶
Validate API server args and create the server socket.