SPB Git

Repository Public

translation-server-events.md 10.3 KB 463 lines markdown

1# Realtime translation server events23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45These are events emitted from the OpenAI Realtime Translation WebSocket server to the client.67<a id="error"></a>89## error1011Returned when an error occurs, which could be a client problem or a server12problem. Most errors are recoverable and the session will stay open, we13recommend to implementors to monitor and log error messages by default.1415### Schema1617Schema name: `RealtimeServerEventError`1819- `error: RealtimeError`2021  Details of the error.2223  - `message: string`2425    A human-readable error message.2627  - `type: string`2829    The type of error (e.g., "invalid_request_error", "server_error").3031  - `code: optional string or null`3233    Error code, if any.3435  - `event_id: optional string or null`3637    The event_id of the client event that caused the error, if applicable.3839  - `param: optional string or null`4041    Parameter related to the error, if any.4243- `event_id: string`4445  The unique ID of the server event.4647- `type: "error"`4849  The event type, must be `error`.5051  - `"error"`5253### Example5455```json56{57    "event_id": "event_890",58    "type": "error",59    "error": {60        "type": "invalid_request_error",61        "code": "invalid_event",62        "message": "The 'type' field is missing.",63        "param": null,64        "event_id": "event_567"65    }66}67```6869<a id="session.created"></a>7071## session.created7273Returned when a translation session is created. Emitted automatically when a74new connection is established as the first server event. This event contains75the default translation session configuration.7677### Schema7879Schema name: `RealtimeTranslationServerEventSessionCreated`8081- `event_id: string`8283  The unique ID of the server event.8485- `session: RealtimeTranslationSession`8687  The translation session configuration.8889  - `id: string`9091    Unique identifier for the session that looks like `sess_1234567890abcdef`.9293  - `audio: object { input, output }`9495    Configuration for translation input and output audio.9697    - `input: optional object { noise_reduction, transcription }`9899      - `noise_reduction: optional object { type }  or null`100101        Optional input noise reduction.102103        - `type: NoiseReductionType`104105          Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.106107          - `"near_field"`108109          - `"far_field"`110111      - `transcription: optional object { model }  or null`112113        Optional source-language transcription. When configured, the server emits114        `session.input_transcript.delta` events. Translation itself still runs from115        the input audio stream.116117        - `model: string`118119          The transcription model used for source transcript deltas.120121    - `output: optional object { language }`122123      - `language: optional string`124125        Target language for translated output audio and transcript deltas.126127  - `expires_at: number`128129    Expiration timestamp for the session, in seconds since epoch.130131  - `model: string`132133    The Realtime translation model used for this session. This field is set at134    session creation and cannot be changed with `session.update`.135136  - `type: "translation"`137138    The session type. Always `translation` for Realtime translation sessions.139140    - `"translation"`141142- `type: "session.created"`143144  The event type, must be `session.created`.145146  - `"session.created"`147148### Example149150```json151{152  "type": "session.created",153  "event_id": "event_123",154  "session": {155    "id": "sess_123",156    "type": "translation",157    "model": "gpt-realtime-translate",158    "expires_at": 1714857600,159    "audio": {160      "input": {161        "transcription": {162          "model": "gpt-realtime-whisper",163          "language": "en"164        },165        "noise_reduction": {166          "type": "near_field"167        }168      },169      "output": {170        "language": "fr"171      }172    }173  }174}175```176177<a id="session.updated"></a>178179## session.updated180181Returned when a translation session is updated with a `session.update` event,182unless there is an error.183184### Schema185186Schema name: `RealtimeTranslationServerEventSessionUpdated`187188- `event_id: string`189190  The unique ID of the server event.191192- `session: RealtimeTranslationSession`193194  The translation session configuration.195196  - `id: string`197198    Unique identifier for the session that looks like `sess_1234567890abcdef`.199200  - `audio: object { input, output }`201202    Configuration for translation input and output audio.203204    - `input: optional object { noise_reduction, transcription }`205206      - `noise_reduction: optional object { type }  or null`207208        Optional input noise reduction.209210        - `type: NoiseReductionType`211212          Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.213214          - `"near_field"`215216          - `"far_field"`217218      - `transcription: optional object { model }  or null`219220        Optional source-language transcription. When configured, the server emits221        `session.input_transcript.delta` events. Translation itself still runs from222        the input audio stream.223224        - `model: string`225226          The transcription model used for source transcript deltas.227228    - `output: optional object { language }`229230      - `language: optional string`231232        Target language for translated output audio and transcript deltas.233234  - `expires_at: number`235236    Expiration timestamp for the session, in seconds since epoch.237238  - `model: string`239240    The Realtime translation model used for this session. This field is set at241    session creation and cannot be changed with `session.update`.242243  - `type: "translation"`244245    The session type. Always `translation` for Realtime translation sessions.246247    - `"translation"`248249- `type: "session.updated"`250251  The event type, must be `session.updated`.252253  - `"session.updated"`254255### Example256257```json258{259  "type": "session.updated",260  "event_id": "event_124",261  "session": {262    "id": "sess_123",263    "type": "translation",264    "model": "gpt-realtime-translate",265    "expires_at": 1714857600,266    "audio": {267      "input": {268        "transcription": {269          "model": "gpt-realtime-whisper",270          "language": "en"271        },272        "noise_reduction": {273          "type": "near_field"274        }275      },276      "output": {277        "language": "es"278      }279    }280  }281}282```283284<a id="session.closed"></a>285286## session.closed287288Returned when a realtime translation session is closed.289290### Schema291292Schema name: `RealtimeTranslationServerEventSessionClosed`293294- `event_id: string`295296  The unique ID of the server event.297298- `type: "session.closed"`299300  The event type, must be `session.closed`.301302  - `"session.closed"`303304### Example305306```json307{308  "event_id": "event_987",309  "type": "session.closed"310}311```312313<a id="session.input_transcript.delta"></a>314315## session.input_transcript.delta316317Returned when optional source-language transcript text is available. This event318is emitted only when `audio.input.transcription` is configured.319320Transcript deltas are append-only text fragments. Clients should not insert321unconditional spaces between deltas.322323### Schema324325Schema name: `RealtimeTranslationServerEventSessionInputTranscriptDelta`326327- `delta: string`328329  Append-only source-language transcript text.330331- `event_id: string`332333  The unique ID of the server event.334335- `type: "session.input_transcript.delta"`336337  The event type, must be `session.input_transcript.delta`.338339  - `"session.input_transcript.delta"`340341- `elapsed_ms: optional number or null`342343  Timing metadata for stream alignment, derived from the translation frame344  when available. It advances in 200 ms increments, but multiple transcript345  deltas may share the same `elapsed_ms`. Treat it as alignment metadata,346  not a unique transcript-delta identifier.347348### Example349350```json351{352  "event_id": "event_125",353  "type": "session.input_transcript.delta",354  "delta": " hear",355  "elapsed_ms": 1200356}357```358359<a id="session.output_transcript.delta"></a>360361## session.output_transcript.delta362363Returned when translated transcript text is available.364365Transcript deltas are append-only text fragments. Clients should not insert366unconditional spaces between deltas.367368### Schema369370Schema name: `RealtimeTranslationServerEventSessionOutputTranscriptDelta`371372- `delta: string`373374  Append-only transcript text for the translated output audio.375376- `event_id: string`377378  The unique ID of the server event.379380- `type: "session.output_transcript.delta"`381382  The event type, must be `session.output_transcript.delta`.383384  - `"session.output_transcript.delta"`385386- `elapsed_ms: optional number or null`387388  Timing metadata for stream alignment, derived from the translation frame389  when available. It advances in 200 ms increments, but multiple transcript390  deltas may share the same `elapsed_ms`. Treat it as alignment metadata,391  not a unique transcript-delta identifier.392393### Example394395```json396{397  "event_id": "event_124",398  "type": "session.output_transcript.delta",399  "delta": " escuch",400  "elapsed_ms": 1200401}402```403404<a id="session.output_audio.delta"></a>405406## session.output_audio.delta407408Returned when translated output audio is available. The `delta` contains a409PCM16 audio chunk whose length can vary. Clients should decode and queue the410complete delta instead of assuming a fixed byte or sample count.411412### Schema413414Schema name: `RealtimeTranslationServerEventSessionOutputAudioDelta`415416- `delta: string`417418  Base64-encoded translated audio data.419420- `event_id: string`421422  The unique ID of the server event.423424- `type: "session.output_audio.delta"`425426  The event type, must be `session.output_audio.delta`.427428  - `"session.output_audio.delta"`429430- `channels: optional number`431432  Number of audio channels.433434- `elapsed_ms: optional number or null`435436  Timing metadata for stream alignment, derived from the translation frame437  when available. Treat `elapsed_ms` as alignment metadata, not a unique438  event identifier.439440- `format: optional "pcm16"`441442  Audio encoding for `delta`.443444  - `"pcm16"`445446- `sample_rate: optional number`447448  Sample rate of the audio delta.449450### Example451452```json453{454  "event_id": "event_123",455  "type": "session.output_audio.delta",456  "delta": "Base64EncodedAudioDelta",457  "sample_rate": 24000,458  "channels": 1,459  "format": "pcm16",460  "elapsed_ms": 1200461}462```463
Files main
Menu

Theme