Experimental realtime model support via gateway.experimental_realtime()
@ai-sdk/gateway@4.0.0-canary.102
Patch Changes
-
a3bb04a: feat(gateway): add experimental realtime model support
Adds
gateway.experimental_realtime()for bidirectional audio/text realtime sessions routed through the AI Gateway. Like every other Gateway modality, the client speaks the normalized AI SDK realtime protocol and the Gateway translates to/from the upstream provider server-side, soGatewayRealtimeModelis a thin identity codec. Gateway realtime is server-side only for v0 and throws if used in a browser because it returns the resolved Gateway auth token rather than a minted ephemeral client secret. Because the browserWebSocketAPI cannot set request headers, the Gateway auth token is carried via theSec-WebSocket-Protocolsubprotocol (the same workaround used for OpenAI) and the model id rides the?ai-model-id=query — the WS transport of theai-model-idheader used by the HTTP routes. The model id is passed through verbatim; the Gateway owns resolution. Provider options (including BYOK) flow through the normalizedsession.update, exactly as they ride the request body on the non-realtime routes.The versioned subprotocol auth contract is centralized so the client and the Gateway server share one definition:
getGatewayRealtimeProtocols(client encode) andgetGatewayRealtimeAuthToken(server decode), plus theGATEWAY_REALTIME_SUBPROTOCOL/GATEWAY_AUTH_SUBPROTOCOL_PREFIXconstants.GatewayProviderOptionsdocuments the stable client-facing option fields while remaining open to service-owned options. Runtime validation lives in the Gateway service so the server can evolve without requiring an SDK release for every new option.
Fetched June 10, 2026

