(language, vertical, optimizeFor) and fails over automatically.
Signature
Parameters
text: string
The text to synthesize. No length limit is enforced client-side — the upstream provider applies its own.
options: SynthesizeOptions
Extends RoutingIntent:
| Field | Type | Description |
|---|---|---|
language | string (BCP-47) | e.g. "en", "es-MX". |
vertical | Vertical | general, healthcare, finance, legal. |
optimizeFor | OptimizeFor? | balanced, accuracy, latency, cost. |
voice | string? | Voice id override. The router interprets it per provider (e.g. a Cartesia voice UUID). |
speed | number? | Speech speed multiplier. Providers vary in what range they accept — 1.0 is always neutral. |
constraints | PipelineConstraints? | Allow-list constraints. |
abortSignal?: AbortSignal
Cancel an in-flight request.
Returns
SynthesizeResult
| Field | Type | Description |
|---|---|---|
audio | Uint8Array | Raw audio bytes. Format depends on the chosen provider — always check contentType. |
contentType | string | MIME type. ElevenLabs returns audio/mpeg. Cartesia returns audio/pcm;rate=24000. |
provider | string | Upstream provider that ran the request. |
model | string | Provider-specific model identifier (e.g. voice model name). |
failoverCount | number | Providers tried before this one succeeded. |
scoresRunId | string | null | Scoring run id that selected this provider. |
Wire format
The SDK sendsPOST /v1/synthesize with a JSON body:
provider, model, failoverCount, and scoresRunId are parsed from response headers (X-Speko-Provider, X-Speko-Model, X-Speko-Failover-Count, X-Speko-Scores-Run-Id).
Example: write to disk
Example: pin a provider for deterministic output
Format gotchas
The return type depends on the provider Speko picks. If your downstream consumer only handles PCM (e.g.@spekoai/adapter-livekit v1), either pin a PCM provider via constraints or branch on contentType before you decode.