vllm.entrypoints.openai.server_utils ¶
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/server_utils.py
__call__ ¶
__call__(
scope: Scope, receive: Receive, send: Send
) -> Awaitable[None]
Source code in vllm/entrypoints/openai/server_utils.py
__init__ ¶
verify_token ¶
verify_token(headers: Headers) -> bool
Source code in vllm/entrypoints/openai/server_utils.py
SSEDecoder ¶
Robust Server-Sent Events decoder for streaming responses.
Source code in vllm/entrypoints/openai/server_utils.py
__init__ ¶
decode_chunk ¶
Decode a chunk of SSE data and return parsed events.
Source code in vllm/entrypoints/openai/server_utils.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/server_utils.py
__call__ ¶
__call__(
scope: Scope, receive: Receive, send: Send
) -> Awaitable[None]
Source code in vllm/entrypoints/openai/server_utils.py
_extract_content_from_chunk ¶
Extract content from a streaming response chunk.
Source code in vllm/entrypoints/openai/server_utils.py
_log_non_streaming_response ¶
_log_non_streaming_response(response_body: list) -> None
Log non-streaming response.
Source code in vllm/entrypoints/openai/server_utils.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/server_utils.py
get_uvicorn_log_config ¶
Get the uvicorn log config based on the provided arguments.
Priority: 1. If log_config_file is specified, use it 2. If disable_access_log_for_endpoints is specified, create a config with the access log filter 3. Otherwise, return None (use uvicorn defaults)