GPT Live
Connect to GPT Live real-time multimodal & voice API via WebSocket
AIRouter24 adaptation
nativeConnect using AIRouter24's WebSocket endpoint wss://api.airouter24.com/v1/live/sessions and a standard API key.
What is GPT Live?
GPT Live (gpt-live-1) is a real-time, low-latency multimodal voice and text model. Over a persistent WebSocket connection, client applications can stream audio and text events bidirectionally and receive instantaneous model speech and structured event streams.
Quickstart
Step 1: Get Your API Key
- Sign up or log in at AIRouter24
- Go to API Keys and create a key (starts with
sk-***) - Set your environment variable:
export AIROUTER24_API_KEY="sk-***"
Step 2: Install WebSocket Dependencies
npm install wspip install websocketsStep 3: Connect and Initialize Session
import WebSocket from 'ws';
const apiKey = process.env.AIROUTER24_API_KEY || 'sk-***';
const ws = new WebSocket('wss://api.airouter24.com/v1/live/sessions', {
headers: {
Authorization: `Bearer ${apiKey}`,
},
});
ws.on('open', () => {
console.log('Connected to AIRouter24 Live Gateway');
// Send session.start to initialize the live session
ws.send(
JSON.stringify({
type: 'session.start',
event_id: 'event_start',
session: {
model: 'gpt-live-1',
instructions: 'Be concise and ask before taking an external action.',
audio: { output: { voice: 'marin' } },
delegation: { type: 'client' },
},
}),
);
});
ws.on('message', (data) => {
const event = JSON.parse(data.toString());
console.log('Received event:', event.type, event);
});
ws.on('error', (err) => {
console.error('WebSocket error:', err);
});
ws.on('close', (code, reason) => {
console.log(`Connection closed: ${code} - ${reason.toString()}`);
});import asyncio
import json
import os
import websockets
API_KEY = os.environ.get("AIROUTER24_API_KEY", "sk-***")
WS_URL = "wss://api.airouter24.com/v1/live/sessions"
async def main():
headers = {"Authorization": f"Bearer {API_KEY}"}
async with websockets.connect(WS_URL, additional_headers=headers) as ws:
print("Connected to AIRouter24 Live Gateway")
# Initialize session
session_start = {
"type": "session.start",
"event_id": "event_start",
"session": {
"model": "gpt-live-1",
"instructions": "Be concise and ask before taking an external action.",
"audio": {"output": {"voice": "marin"}},
"delegation": {"type": "client"},
},
}
await ws.send(json.dumps(session_start))
async for message in ws:
event = json.loads(message)
print("Received event:", event.get("type"), event)
if __name__ == "__main__":
asyncio.run(main())Endpoint & Configuration Reference
| Parameter | Description | Example Value |
|---|---|---|
| WebSocket URL | AIRouter24 Live session endpoint | wss://api.airouter24.com/v1/live/sessions |
| Authorization | Bearer token authorization header | Bearer sk-*** |
| Model (model) | Model identifier | gpt-live-1 |
| Voice (voice) | Audio output voice | marin, alloy, echo, shimmer, etc. |
| Rate | Real-time session billing rate | $0.05 / minute |
Troubleshooting
- 401 Unauthorized: Ensure the
Authorizationheader has the formBearer sk-***and that your API key is active with sufficient credits. - Connection Closed / Timeout: Keep the session active with heartbeat messages or cleanly close connections when idle.
- Usage & Billing: Real-time session token and duration metrics appear immediately in the AIRouter24 Activity Dashboard.