Audio streaming output
Generate speech from Arabic text with streaming PCM16 audio output. When streaming: true is set, audio chunks are streamed as they're generated — low-latency delivery you can start playing before generation completes.
How it works
When streaming is enabled:
| Step | What happens |
|---|---|
| 1 | The API starts generating audio immediately |
| 2 | Audio chunks are sent as they become available |
| 3 | You can begin playback before generation completes |
| 4 | Lower latency compared to non-streaming requests |
Audio format
Streaming responses return raw PCM audio data:
| Property | Value |
|---|---|
| Format | PCM (Pulse Code Modulation) |
| Sample rate | Follows sample_rate: 48000 Hz recommended (engine-native), 24000 Hz default |
| Channels | Mono |
| Bit depth | 16-bit |
Endpoint & request
Requires API key authentication via the x-api-key header. Same endpoint as Synthesize — the only difference is streaming must be true.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model_id | string | Yes | The model identifier to use for generation |
Request body — Content-Type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
voice_id | string | Yes | The voice ID to use for synthesis |
text | string | Yes | The Arabic text to convert to speech |
stability | number | Yes | Voice stability (0.0 to 1.0). Higher values produce more consistent output |
speed | number | No | Speech speed (0.7 to 1.2, default 1.0). Values below 1.0 slow down speech, above 1.0 speed it up |
streaming | boolean | Yes | Must be true for streaming response |
sample_rate | number | No | Output sample rate in Hz, 8000–48000 (default 24000). Use 48000 — it's the engine's native rate, so the audio skips downsampling and needs no client-side resampling for WebRTC. |
dialect | string | No | Dialect hint for synthesis: auto (default), emirati, or fusha. |
Example request
The cURL example uses the faseeh-v1-preview model with the ar-najdi-male-2 voice.
Response
Status code: 200 OK. The body is a stream of mono PCM16 audio chunks at the rate you requested — 24 kHz by default, 48 kHz when you pass sample_rate=48000 (recommended). The resolved rate is echoed in the Content-Type header, so a client can follow it rather than assume.
| Header | Value |
|---|---|
Content-Type | audio/raw;codec=pcm16;rate=<sample_rate>;channels=1 — e.g. rate=48000 |
Cache-Control | no-cache |
Connection | keep-alive |
Handling streaming responses. Process the streaming PCM data in your application: save chunks to a buffer, play audio chunks as they arrive, and convert PCM to your desired format (WAV, MP3, etc.) if needed.
Error responses
Errors come back as JSON with an errorCode and errorMessage.
| Status | Error code | Example message |
|---|---|---|
| 400 Bad Request | 400xx | Model not found: invalid_model_id |
| 402 Payment Required | 402xx | Insufficient wallet balance. Required: $0.05, Available: $0.02 |
Cost calculation
The cost is calculated from the text length (number of characters) and the model cost per character. Cost is deducted from your wallet balance upon successful generation.
Go further
Working with an AI assistant? Every page is available as Markdown: add .md to the URL, or send an Accept: text/markdown header. For the whole documentation in one request, point it at llms-full.txt; the page index is llms.txt. Or use Copy Page, top right.
