Realtime transcription
Continuously send audio over Realtime WebSocket and receive incremental and final transcripts.
Continuously send audio over WebSocket and receive text deltas and final segment results for captions, meeting notes and voice input.
| Model | Usage |
|---|---|
| gpt-live-transcribe | Continuously returns text deltas during audio input; suitable for realtime captions, without detected languages |
| gpt-transcribe | Starts transcription after a speech segment is committed. Final results may include detected languages; returns an empty array when detection is unreliable |
wss://api.agtcloud.cn/v1/realtime?model=MODEL_IDConnection parameters
Session configuration
After session.created, send session.update with these fields in the session object. Wait for session.updated before sending audio.
Prepare and commit audio
| Item | Requirement |
|---|---|
| Input format | PCM16 little-endian, 24 kHz, mono. Send raw audio without WAV or other container headers |
| Audio chunks | 20–100 ms per chunk is recommended; 100 ms is 4,800 bytes. A single append event must not exceed 15 MiB |
| Commit method | Set turn_detection: null; after input_audio_buffer.append, send input_audio_buffer.commit when the speech segment ends |
| Segmentation with gpt-live-transcribe | Does not support server_vad or semantic_vad; detect speech end on the client and commit manually |
| Discard the current segment | Send input_audio_buffer.clear and wait for input_audio_buffer.cleared; do not commit an empty buffer |
| Final result | Aggregate deltas by item_id and replace temporary text with completed.transcript. Do not concatenate different speech segments by completion-event arrival order |
Convert common audio formats to the raw PCM required by the examples:
ffmpeg -i input.mp3 -f s16le -acodec pcm_s16le -ac 1 -ar 24000 audio.pcmThe examples send 100 ms chunks and close after the current speech segment completes. Set API_KEY and MODEL_ID, install the WebSocket library for the selected language, and pass the PCM file path as an argument. For continuous microphone input, repeatedly append and commit speech segments.
Transcription hints and latency
| Field | How to set |
|---|---|
prompt | Briefly describe the business scenario, recording environment and context |
keywords | Hints for proper names, abbreviations or products. Each item must not contain <, >, carriage returns or line breaks; hints do not guarantee verbatim output |
languages | Expected language list, such as zh-cn and en. Supports common ISO 639-1, some ISO 639-3 and Chinese regional codes; do not also set language |
delay | gpt-live-transcribe latency levels: minimal, low, medium, high, xhigh. Higher levels can use more context; they do not represent fixed milliseconds |
noise_reduction | near_field for headsets, far_field for distant microphones, and null to disable noise reduction |
These transcription settings are under session.audio.input. gpt-live-transcribe does not return word-level timestamps, speaker labels or transcription confidence.
Event Reference
Inspect fields and complete JSON by event. Use deltas for live display and final results for storage. Read returned usage from usage; its presence does not determine transcription success.
session.update
Update supplied session fields and wait for session.updated acknowledgment.
Troubleshooting
| Symptom | Resolution |
|---|---|
| Handshake failure | Check the platform WSS address, Bearer Key and model ID; do not duplicate /v1 |
| No final text | Check that non-empty audio was appended and commit was sent; verify sample rate, bit depth, byte order and mono configuration |
| Transcription parameters rejected | Check session.type, field nesting, keyword characters and language codes. Disable server VAD for gpt-live-transcribe |
| Audio speed or recognition is incorrect | Convert again to raw 24 kHz PCM16 little-endian audio and remove container headers |
| Speech segments appear out of order | Correlate using item_id, previous_item_id and the application's commit order, not completion-event arrival order |
| One segment failed transcription | Save the failed Item ID and original segment; decide whether to resend that segment only |
| Connection lost | Stop sending and reconnect with bounded retries. Recreate the session and handle unacknowledged audio according to application records to avoid duplicate transcription |
Native browser WebSocket cannot set an Authorization Header. Browser products should connect to the platform through a trusted backend and keep long-lived Keys on the server.