Skip to content

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

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

refresh_time

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.

periodic_refresh async

periodic_refresh(app: FastAPI, period: float) -> None

Periodically refresh the ephemeral key.

Parameters:

Name Type Description Default

app

FastAPI

FastAPI application whose state will hold the ephemeral key pair.

required

period

float

Time in seconds to wait between refreshes.

required