Text-to-Speech
Generate audio from text. PolarGrid serveskokoro-82m (preset voice catalog) and tada-3b-ml (voice-cloning). The endpoint returns audio in the container format requested via response_format — supported values are pcm, wav, and mp3.
Edge endpoints accept your
pg_* API key as a bearer token. See Authentication for details. The cURL examples below pin Toronto (yto-01) for concreteness — substitute another region or discover the fastest one via GET https://autorouter.polargrid.ai/v1/route. See API Overview for both patterns.Create Speech
Request Body
The gateway returns
400 Bad Request if input is empty/whitespace-only, voice is empty, or response_format is anything other than pcm, wav, or mp3. Synthesis failures (invalid voice ID, upstream error) return 502 Bad Gateway — never an empty 200.
Input length limits
input length is capped per model and enforced before synthesis; over-limit requests return 413 Payload Too Large with a message naming the model and its limit (e.g. Input too long: maximum 850 characters for tada-3b-ml). The limit is applied after the gateway strips surrounding quotes and code/markdown artifacts, so it counts the text actually synthesized.
tada-3b-ml has a lower limit because longer inputs can exhaust GPU memory mid-synthesis. The 850-character cap is a deterministic, documented contract that keeps identical requests behaving identically regardless of server load. Split longer text into multiple requests and concatenate the audio client-side.Voices
tada-3b-ml is a voice-cloning model — see the model page for how to provide a reference voice; it does not use the preset voice IDs below.
The kokoro-82m model exposes eight preset voices through the PolarGrid SDKs:
See the Voice AI guide for how these map to Kokoro-82M and a link to the full upstream voice list.
TADA output is deterministic.
tada-3b-ml uses diffusion-based synthesis with a fixed random seed, so the same input text + same voice reference always produces byte-identical audio. This is by design — the fixed seed guarantees consistent voice identity and timing across requests, which matters for voice-agent pipelines where prosody shifts between calls would be jarring. There is no server-side cache: every request runs full inference and is billed accordingly, even when the output matches a previous call. A user-controllable seed parameter is planned for a future API version to let callers introduce deliberate prosody variation.Audio Format
Audio is generated at 24 kHz, 16-bit, mono. The container is chosen byresponse_format:
PCM is the lowest-latency choice and the recommended format for real-time voice-agent pipelines. Pick
wav if you need a playable file with no client-side post-processing, or mp3 if bandwidth matters more than first-byte latency.
opus, aac, and flac from the OpenAI spec are not yet supported in batch mode — requesting them returns 400. For streaming, opus is supported (see below); for batch, transcode PCM client-side if you need one of those:
Streaming
Passstream: true to receive chunked audio over a single HTTP response — first bytes typically arrive in under 300 ms, well before synthesis finishes. The PolarGrid SDKs default streaming requests to response_format: 'opus'; raw HTTP callers get pcm when response_format is omitted (the gateway’s lowest-latency default).
Streamable formats:
Streaming
wav or mp3 returns 400 Bad Request.
Streamable models:
Response headers:
X-Polargrid-Stream: 1— set on every streaming response.X-Polargrid-Sample-Rate: 24000— PCM sample rate; Opus is resampled to 48 kHz inside the Ogg container.
Detecting truncated streams
A mid-stream Triton or upstream failure closes the connection cleanly — there is no in-band error frame. Clients observe one of:- A
ReadError/IncompleteRead/ChunkedEncodingErrorraised by the HTTP client. - For
opus, an Ogg stream that never sees theend-of-streamflag on its final page.
Streaming example
Example Request
Response
Returns the requested container as a binary body, withContent-Type set to audio/pcm, audio/wav, or audio/mpeg to match response_format.
See Streaming above for the streaming TTS contract, supported formats and models, and code samples.