server_keys
Utilities for managing ephemeral server keys in a FastAPI application.
Warning
Under almost no circumstances should you need to import this module directly. If stainedglass_output_protection is installed, and
you launch vLLM via the alternative entrypoint, this module will be automatically applied.
Functions:
| Name | Description |
|---|---|
ephemeral_key_lifespan_factory |
Create a FastAPI lifespan async context manager that wraps an existing lifespan but also adds functionality to |
inject_key_lifespan |
Add the |
periodic_refresh |
Periodically refresh the ephemeral key. |
ephemeral_key_lifespan_factory
¶
ephemeral_key_lifespan_factory(
refresh_time: float,
) -> Callable[
[
Callable[
[fastapi.FastAPI],
contextlib.AbstractAsyncContextManager,
]
],
Callable[
[fastapi.FastAPI],
contextlib.AbstractAsyncContextManager,
],
]
Create a FastAPI lifespan async context manager that wraps an existing lifespan but also adds functionality to periodically refresh the ephemeral keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float
|
Time in seconds to wait between refreshes. |
required |
Returns:
| Type | Description |
|---|---|
Callable[[Callable[[fastapi.FastAPI], contextlib.AbstractAsyncContextManager]], Callable[[fastapi.FastAPI], contextlib.AbstractAsyncContextManager]]
|
Wrapped lifespan async context manager. |
inject_key_lifespan
¶
inject_key_lifespan(
build_app_func: BuildAppFunc, key_refresh_time_s: float
) -> middleware.BuildAppFunc
Add the ephemeral_key_lifespan to a function that builds a vLLM OpenAI-compatible FastAPI application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
BuildAppFunc
|
Function that builds the vLLM OpenAI-compatible FastAPI application |
required |
|
float
|
Time in seconds to wait between ephemeral key refreshes. |
required |
Returns:
| Type | Description |
|---|---|
middleware.BuildAppFunc
|
A new function compatible with the same signature as |
middleware.BuildAppFunc
|
|