Skip to main content
For applications requiring the lowest latency, use the real-time WebSocket API. This provides streaming transcription with incremental results. You have two ways to connect:
  • The Python SDK (client.beta.realtime.transcription()), which handles the WebSocket, reconnection, and audio replay for you. Use this for most applications.
  • The raw WebSocket protocol, for languages other than Python or when you need full control over the wire.
The server uses Voice Activity Detection (VAD) to automatically segment speech. You can tune VAD parameters for your audio characteristics. See the Voice activity detection guide for configuration details and common presets.

Python SDK

The Python SDK for real-time transcription is in beta, and the API surface may change before it stabilizes. Share feedback with [email protected].
The SDK opens the WebSocket, streams your audio, and returns transcription events. When the connection drops mid-conversation, the session holds on to the speech the server hadn’t transcribed yet, reconnects automatically, and picks up where the transcript left off, so words spoken during the outage still come back as text. Install the SDK with the realtime extra:

Basic usage

Call client.beta.realtime.transcription() to open a session, feed audio with session.append(), and consume events by iterating the session. Each TranscriptDelta is an interim result that updates while a phrase is being spoken; each TranscriptCompleted is the finalized transcript for one utterance.
session.append() never blocks on network state, so it is safe to call from a capture loop. Instead of iterating the session, you can pass an event_callback= function to handle events as they arrive.

Audio format

Audio in is 16 kHz mono 16-bit PCM (pcm_s16le_16000). Resample your source before appending. Passing sample_rate= lets the SDK reject a mismatch loudly instead of silently transcribing the wrong sample rate.

Utterance boundaries

Utterance boundaries are detected server-side by default. Final transcripts arrive on their own as the speaker pauses. To control segmentation yourself, pass turn_detection={"type": "none"} and call await session.commit() when each segment ends.

Session events

Iterate the session (or pass event_callback=) to receive normalized events. Import them from together.realtime. TranscriptDelta and TranscriptCompleted may also include optional quality fields when the server sends them: logprobs (avg_logprob, token_logprobs, token_texts) and tokens (per-token token_id, text, and confidence).

Reconnection and replay

When the connection drops, the session emits Reconnecting and Reconnected events and retries on its own. By default the SDK makes up to two same-endpoint reconnect attempts (reconnect={"max_attempts": 2}) before raising. Transcripts recomputed from speech carried across the reconnect are marked replayed=True and may overlap text you already received. Voice agents that act on each final result can set buffer={"max_replay_seconds": 0} to resume live with no re-emission instead.

Failover across endpoints

If an endpoint fails for good, calls raise RealtimeConnectionError. When the server reports it cannot currently serve (exc.code == "no_healthy_workers", including WebSocket close code 4503), the SDK raises immediately with no same-endpoint retry so you can rotate. To keep a conversation alive across endpoint outages, run a failover ring: on failure, session.pending_audio() hands you the un-transcribed speech to seed a new session on another endpoint.

Synchronous usage

Together().beta.realtime.transcription(...) mirrors the async API on a background thread. Use it for a handful of concurrent sessions. For high concurrency, use the async client.

Key parameters

For full manual control over the raw wire events with no automatic recovery, use client.beta.realtime.connect().

Raw WebSocket protocol

Use the raw WebSocket protocol from languages other than Python, or when you need full control over the wire. The SDK above wraps this same protocol.

Establish a connection

Connect to: wss://api.together.ai/v1/realtime?model={model}&input_audio_format=pcm_s16le_16000 Headers:

Query parameters

Client-to-server messages

Append audio to buffer

Send audio data in base64-encoded PCM format.

Commit audio buffer

Forces transcription of any remaining audio in the server-side buffer.

Server-to-client messages

Delta events (intermediate results)

Delta events are intermediate transcriptions. The model is still processing and may revise the output. Each delta message overrides the previous delta.

Completed events (final results)

Completed events are final transcriptions. The model is confident about this text. The next delta event continues from where this completed.

Real-time example