TTS API documentation
Updated on November 24, 2026
You send a text and you get an audio file back. Everything you need to know is on this page.
1. At a glance
- API address:
https://api.sawfoxlab.com - 7 languages: French (
fr), English (en), German (de), Spanish (es), Italian (it), Portuguese (pt), Dutch (nl). - 11 voices, each in all 7 languages, and 11 styles:
| Style | For | Languages |
|---|---|---|
narration | storytelling, history, documentaries | all 7 |
dark | dark tone, investigations, true crime | all 7 |
kids | stories for children | all 7 |
bedtime | bedtime stories, soft voice | all 7 |
news | news bulletins, current affairs | all 7 |
educational | lessons and explanations for adults | all 7 |
trailer | movie trailers, film voice-over | all 7 |
customer_service | customer service, switchboard, welcome messages | all 7 |
conversational | natural everyday voice, like a conversation | all 7 |
meditation | meditation, relaxation, slow and soothing voice | all 7 |
asmr | ASMR, soft whispered voice | all 7 |
The exact list, voice by voice and language by language, is always given by GET /v1/voices (section 5).
- Two generation modes:
- Studio: the best realism. You get the complete file, or streamed audio with
stream: true; - Flash: the audio streams in, and the beginning arrives within seconds.
- Studio: the best realism. You get the complete file, or streamed audio with
- Pricing: per character, charged only if the audio is generated. If generation fails, nothing is billed.
- Your text is never stored. It is used to generate the audio, then deleted.
- Already using another service? The API also accepts requests in the OpenAI, ElevenLabs, Google and Azure formats (see section 9). In most cases, you only need to change the address and the key.
2. Your key
Every request carries your API key, which starts with sfl_. You create it in your account.
Authorization: Bearer sfl_your_key
The X-API-Key: sfl_your_key header is also accepted.
Keep your key secret: never put it in a web page or an app that other people can open. If a key has leaked, delete it in your account and create a new one.
3. First request
curl https://api.sawfoxlab.com/v1/speech \
-H "Authorization: Bearer sfl_your_key" \
-H "Content-Type: application/json" \
-d '{"text": "Once upon a time, in a village by the sea…", "language": "en", "voice": "clara", "style": "bedtime"}' \
--output story.mp3In Python:
import requests
r = requests.post(
"https://api.sawfoxlab.com/v1/speech",
headers={"Authorization": "Bearer sfl_your_key"},
json={"text": "Hello and welcome.", "language": "en", "voice": "oliver", "style": "narration"},
)
r.raise_for_status()
open("hello.mp3", "wb").write(r.content)
print("characters:", r.headers["X-Characters"], "| charged:", r.headers["X-Charged"])In JavaScript (Node 18 or later, .mjs file):
import { writeFileSync } from "node:fs";
const r = await fetch("https://api.sawfoxlab.com/v1/speech", {
method: "POST",
headers: { "Authorization": "Bearer sfl_your_key", "Content-Type": "application/json" },
body: JSON.stringify({ text: "Bonjour et bienvenue.", language: "fr", voice: "katia", style: "news" }),
});
if (!r.ok) throw new Error((await r.json()).error);
writeFileSync("bonjour.mp3", Buffer.from(await r.arrayBuffer()));4. POST /v1/speech — generate audio
Request body (JSON)
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
text | string | yes | — | The text to read, from 1 to 20,000 characters. It can contain tags (section 6). |
language | string | yes | — | fr, en, de, es, it, pt or nl. |
voice | string | yes | — | The voice name, for example clara. The list is given by GET /v1/voices. Your custom voices: custom:… (section 5). |
style | string | no | narration | narration, dark, kids, bedtime, news, educational, trailer, customer_service, conversational, meditation or asmr (languages of each style: section 1). Note: conversational is a style; do not confuse it with the natural value of the rhythm field. With one of your custom voices (custom:…), the style has no effect on the sound: set none, or leave any style. none is only for custom voices. |
mode | string | no | studio | studio (complete file) or flash (streamed audio). |
format | string | no | mp3 | Studio: mp3, opus or wav. Studio streaming (stream: true): mp3 or pcm. Flash: mp3 or pcm. |
stream | boolean | no | false | Studio only: the audio is streamed instead of sent as a complete file, with the same realism. Flash is always streamed. |
speed | number | no | 0 | Speed in percent, from -10 to +10. Decimals are allowed (-2.5). |
rhythm | string | no | depends on the voice | natural, punchy1 or punchy2, in Studio and in Flash. The “punchy” rhythms tighten the pauses for a livelier tone. For one passage only: the <RHYTHM> tag (section 6). |
expressiveness | number | no | the voice's own | Expressiveness, from 0 (calm) to 1 (very expressive). |
pacing | number | no | the voice's own | The voice's pacing, from 0 to 1. |
variability | number | no | 0.5 | How much one generation differs from the next, from 0 to 2. The higher it is, the more two readings of the same text differ. |
fluency | boolean | no | false | “Improve text flow”: improves pronunciation, at the cost of slight changes to the text. |
priority | boolean | no | false | Priority queue: your request goes before the others (higher price, section 8). |
To keep the voice's setting without removing the line, use null or "none" (both mean the same); a real value always applies.
Response
On success (code 200), the response body is the audio itself (audio/mpeg, audio/ogg, audio/wav or audio/pcm).
| Header | Content |
|---|---|
X-Characters | The number of characters billed. |
X-Charged | The amount charged, for example 0.000412 EUR. |
X-Balance | Your balance after the request (Studio without streaming only). |
X-Sample-Rate, X-Sample-Format | In pcm only (Flash, or Studio streaming): 24000 and s16le-mono. |
Studio, Studio streaming or Flash?
| Studio | Studio streaming (stream: true) | Flash | |
|---|---|---|---|
| What you get | The complete file, in one go | Streamed audio: it starts as soon as the first seconds are ready, the rest arrives while you listen | Streamed audio, from the first seconds |
| Realism | The best | The same as Studio | Very good |
| Formats | mp3, opus, wav | mp3, pcm (24 kHz, 16-bit, mono) | mp3, pcm (24 kHz, 16-bit, mono) |
rhythm setting | Yes | Yes | Yes |
| For | Audiobooks, videos, podcasts | Listening to a long Studio text without waiting for the end | Voice assistants, live reading |
**Why no wav in streaming?** A WAV file starts with the total size of the audio, which is not known yet when the beginning is sent. pcm is exactly the same audio, without that header. To get a .wav file at the end, add the standard 44-byte WAV header in front of the data (24,000 Hz, 16-bit, mono).
Python example, Studio streaming, each chunk written as soon as it arrives:
import requests
with requests.post(
"https://api.sawfoxlab.com/v1/speech",
headers={"Authorization": "Bearer sfl_your_key"},
json={"text": "Once upon a time…", "language": "en", "voice": "clara", "style": "narration",
"mode": "studio", "stream": True, "format": "mp3"},
stream=True,
) as r:
r.raise_for_status()
with open("story_stream.mp3", "wb") as f:
for morceau in r.iter_content(chunk_size=None):
f.write(morceau)5. Voices — GET /v1/voices
No key is needed.
curl https://api.sawfoxlab.com/v1/voices
{"voices": [
{"voice": "alexandre", "languages": {"fr": ["narration", "dark", "kids", "bedtime", "news", "educational", "trailer", "customer_service", "conversational", "meditation", "asmr"], "en": ["…"]}},
…
]}The 11 voices are: alexandre, andreas, anna, antonio, charles, clara, diana, giulia, katia, oliver and paola.
Every voice speaks all 7 languages with a real native accent. All 11 styles exist in all 7 languages, for all 11 voices. If you request a voice that does not exist in a style and a language, the API answers 400 with the message unknown voice … (see GET /v1/voices), and nothing is charged.
Always rely on GET /v1/voices: if a voice is ever replaced, its old name keeps working and gets a similar voice.
Your custom voices
The voices you create in your account are used with their custom:… identifier, in the voice field or in a <VOICE custom:…> tag. Each one speaks the language chosen when it was created, and only with your account. GET /v1/custom-voices (with your key) gives the list.
Base voice: when you create a voice, you can pick one of our 11 voices as a starting point (andreas, alexandre, oliver, charles, antonio, giulia, katia, diana, paola, clara, anna); your description transforms it, and its gender is kept (no need to choose female or male). Without a choice, the starting voice is picked automatically from your description and the gender you give. Through the API: POST /v1/custom-voices with name, description, language and base_voice (or gender: female or male, required without base_voice). You can also start from one of your own custom voices to make a variant: base_voice = its identifier (custom:…); its starting voice and gender are kept.
Each voice can keep its own settings: expressiveness, pacing, variability, speed and rhythm, with the same values as in POST /v1/speech. Set them in your account, or through the API: PATCH /v1/custom-voices/{id} with {"settings": {"expressiveness": 0.6, "speed": -3, "rhythm": "natural"}}.
settingsreplaces all saved settings. A missing,nullor"none"setting falls back to the voice's base value;"settings": nullclears them all.namerenames the voice.- Main voice (
voicefield): what your request specifies wins; the rest comes from the voice's settings. - In a tag
<VOICE custom:…>: the voice always keeps its own settings, never those of the main voice. A<SPEED>or<RHYTHM>tag inside the passage still takes priority. - The style has no effect on a custom voice (see the
stylefield).
6. Tags — staging your text
Tags are written directly in text, in upper or lower case. A badly written tag is rejected with a clear 400 error, before anything is charged. You can try them all in the playground of your account.
| Tag | Effect | Example |
|---|---|---|
... | A 0.5-second pause. | And then... nothing. |
<SILENCE> | A 0.5-second silence. <SILENCE x2> = 1 second, <SILENCE x3> = 1.5 seconds… up to <SILENCE x30> = 15 seconds. Speed (speed, <SPEED>) does not change the length of silences. | End of chapter. <SILENCE x3> Chapter two. |
<VOICE nom> … </VOICE> | The passage is read by another voice, in the same language and style. Ideal for dialogue. | <VOICE oliver>Who's there?</VOICE> <VOICE diana>It's me.</VOICE> |
<STYLE nom> … </STYLE> | The passage is read by the same voice in another style. | Good evening. <STYLE news>Here are the headlines.</STYLE> |
<LANG code> … </LANG> | The passage is read in another language, with that language's real accent and the same voice. Handy for a language lesson. | Repeat after me: <LANG fr>Bonjour.</LANG> |
<SPEED +8> … </SPEED> | The passage is read 8% faster (from -30 to +30). Add gradual to speed up or slow down progressively: <SPEED +15 gradual>. | <SPEED -10>Slowly…</SPEED> |
<VOLUME +30> … </VOLUME> | The passage is 30% louder (from -100 to +100). | <VOLUME -50>he whispered</VOLUME> |
<RHYTHM punchy2> … </RHYTHM> | The passage takes another rhythm: natural, punchy1 or punchy2, like the rhythm field, but for this passage only. ... and <SILENCE> keep their length. | He walked in. <RHYTHM punchy2>A door, a scream, then nothing.</RHYTHM> |
<DIGITS> … </DIGITS> | Digits are read one by one, or two by two if grouped that way: phone numbers, codes. Only digits, spaces and - . / ( ) + are allowed inside, 30 digits at most. | Call <DIGITS>555 123 4567</DIGITS>. |
Rules:
- A tag cannot go inside a tag of the same type: no
<VOICE>inside a<VOICE>, no<SPEED>inside a<SPEED>, and so on. Different types can be combined. - At most 30 silences in a row at the same spot (15 seconds), and 300 seconds of silence at most in the whole text.
...and<SILENCE>that follow each other add up. - Pricing: each tag counts as 1 character, however long it is written.
<SILENCE x3>counts as 3 characters.
7. Your account — GET /v1/account
curl https://api.sawfoxlab.com/v1/account -H "Authorization: Bearer sfl_your_key"
{"name": "My studio", "currency": "EUR", "balance": 12.418, "simultaneous_limit": 20}simultaneous_limit is the number of requests that can be in progress at the same time for your account. It is 20 by default. Write to us if you need more.
8. Pricing and billing
| Queue | Price |
|---|---|
| Standard | €4 per million characters |
Priority (priority: true) | €5 per million characters |
- The amount is based on the characters of the text. Each tag counts as 1 character (section 6).
- The amount is reserved at the start, then fully refunded if generation fails (error
502). - The exact amount of each request is given in the
X-Chargedheader. - Monthly plans are shown on the Pricing page.
9. Already using another service? Compatible endpoints
Keep your code and your tools: just change the base address and the key. Those services' voice names are accepted and mapped to one of our voices. Our own voice names work too. If you don't specify the language, it is detected from the text.
| Format | Endpoint | Accepted key | What changes with us |
|---|---|---|---|
| OpenAI | POST /v1/audio/speech | Authorization: Bearer sfl_… | model: "tts-1" gives Flash mode, other models give Studio mode. Extra optional fields: language, style, priority (via extra_body in the OpenAI SDKs). instructions is ignored: use style. speed goes from 0.25 to 4, mapped to our range of -10% to +10%. |
| ElevenLabs | POST /v1/text-to-speech/{voice_id} and …/stream | xi-api-key: sfl_… | /stream gives Flash when the format allows it. In voice_settings, only speed is used. Extra fields: style, priority. All the usual output_format values are accepted (mp3_*, opus_*, wav_*, pcm_*, ulaw_8000, alaw_8000). |
| Google Cloud | POST /v1/text:synthesize (and /v1beta1/…) | x-goog-api-key: sfl_… (never in the URL) | text, ssml or markup are accepted. SSML is translated into our tags. Extra fields: style, priority. |
| Azure | POST /cognitiveservices/v1 | Ocp-Apim-Subscription-Key: sfl_… | The body is SSML, with the X-Microsoft-OutputFormat header. POST /sts/v1.0/issueToken is provided for tools that ask for a token. |
Example with the OpenAI SDK (Python):
from openai import OpenAI
client = OpenAI(base_url="https://api.sawfoxlab.com/v1", api_key="sfl_your_key")
with client.audio.speech.with_streaming_response.create(
model="tts-1-hd", voice="clara", input="Hello everyone.",
extra_body={"language": "en", "style": "narration"},
) as r:
r.stream_to_file("hello.mp3")On these endpoints, errors are returned in the format of the imitated service, so your tools understand them.
10. Errors
On /v1/speech, an error is returned as {"error": "}.
| Code | Meaning | What to do |
|---|---|---|
400 | The request is not valid: unknown voice for this language or style, format not possible in this mode, badly written tag… The message says exactly what. | Fix the request. Nothing was charged. |
401 | Missing or invalid key. | Check the Authorization header. |
402 | Insufficient balance. The message gives the price of the request and your balance. | Top up your account. |
422 | A field has a wrong type or an out-of-range value (for example speed: 50). The details are in detail. | Fix the field indicated. |
429 | Too many simultaneous requests for your account. | Wait for a request to finish, or write to us to raise the limit. |
502 | Generation failed. You were not charged. | Try again. |
11. Good to know
- Long texts: a request can hold up to 20,000 characters. For a book, send one chapter per request, and run several requests at the same time, within your account's limit. In Studio mode, a very long text can take several minutes: set your tool's timeout to at least 30 minutes (the server waits up to 90 minutes).
- Dropped connection: if your program closes the connection before the Studio audio is ready, nothing is charged; the request shows in your history as “interrupted”, at 0. When streaming (Flash, or Studio with
stream: true), the audio leaves from the first seconds: the request is then charged, even if you cut it before the end. - Numbers and dates: they are read naturally in the chosen language. To read digit by digit, use
<DIGITS>. - Privacy: your text is neither stored nor reused. Only the number of characters and the amount are kept, for your history.
- Service status:
GET /v1/healthanswers{"status": "ok"}.