107Authenticate your WebSocket connection with either method:107Authenticate your WebSocket connection with either method:
108 108
109* **[Ephemeral Tokens](/developers/model-capabilities/audio/ephemeral-tokens)** (recommended) — Short-lived tokens for client-side apps (browsers, mobile). Keeps your API key off the client.109* **[Ephemeral Tokens](/developers/model-capabilities/audio/ephemeral-tokens)** (recommended) — Short-lived tokens for client-side apps (browsers, mobile). Keeps your API key off the client.
110110* **API Key** — Pass your xAI API key directly in the `Authorization` header. Server-side only.* **API Key** — Pass your API key directly in the `Authorization` header. Server-side only.
111 111
112Read more in our [API documentation](/developers/rest-api-reference/inference/voice#realtime).112Read more in our [API documentation](/developers/rest-api-reference/inference/voice#realtime).
113 113
1377 1377
1378## Best Practices1378## Best Practices
1379 1379
13801380This section outlines key recommendations for building low-latency, reliable, and natural-feeling voice experiences using the xAI Speech to Speech API.This section outlines key recommendations for building low-latency, reliable, and natural-feeling voice experiences using the SpaceXSI Speech to Speech API.
1381 1381
1382### Minimize perceived latency with parallel initialization1382### Minimize perceived latency with parallel initialization
1383 1383
1508 1508
1509#### Using the OpenAI SDK1509#### Using the OpenAI SDK
1510 1510
15111511If you are using the official OpenAI SDK, point the client at the SpaceXSI endpoint and supply your xAI API key:If you are using the official OpenAI SDK, point the client at the SpaceXSI endpoint and supply your SpaceXSI API key:
1512 1512
1513```python customLanguage="pythonWithoutSDK"1513```python customLanguage="pythonWithoutSDK"
1514import asyncio1514import asyncio
1645 1645
1646### Event Naming Differences1646### Event Naming Differences
1647 1647
16481648The xAI API uses different event names for a few events with different payloads:The SpaceXSI API uses different event names for a few events with different payloads:
1649 1649
16501650* OpenAI's `conversation.item.input_audio_transcription.delta` is named `conversation.item.input_audio_transcription.updated` in the xAI API. The `updated` event contains the cumulative transcript (which may include corrections to previous updates), rather than an incremental delta. Only emitted when `audio.input.transcription.model` is set to `"grok-transcribe"`.* OpenAI's `conversation.item.input_audio_transcription.delta` is named `conversation.item.input_audio_transcription.updated` in the SpaceXSI API. The `updated` event contains the cumulative transcript (which may include corrections to previous updates), rather than an incremental delta. Only emitted when `audio.input.transcription.model` is set to `"grok-transcribe"`.
1651 1651
1652### Unsupported Client Events1652### Unsupported Client Events
1653 1653