LatentKit

Speech (Text-to-Speech)

POST /v1/speech — synthesize spoken audio from text through the assigned route.

POST /v1/speech converts text into spoken audio. The assigned route must include a model with the audio_output capability.

For the reverse direction — turning audio into text — see Audio and STT.

Request

curl https://ai.latentkit.com/v1/speech \
  -H "Authorization: Bearer $LATENTKIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Welcome to LatentKit. Your request was routed automatically.",
    "voice": "alloy",
    "response_format": "mp3",
    "speed": 1.0
  }'

Fields

FieldDescription
inputText to synthesize (required)
voiceVoice name when the route model supports voice selection (e.g. alloy)
response_formatOutput audio format when supported (e.g. mp3, wav, opus)
speedPlayback speed multiplier when supported (must be greater than 0)
response_profilefast, balanced, or deep when the route allows overrides

Voice names and formats are provider-specific. Because the route decides which provider executes, prefer widely supported values, or pin a specific model in the routing policy when your product depends on one exact voice.

SDK

const speech = await client.speech.create({
  input: 'Welcome to LatentKit.',
  voice: 'alloy',
  response_format: 'mp3',
});
speech = client.speech.create(
    input="Welcome to LatentKit.",
    voice="alloy",
    response_format="mp3",
)

Response

Speech responses use the unified runtime envelope (id, provider, model, policy_version_id, usage). Inspect the returned payload for the audio content field your route's provider adapter produces — typically base64-encoded audio data plus format metadata.

Managed Billing

Platform Access speech consumes workspace credits when the selected model is available for managed usage. BYOK speech is charged by your provider account. Check current availability and pricing in the console.

Audio output inside chat

Chat requests can also request spoken output by including "modalities": ["audio"] when the route model supports audio output. When present, LatentKit requires the audio_output capability for route eligibility.

Troubleshooting

  • NO_HEALTHY_PROVIDER means no route model has the audio_output capability. Enable a TTS-capable model on a connection and add it to the route.
  • If a model is unavailable through Platform Access, use a supported BYOK connection or select another route model.

On this page