OpenAI SDK-compatible realtime transcription
Streams input audio and receives OpenAI realtime transcription events. Set `intent=transcription`; 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](/realtime-reference) (AsyncAPI spec: [/asyncapi.yaml](/asyncapi.yaml)).
/oai/realtimeStreams input audio and receives OpenAI realtime transcription events. Set intent=transcription; 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.
Value in
- "transcription"
Realtime transcription model, preferably using {author}/{modelName}.
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. Use `provider_options` for provider-specific settings. You can also pass supported options directly as query parameters. If both forms set the same option, `provider_options[<name>]=<value>` takes precedence. Recognized enum and boolean option values are case-insensitive and are normalized to each provider's wire spelling; free-form values such as prompts, keyterms, and voice IDs retain their original case.
Realtime WebSocket reference
Message-level AsyncAPI reference for every AllModels WebSocket channel.
