Use case
Text-to-speech API with cURL
SayIt is a plain REST API, so one curl command is enough to turn text into speech. POST to https://api.sayitapi.com/v1/tts, read audio_url from the JSON response, and download the MP3. No SDK is required.
Pass the key through an environment variable
Every /v1 request sends your key in the SAYIT-API-KEY header. Keys issued by SayIt start with sk_live_, and there is no separate sandbox key. Export it once as SAYIT_API_KEY so it stays out of scripts you share or commit.
# keep the key out of your shell history and scripts
export SAYIT_API_KEY="YOUR_API_KEY"Quick start: save an MP3
POST JSON with text, voice_id, and language. The response is JSON, not audio: it includes id, audio_url, characters_used, duration_seconds, voice_id, and created_at. Download audio_url with a second request and --output. The character balance is reduced by text.length.
# 1. synthesize: the response is JSON with a signed audio_url
curl -sS -X POST https://api.sayitapi.com/v1/tts \
-H "SAYIT-API-KEY: $SAYIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Hello from cURL.","voice_id":"eve","language":"en","output_format":"mp3","speed":1}' \
--output response.json
# 2. download the MP3 from audio_url (needs jq)
curl -sS "$(jq -r .audio_url response.json)" --output hello.mp3
jq '{characters_used, duration_seconds}' response.jsonThe signed audio_url expires after 24 hours. The body also accepts output_format (mp3 or wav), speed (0.5 to 2.0; the engine applies 0.7 to 1.5 and clamps values outside that range), sample_rate (8000, 16000, 22050, or 44100; default 22050), and speech_tags (boolean, with tags written inline in the text). The request builder generates a ready-to-run curl command for any combination.
Check your plan and balance
GET /v1/account returns plan (demo, free, or paid), chars_balance, chars_used, max_text_length, rpm, and batch_size. Call it before large jobs.
curl -sS https://api.sayitapi.com/v1/account \
-H "SAYIT-API-KEY: $SAYIT_API_KEY" \
| jq '{plan, chars_balance, max_text_length, rpm, batch_size}'Voices and languages
There is no voice-list endpoint; the five voices are fixed. Set voice_id to eve, ara, rex, sal, or leo (default eve), and hear them on the voices page. language defaults to auto and also accepts one of 57 language codes; SayIt translates the text, with native voice support for 20+. Translated responses add translated and source_language.
curl -sS -X POST https://api.sayitapi.com/v1/tts \
-H "SAYIT-API-KEY: $SAYIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Your order has shipped.","voice_id":"rex","language":"es"}' \
| jq '{audio_url, translated, source_language}'Handle errors with the HTTP status
Errors use { "error": { "code", "message" } }. Use -w '%{http_code}' to capture the status while the body goes to a file. Common codes: invalid_api_key (401), invalid_request, invalid_voice, invalid_language, and text_too_long (400), quota_exceeded (402), plan_required (403), rate_limit_exceeded (429), and server_error (500). The full list is in the error reference.
status=$(curl -sS -o response.json -w '%{http_code}' \
-X POST https://api.sayitapi.com/v1/tts \
-H "SAYIT-API-KEY: $SAYIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Hello from cURL.","voice_id":"eve"}')
case "$status" in
2??) curl -sS "$(jq -r .audio_url response.json)" --output hello.mp3 ;;
*) echo "HTTP $status: $(jq -r '.error.code + ": " + .error.message' response.json)" >&2
exit 1 ;;
esacRate limits and retries
Limits are per key in a rolling one-minute window: 5 requests per minute on demo keys, 10 on free keys, and 200 on paid keys. A 429 includes a Retry-After header and retry_after in the body. Retry only 429 and 5xx responses; curl's built-in --retry does that and waits for Retry-After. Do not add --retry-all-errors, which would also repeat 400 to 403 responses that need a fix instead.
# --retry repeats 408, 429, 500, 502, 503 and 504 responses,
# waiting for Retry-After when the server sends it
curl -sS --retry 5 --retry-max-time 120 \
-X POST https://api.sayitapi.com/v1/tts \
-H "SAYIT-API-KEY: $SAYIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Hello from cURL.","voice_id":"eve"}' \
--output response.jsonquota_exceeded (402) means the character balance is too low, and the balance does not reset monthly. See pricing for character packs.
Long text: a shell loop over chunks
The per-request limit is 250 characters on demo keys, 1,000 on free keys, and 10,000 on paid keys. Read it from max_text_length instead of hardcoding it. fold -s breaks the file at spaces so each line fits, and jq -n --arg builds valid JSON even when the text contains quotes. Each chunk is a separate request billed by its own text.length.
# read the per-request limit, then split on spaces with fold -s
LIMIT=$(curl -sS https://api.sayitapi.com/v1/account \
-H "SAYIT-API-KEY: $SAYIT_API_KEY" | jq -r .max_text_length)
i=0
fold -s -w "$LIMIT" article.txt | while IFS= read -r chunk; do
[ -z "$chunk" ] && continue
i=$((i + 1))
jq -n --arg text "$chunk" '{text: $text, voice_id: "eve", language: "en"}' \
| curl -sS --retry 5 -X POST https://api.sayitapi.com/v1/tts \
-H "SAYIT-API-KEY: $SAYIT_API_KEY" \
-H "Content-Type: application/json" \
-d @- --output "part-$i.json"
curl -sS "$(jq -r .audio_url "part-$i.json")" --output "part-$i.mp3"
doneBatch requests
POST /v1/tts/batch is for paid keys only, with up to 50 items per request. The body is { "requests": [ { "text": "..." } ] }. The balance is reserved up front and failed items are refunded. The response is { "results": [...], "total": n }. Free and demo keys receive plan_required.
curl -sS -X POST https://api.sayitapi.com/v1/tts/batch \
-H "SAYIT-API-KEY: $SAYIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"requests":[{"text":"First clip."},{"text":"Second clip."}]}' \
| jq '{total, results}'FAQ
Do I need an SDK to use the API from the command line?
No. The API is plain REST over HTTPS, so cURL is enough. jq is only used in these examples to read audio_url and build JSON safely.
Does the API return the MP3 directly?
No. POST /v1/tts returns JSON with a signed audio_url. Download that URL with a second curl call and --output to save the file.
What is the maximum text per request?
Demo keys allow 250 characters, free keys 1,000, and paid keys 10,000. GET /v1/account returns the value as max_text_length; split longer text into chunks or use the batch endpoint on a paid key.
How long is the audio URL available?
The signed audio_url expires after 24 hours, and generated audio is deleted after 24 hours, so download anything you want to keep.
Which errors should a script retry?
Retry only 429 and 5xx responses. A 429 includes a Retry-After header. Do not retry 400, 401, 402, or 403; fix the request or key instead.
Writing code instead of shell? See the Python guide or the JavaScript & Node.js guide, or read the full API docs.
cURL quick start
curl -X POST https://api.sayitapi.com/v1/tts \
-H "SAYIT-API-KEY: $SAYIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Hello from cURL.","voice_id":"eve","language":"en"}'Powered by Grok TTS. Generated audio is deleted after 24 hours.
API accepts 0.5–2.0. The speech engine applies 0.7–1.5.
curl -X POST https://api.sayitapi.com/v1/tts \
-H "SAYIT-API-KEY: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Hello! This is SayIt. <emphasis>Important words</emphasis> stand out, and a pause [pause] sounds natural.","voice_id":"eve","language":"en","output_format":"mp3","speech_tags":true,"speed":1}'Live demo uses a server-side key, limited to 250 characters. Audio expires after 24 hours.