Skip to content

Gateway

Embed with serve_gateway(), or run with python -m openai_agents.codex.sandbox.gateway.

serve_gateway

serve_gateway(
    registration_digests: Mapping[str, str],
    *,
    host: str = "127.0.0.1",
    port: int = 8765,
    ssl: SSLContext | None = None,
) -> AbstractAsyncContextManager[Server]

Serve authenticated WebSocket routes in the current event loop as an async context.

Source code in src/openai_agents/codex/sandbox/gateway.py
def serve_gateway(
    registration_digests: Mapping[str, str],
    *,
    host: str = "127.0.0.1",
    port: int = 8765,
    ssl: SSLContext | None = None,
) -> AbstractAsyncContextManager[Server]:
    """Serve authenticated WebSocket routes in the current event loop as an async context."""
    gateway = _Gateway(registration_digests)
    return serve(
        gateway.handle,
        host,
        port,
        ssl=ssl,
        origins=[None],
        process_request=gateway.check_upgrade,
        **SOCKET_OPTIONS,
    )