New: Audio API, Embeddings & Realtime WebSocket now available!
osmAPI LogoosmAPI

Create Realtime Session

Create Realtime Session

POST /v1/realtime/sessions

Creates an ephemeral client secret for WebRTC-based realtime voice connections from browsers.

Request

Content-Type: application/json

ParameterTypeRequiredDescription
modelstringYesRealtime model ID: gpt-realtime or gpt-realtime-mini
voicestringNoVoice for the session (e.g., alloy, echo, shimmer)

Note: /v1/realtime/client_secrets is also accepted as an alias for this endpoint.

curl -X POST "https://api.osmapi.com/v1/realtime/sessions" \
  -H "Authorization: Bearer $OSM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-realtime",
    "voice": "alloy"
  }'

Response

{
  "id": "sess_abc123",
  "object": "realtime.session",
  "model": "gpt-realtime",
  "client_secret": {
    "value": "ek_abc123...",
    "expires_at": 1774960000
  }
}

Usage

The client_secret.value is used by browser clients to establish direct WebRTC connections:

const pc = new RTCPeerConnection();
const response = await fetch("/v1/realtime/sessions", { ... });
const { client_secret } = await response.json();
// Use client_secret.value for WebRTC negotiation

See the Realtime feature guide for detailed WebRTC setup.

How is this guide?