Skip to main content
@ai_kit/core includes full-duplex realtime transcription: push audio chunks as they arrive (microphone, live stream) over a WebSocket and receive transcription deltas as they come. It is compatible with Mistral’s realtime API (Voxtral model).
Not to be confused with createTranscriptionStreamingModel (see Audio Transcription), which streams the output of a complete uploaded file. Here the input is pushed continuously — ideal for a microphone.

Why a native WebSocket client?

The Vercel AI SDK (ai) has no realtime transcription primitive: experimental_transcribe / transcribe and the TranscriptionModelV3 interface are batch only. So @ai_kit/core ships a small direct WebSocket client — with no extra runtime dependency (Node ≥ 22’s global WebSocket sends the Authorization: Bearer header via undici).

Two public primitives

Audio format

Mistral expects raw PCM pcm_s16le, 16000 Hz, mono. No conversion is bundled. To convert a file with ffmpeg:
A microphone capture is usually already 16-bit mono PCM — no conversion needed.

Quickstart — transcribeStream (high-level)

Best for transcribing a file or stream you can iterate. Pass an AsyncIterable<Uint8Array> of PCM and receive events until done.
transcribeStream opens the connection, pumps the audio in the background (then sends flush + end), and stops automatically after the done or error event.

Microphone / pushed source — connect (low-level)

When audio arrives via callbacks (microphone, incoming WebSocket), open a session and push chunks yourself.

Session methods

Normalized events

Unknown event types are surfaced as { type: "unknown", raw } (never thrown) for forward compatibility.

Configuration

Connection options

Error handling

  • Connection failure, handshake timeout, or abort → throws a RealtimeTranscriptionError.
  • A server error event is surfaced as { type: "error", error }; transcribeStream stops after emitting it (in low-level mode, the caller decides).