FreeOne free generation each: up to 50 characters, no sign-up, audio drama or voiceover
Back to blog
Voice craft

Text-to-Speech API Guide: Requests, Billing and Errors

How a text-to-speech API works, with ElevenLabs as the example: auth, requests, timestamps, streaming, per-character billing, errors. Our API is not open yet.

Aug 24, 2026AaronAaron

Listen to this article

AI narration · about 2 min
0:00 / –:––

Recorded when the post was published; prices and features follow the text above.

Text-to-Speech API Guide: Requests, Billing and Errors

First, a note: our API isn't open yet; for bulk work or integration, email voicesmiths@163.com. You can create API keys in settings, but no endpoint accepts them today, so please don't build against them. What follows is how text-to-speech APIs work in general, using ElevenLabs (the provider behind VoiceSmiths) as the example, so you can evaluate and integrate any vendor.

1. Auth: a key in the request header

Mainstream TTS APIs authenticate with a key. With ElevenLabs, you create an API key in its console and send the header xi-api-key: <your key> with every request. Keep the key on your server, never in front-end code or an app bundle, and revoke and recreate it if it leaks.

Text-to-Speech API Guide: Requests, Billing and Errors

2. Send a generation request

The basic ElevenLabs call is POST https://api.elevenlabs.io/v1/text-to-speech/{voice_id} with a body of:

  • text: what to read
  • model_id: the model, e.g. eleven_v4, eleven_multilingual_v2, eleven_flash_v2_5
  • voice_settings: optional, stability, similarity_boost, style, speed and so on
  • seed: optional, fixes the randomness so a read can be reproduced

The response is the audio itself; the output_format query parameter picks the format (e.g. mp3_44100_128).

3. For subtitles, ask for timestamps

Call /v1/text-to-speech/{voice_id}/with-timestamps instead and you get base64 audio plus an alignment object: start and end seconds for every character. Group characters into sentences at punctuation and you can write an SRT directly, without running speech recognition afterwards. How to cut the cues is in the subtitle timing guide.

4. Stream for latency, chunk long text yourself

  • Streaming: the /stream endpoint returns audio chunks as they are generated, for voice assistants and anything that must start speaking fast.
  • Per-request limits: each model accepts a different number of characters per request (Eleven v4 takes 10,000, v3 takes 5,000). Past that you split the text yourself; pass previous_text / next_text (or previous_request_ids) so the intonation doesn't reset between chunks.
  • Pronunciation: brand names and terms can use pronunciation dictionaries (pronunciation_dictionary_locators, up to 3 per request); see pronunciation dictionary.
  • Model trade-offs: expressiveness and audio tags versus speed and price, see choosing a model.

5. Billing: per character, not per call

TTS APIs almost all bill by character. On ElevenLabs a standard model costs about 1 credit per character and fast models like Flash / Turbo about half that. Whether failed requests are charged and what happens when the quota runs out differ by vendor, so read the docs before you integrate and handle the out-of-balance error in your code.

6. Common errors

SymptomUsual causeFix
401Invalid or revoked keyCheck the header, create a new key
422Invalid parameters (empty text, wrong model ID)Check the body against the docs
429Concurrency or rate limit hitQueue, throttle and retry
Quota exceededThe account's character quota is used upTop up, or use a cheaper model
Text too longOver the model's per-request capSplit it and pass context
Wrong accentVoice doesn't match the languageUse a native voice per language, see multilingual accents

No code: the VoiceSmiths workbench

VoiceSmiths is a web workbench for now: text to speech takes 5,000 characters per generation and long-form audiobook up to 50,000 per job, with MP3 and character-aligned SRT downloads, at 7 credits per 100 characters (4 on fast models); failed generations refund automatically. Our API isn't open yet; for bulk work or integration, email voicesmiths@163.com with your volume and use case.

Open the voice workbench →

Turn your own story into a drama like this

  1. Paste a chapter or script, up to 8,000 characters
  2. See the cast: a voice for every character, tap to hear it
  3. Render it: a 2,000-character episode is about 140 credits, so the trial pack ($29.90 for new users) covers about 21. You get an MP3 and line-timed subtitles