Skip to main content
createGateway() returns a Gateway object whose handler is a plain (request: Request) => Response | Promise<Response> function — the WinterCG fetch signature every modern runtime accepts.

Node, via Hono

Inside an existing Hono app, mount it under a prefix — bare paths keep working too, so app.mount and direct /v1/... calls both resolve.

Next.js route handler


Bun and Deno


Cloudflare Workers


Seed hook context from a request

The handler’s second argument seeds the mutable context bag every hook receives — useful for passing an already-authenticated user into beforeOperation without re-deriving it from headers.
This argument only exists on the in-process call — wire traffic hitting the gateway directly can never set it.

Selective route mounting

Mount individual routes instead of the full handler, keyed by bare HTTP path.

In-process model calls

Skip HTTP entirely and resolve a model for direct AI SDK calls — useful when you already have a generateText/streamText call site and just want the gateway’s provider resolution and hooks.
gw.operation({ operation, ... }) exposes the full lifecycle (model resolution, hooks, usage aggregation) for building custom in-process call sites — see Hooks.
gw.operation accepts: The returned operation has one requestId and context for the whole lifecycle: gw.operation runs only the hooks in your config. The gateway’s built-in logging, tracing, and metrics hooks run on HTTP requests, not on in-process operations.