Hecho para agentes de voz que no pueden esperar 600ms

OpenAI: GPT Realtime 2.1 mini

openai/gpt-realtime-2-1-mini
activo speech-to-speech 1 proveedor
Playground

OpenAI distilled realtime reasoning model for faster, lower-cost speech-to-speech voice conversations.

AutorOpenAI
Idiomasno especificado
Formatos de respuestaStreaming: PCM · µ-law · A-law
Estadoactivo

Proveedores

Distintos proveedores pueden alojar el mismo modelo. Elige un proveedor cuando necesites un backend fijo, o deja que el enrutamiento elija entre ellos.

ProveedorSlugPor 1M de tokensLatenciaiEn TTS, la latencia se mide como el tiempo hasta el primer byte de audio. En STT, se mide como el tiempo hasta el primer token.ModosDisponibilidad
OpenAI 3 parámetros
openai
$20
—
Streaming

Idiomas admitidos

Todavía no hay una lista de idiomas revisada para este modelo.

Funciones

Speech to speech

Bidirectional realtime speech-to-speech over WebSocket or WebRTC.

speech_to_speech
Text input and output

Accepts text input and returns text output alongside audio.

text_input_output
Image input

Accepts image input in the conversation.

image_input
Turn detection

Server-side voice activity detection (server_vad) or semantic turn detection (semantic_vad).

turn_taking
Tool use

Function calling during the conversation.

tool_use
Input transcription

Optional transcription of input audio by a separate transcription model.

input_transcription

Código

Lenguaje

Voz a voz en tiempo real con el OpenAI SDK

Envía question.pcm (PCM mono de 16 bits a 24 kHz) como un turno mediante el protocolo OpenAI Realtime y guarda la respuesta hablada en reply.pcm.

import { once } from "node:events";
import { readFile, writeFile } from "node:fs/promises";
import OpenAI from "openai";
import { OpenAIRealtimeWS } from "openai/realtime/ws";

const client = new OpenAI({
  apiKey: process.env.ALLMODELS_API_KEY,
  baseURL: "https://api.allmodels.io/oai"
});
const realtime = new OpenAIRealtimeWS({ model: "gpt-realtime-2.1-mini" }, client);
const reply = [];

realtime.on("response.output_audio.delta", ({ delta }) => reply.push(Buffer.from(delta, "base64")));
realtime.on("response.done", async () => {
  await writeFile("reply.pcm", Buffer.concat(reply));
  realtime.close();
});
realtime.on("error", console.error);

if (realtime.socket.readyState !== 1) await once(realtime.socket, "open");
const format = { type: "audio/pcm", rate: 24000 };
realtime.send({
  type: "session.update",
  session: {
    type: "realtime",
    output_modalities: ["audio"],
    audio: { input: { format, turn_detection: null }, output: { format, voice: "marin" } }
  }
});
realtime.send({ type: "input_audio_buffer.append", audio: (await readFile("question.pcm")).toString("base64") });
realtime.send({ type: "input_audio_buffer.commit" });
realtime.send({ type: "response.create" });