Skip to main content
POST
Initiate Speech-to-Speech WebRTC Session

Initiate Speech-to-Speech WebRTC Session

Establish a WebRTC connection for real-time speech-to-speech conversations using OpenAI Realtime API.

Endpoint

Description

Establishes a WebRTC connection for real-time speech-to-speech conversations using OpenAI Realtime API. This endpoint accepts a WebRTC SDP offer and returns an SDP answer that can be used to establish a peer connection with OpenAI’s Realtime API.

Usage Flow

  1. Client creates a WebRTC offer (RTCPeerConnection.createOffer)
  2. Client sends the SDP offer to this endpoint
  3. This endpoint proxies the offer to OpenAI Realtime API
  4. Client receives SDP answer and establishes WebRTC connection
  5. Client can then have real-time voice conversations with the AI

S2S Time Tracking

  • Each user has a monthly S2S time quota based on their license
  • Time is tracked in minutes and deducted when sessions are logged
  • Use /speech/s2s/status to check remaining time
  • Use /speech/s2s/log-session to log session duration and deduct time

SMLTP Integration

  • All requests are processed through SMLTP for security and compliance
  • Model validation is enforced based on the specified SMLTP policy
  • Requests are audited and logged for compliance tracking

Authentication

Required: API Key

Request Body

Available Models

  • gpt-4o-mini-realtime-preview
  • gpt-4o-realtime-preview

Available Voices

  • alloy (default)
  • echo
  • fable
  • onyx
  • nova
  • shimmer
  • ash
  • ballad
  • coral

Available SMLTP Policies

  • public
  • internal (default)
  • internal-strict
  • confidential
  • hipaa
  • gdpr
  • pci-dss

Request Example

JavaScript/Node.js

Python

Response

Success Response (200)

Content-Type: application/sdp The response is an SDP answer string that can be used with RTCPeerConnection.setRemoteDescription().

Error Responses

400 Bad Request

403 Forbidden

S2S Time Limit Reached

Model Validation Failed

500 Internal Server Error

Notes

  • The SDP offer must be a valid WebRTC SDP offer string
  • After receiving the SDP answer, use it to set the remote description on your RTCPeerConnection
  • Check S2S time status before initiating sessions using /speech/s2s/status
  • Log session duration after completion using /speech/s2s/log-session
  • All requests are processed through SMLTP for security and compliance
  • The user_id parameter allows billing to a different user account

Authorizations

Authorization
string
header
required

API key authentication using Bearer token format. Example: Authorization: Bearer sk-your-api-key-here

Body

application/json
sdp
string
required

WebRTC SDP offer from the client's RTCPeerConnection

Example:

"v=0\r\no=- 4611731400430051336 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n..."

model
enum<string>
default:gpt-4o-mini-realtime-preview

OpenAI Realtime model to use

Available options:
gpt-4o-mini-realtime-preview,
gpt-4o-realtime-preview
voice
enum<string>
default:alloy

Voice to use for the AI response

Available options:
alloy,
echo,
fable,
onyx,
nova,
shimmer,
ash,
ballad,
coral
smltp_policy
enum<string>
default:internal

SMLTP policy to apply for this session

Available options:
public,
internal,
internal-strict,
confidential,
hipaa,
gdpr,
pci-dss
output_audio
boolean
default:true

Whether to enable audio output (default: true)

user_id
string

Optional user ID to bill this session to (defaults to API key owner)

Example:

"60a7c8f5e8b4f5001f7a8c23"

instructions
string

Optional system instructions for the AI assistant

Example:

"You are a helpful customer service agent."

Response

SDP answer from OpenAI Realtime API

SDP answer that can be used with RTCPeerConnection.setRemoteDescription()