Skip to main content
Use this flow for browser-based OpenAI Realtime voice apps (React, etc.). TrueFoundry mints a short-lived ephemeral client secret so your API key stays server-side. The browser then connects directly to OpenAI for WebRTC. Live audio/media is not proxied through the gateway.
For server-side / WebSocket Realtime, use the Live / Realtime API (wss://{GATEWAY_HOST}/live/{providerAccountName}) instead.

Architecture

TrueFoundry credentials never go to the browser. Because media does not pass through the gateway, live-session observability for the WebRTC media path will not appear on gateway traces the way WebSocket /live/... sessions do.

Prerequisites

  1. An OpenAI (or Azure OpenAI / Azure AI Foundry) model account on TrueFoundry with a Realtime model (for example gpt-realtime or gpt-realtime-2.1).
  2. Your Gateway Base URL and TrueFoundry API key.
  3. Call this from your backend and return only the ephemeral key (ek_...) to the browser — do not put the TrueFoundry API key in client code.

1. Mint an ephemeral client secret (backend)

Replace ${GATEWAY_BASE_URL}, ${TFY_API_KEY}, openai-main, and gpt-realtime with your gateway URL, API key, provider account name, and realtime model id. The response includes a short-lived key (ek_...). Return only that value to the browser. Mint it immediately before connecting — ephemeral keys expire quickly.

2. Connect WebRTC from the browser (directly to OpenAI)

Follow OpenAI’s Realtime WebRTC guide. Do not send the SDP offer to TrueFoundry.
Serve this page over http://localhost or HTTPS so the browser can access the microphone.

What TrueFoundry does / does not do