OpenAI SDK-compatible realtime transcription and speech-to-speech
/oai/realtimeOne OpenAI Realtime WebSocket for two uses. Set the OpenAI SDK base URL to https://api.allmodels.io/oai and authenticate with your AllModels API key.
- Speech-to-speech: omit
intentand setmodelto a speech-to-speech model (gpt-realtime-2.1,gpt-realtime-2.1-mini,gpt-realtime-2,grok-voice-latest,grok-voice-3.0,grok-voice-2.0,grok-voice-think-fast-2.0,eleven_realtime_v1_minioreleven_realtime_v1_max, each with an optionalopenai/,grok/orelevenlabs/prefix). The provider's own Realtime events pass through unchanged in both directions, except that an ElevenLabs session stays on the model in the URL: asession.modelinsession.updateis replaced with it. OpenAI models bill on tokens, Grok Voice models on session seconds plus text items, ElevenLabs Realtime models on session seconds (prices on the models page). On an OpenAI model, input transcription (session.audio.input.transcription.model) is billed separately as speech-to-text at that transcription model's price. A transcription model without a price is answered with anerrorevent (model_not_priced,param: session.audio.input.transcription.model) and thesession.updateis not applied; the session stays open. Live models (gpt-live-1,gemini-3.8-live) are refused400 invalid_model; connect to/oai/live/sessionsinstead. Walkthrough: Speech to speech. - Transcription: set
intent=transcriptionor a transcriptionmodel; the rest of this description covers it.
Transcription streams input audio and receives OpenAI realtime transcription events; use /oai/audio/speech to stream generated speech. Node and Python clients use Bearer authentication. Browser clients can pass realtime and openai-insecure-api-key.<allmodels-key> as WebSocket subprotocols. Send OpenAI's nested session.update before audio. turn_detection: null, server_vad, and semantic_vad translate to portable manual, acoustic, and semantic intent for the selected provider. Unsupported configurations arrive as official OpenAI error events. Query-level provider_options[...] remains the native override extension.
The message-level protocol is documented at the realtime WebSocket reference (AsyncAPI spec: /asyncapi.yaml).
Authorization
BearerAuth Tenant key supplied as the Authorization Bearer token.
In: header
Query Parameters
Realtime mode. Only transcription is supported, and it always selects transcription. Omit it for speech-to-speech.
Value in
- "transcription"
A speech-to-speech model (see above; selects speech-to-speech when intent is omitted) or a realtime transcription model, preferably using {author}/{modelName}. Required — a missing value is refused 400 missing_required_parameter; the router applies no default model.
Comma-separated or repeated provider IDs in preferred order. Providers not listed remain eligible.
Comma-separated or repeated provider IDs. Only these providers may serve the request.
Comma-separated or repeated provider IDs that must not serve the request.
Set to false to prevent fallback to another provider. Automatic provider retries are not currently supported.
Provider-specific options in bracket notation, such as provider_options[encoding]=linear16. Provider-native names are accepted only inside this namespace; unknown bare query parameters are rejected.
Header Parameters
Must be websocket to perform the protocol upgrade.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
import { once } from "node:events";import { readFile } from "node:fs/promises";import OpenAI from "openai";import { OpenAIRealtimeWebSocket } from "openai/realtime/websocket";const client = new OpenAI({ apiKey: process.env.ALLMODELS_API_KEY, baseURL: "https://api.allmodels.io/oai"});const realtime = await OpenAIRealtimeWebSocket.create(client, { model: "openai/gpt-realtime-whisper"});realtime.on("conversation.item.input_audio_transcription.delta", ({ delta }) => console.log(delta));realtime.on("conversation.item.input_audio_transcription.completed", ({ transcript }) => { console.log(transcript); realtime.close({ code: 1000, reason: "complete" });});if (realtime.socket.readyState !== 1) await once(realtime.socket, "open");realtime.send({ type: "session.update", session: { type: "transcription", audio: { input: { format: { type: "audio/pcm", rate: 24000 }, transcription: { model: "openai/gpt-realtime-whisper", language: "en" }, turn_detection: null } }}});realtime.send({ type: "input_audio_buffer.append", audio: (await readFile("chunk.pcm")).toString("base64") });realtime.send({ type: "input_audio_buffer.commit" });import asyncioimport base64import osfrom pathlib import Pathfrom openai import AsyncOpenAIasync def main(): client = AsyncOpenAI( api_key=os.environ["ALLMODELS_API_KEY"], base_url="https://api.allmodels.io/oai", ) async with client.realtime.connect( model="openai/gpt-realtime-whisper", extra_query={"intent": "transcription"}, ) as connection: await connection.session.update(session={ "type": "transcription", "audio": {"input": {"format": {"type": "audio/pcm", "rate": 24000}, "transcription": {"model": "openai/gpt-realtime-whisper", "language": "en"}, "turn_detection": None}}, }) audio = base64.b64encode(Path("chunk.pcm").read_bytes()).decode("ascii") await connection.input_audio_buffer.append(audio=audio) await connection.input_audio_buffer.commit() async for event in connection: if event.type.endswith(("transcription.delta", "transcription.completed")): print(event) if event.type == "conversation.item.input_audio_transcription.completed": breakasyncio.run(main()){ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}OpenAI SDK-compatible transcription POST
Transcribes an uploaded audio file with the official OpenAI JavaScript or Python SDK. Set `stream=true` only when the selected model supports streaming transcription.
OpenAI SDK-compatible GPT-Live speech-to-speech GET
Holds a speech-to-speech conversation over the OpenAI GPT-Live protocol; `gpt-live-1` and `gemini-3.8-live` share its frames. Set the OpenAI SDK base URL to `https://api.allmodels.io/oai` and authenticate with your AllModels API key.
