TTS & STT API documentation
Integrate TTS and paid STT on your server with your existing FasihTTS API key.
Arabic text to speech API with Saudi, Gulf, Egyptian, Levantine and Darija voices. Server-side examples, async jobs, MP3 output and Arabic speech to text.
The prepaid Project Pack includes REST API access for one project or occasional use, without a monthly subscription.
Minute-funded HD requests accept up to 10,000 characters on Basic and 15,000 on Pro or Project Pack. Counts use UTF-16 code units, including whitespace. Over-limit requests return HTTP 400 with code text_limit_exceeded, limit, actual, countUnit, and English error / Arabic errorAr messages before any job or quota reservation. Legacy character limits remain Basic 5,000, Pro/Project 15,000, Enterprise 50,000.
HD voice jobs
Start with a complete server-side example: submit once, poll the job, and download the MP3. Requires a paid allowance and an API key. Quota is selected automatically, including existing character plans.
Read GET https://api.fasihtts.com/v1/voices and choose an available HD voice. Persist the complete payload and a unique Idempotency-Key before submitting. Keep both unchanged when retrying the same request; use a new key only for an intentional new generation.
POST https://xrwqtifhqycpxfjzfrip.supabase.co/functions/v1/generate-tts-v2
x-api-key: YOUR_API_KEY
Idempotency-Key: UNIQUE_REQUEST_KEY
Content-Type: application/json
{"text":"السعر ١٢٥٠ جنيهًا","voice":"ar-eg-cairo-male-2","dialect":"ar-eg-cairo"}
202 {"jobId":"...","unit":"seconds","reserved":60,"status":"queued"}
POST https://xrwqtifhqycpxfjzfrip.supabase.co/functions/v1/get-long-tts-job
x-api-key: YOUR_API_KEY
Content-Type: application/json
{"id":"JOB_ID"}
200 {"job":{"status":"completed","audio_url":"SIGNED_MP3_URL","quota":{"unit":"seconds","charged":24,"durationSeconds":23.6}}}Poll the job endpoint every 2–5 seconds. A completed job returns a signed MP3 URL. Generation reserves quota, charges the completed duration rounded up once to a whole second, and releases the unused reservation. Failed jobs are not charged. Repeated downloads are free. Existing character balances can use quotaUnit: characters; they remain separate from audio-minute balances. GET get-usage returns audioQuota in seconds alongside previous character usage.
409 idempotency_conflict means a key was reused with different input. 409 balance_temporarily_reserved means another job holds your minutes: wait for it to finish. 403 quota_exceeded means insufficient allowance. 410 voice_retired means a previous voice has retired; choose a replacement explicitly. 503 means temporarily unavailable, not necessarily insufficient credit.
HD request fields and response handling
- Required: text (non-empty string), voice (available HD ID), and Idempotency-Key (non-blank, at most 128 characters; requestKey in JSON is also accepted). Use a UUID and persist it before the first attempt.
- dialect defaults to the public voice’s dialect. Set it explicitly for a private voice. GET /v1/dialects lists Arabic dialects plus English (en) and French (fr) generation previews; these read your supplied text, not translate it. Keep the selected voice ID.
- Optional: styleInstruction (the first 500 UTF-16 code units are used), quotaUnit (seconds or characters), and budgetSeconds (positive integer, no more than your available seconds or 100,000). A low duration budget can cause the job to fail; it does not guarantee a shorter recording. Leave quota selection and budget automatic unless you need explicit control.
- Do not send provider model IDs or assume a model/format parameter. FasihTTS manages provider routing; this HD job flow produces MP3. longForm is a legacy endpoint field, not required for HD jobs.
- HTTP 202 acknowledges a job, not finished audio. Save jobId and poll the same job while queued or processing. On failed, stop and inspect the result. A network timeout is uncertain: retry the identical submit with its original key, or resume polling the saved job—not a new paid generation.
- Download job.audio_url without your API key. Signed links expire; poll the same job for a fresh link only while its audio remains available. audioExpired: true or audio_url: null means no downloadable audio is available; polling does not restore deleted or expired content. Save the MP3 promptly.
Speech to text (STT) · Beta
Paid transcription with your existing API key, plus a signed-in web workspace.
Paid developer API
Use your existing FasihTTS API key in x-api-key from your server. Do not also send Authorization, expose keys in browser code, or supply provider credentials. Paid STT uses the same audio-minute balance as TTS. Free STT samples remain a signed-in, verified web feature—not an API-key allowance.
Three steps: upload the raw MP3 bytes, accept the returned credit quote, then poll the exact job. The upload is not multipart/form-data, a base64 JSON field, or a remote audio URL. Persist a UUID Idempotency-Key before uploading; retry only the same bytes with that same key. Save the entire upload response before starting.
# Server-side shell; set FASIHTTS_API_KEY privately.
# Generate and SAVE a UUID for this recording before the first upload.
curl --fail-with-body --max-time 90 \
https://api.fasihtts.com/v1/stt/account/source \
-H "x-api-key: $FASIHTTS_API_KEY" \
-H "Idempotency-Key: $FASIHTTS_REQUEST_ID" \
-H "Content-Type: audio/mpeg" \
--data-binary @recording.mp3
# 200: {"status":"uploaded","jobId":"JOB_UUID","requestKey":"SAVED_UUID",
# "creditQuote":{"fingerprint":"QUOTE_HASH","nativeUnit":"seconds",
# "reservedUnits":9,"expiresAtMs":1800000000000}}
# Values above are illustrative. Use the exact values returned by your upload.
curl --fail-with-body --max-time 30 \
https://api.fasihtts.com/v1/stt/account/start \
-H "x-api-key: $FASIHTTS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"jobId":"JOB_UUID","requestKey":"SAVED_UUID","quoteFingerprint":"QUOTE_HASH"}'
# 202 while queued/processing. Save the same job ID; do not upload again.
curl --fail-with-body --max-time 30 \
"https://api.fasihtts.com/v1/stt/account/jobs/JOB_UUID/result" \
-H "x-api-key: $FASIHTTS_API_KEY"
# 200 result fields: id, status, rawTranscript, reviewedTranscript, revision, credit.
# status="ready" is success. The transcript is not nested inside a job field.- Upload returns jobId, requestKey and creditQuote with fingerprint, nativeUnit, reservedUnits and expiresAtMs. It holds allowance before inference. Start accepts only jobId, requestKey and quoteFingerprint from that response; submit before quote expiry. Exact retries return the original job rather than reserving again.
- Poll every 2–5 seconds with a bounded timeout. queued/processing are pending; ready returns usable text and charged credit. failed, no_speech and outcome_uncertain are terminal non-success states with released customer credit. Stop; do not automatically create a replacement. Save your jobId to resume after a timeout.
- An uncertain upload: resend the same MP3 and UUID. An uncertain start: resend the same three fields or poll the known job. A 404 before a start was confirmed is not permission to upload with a fresh key. An expired or released quote cannot be silently restarted; inspect the original state first.
- Optional owned-job routes: GET /v1/stt/account/jobs/{id}/source returns the original audio; PATCH /v1/stt/account/jobs/{id}/review accepts {expectedRevision, text}. Use the latest revision; 409 revision_conflict means reload before editing. These do not generate again. API keys cannot access free-sample jobs or the web-only recent-recordings list. Retained paid jobs remain readable with a valid key after paid allowance expires.
- Errors: 400 invalid request/media; 401 missing, invalid or revoked key; 402 insufficient paid credits; 403 access denied or disallowed source; 404 job not found for this account; 409 conflicting/expired quote, request key or revision; 503 unavailable or unconfirmed operation. A 503 is not an upgrade prompt. Keep the job, key and quote for recovery; never log the API key.
Prefer the website?
- Open Transcribe and sign in. Choose paid audio minutes or a free sample before uploading.
- Upload an MP3 you have permission to use. Review the allowance quote, then start transcription. Uploading and starting are separate steps.
- Wait for the result, listen back, edit and save the transcript. Copy the text or download TXT; review names and wording before using it.
| Allowance | Input | Accounting |
|---|---|---|
| Paid audio minutes | MP3 · up to 2 minutes · 5 MiB (5,242,880 bytes) | Shares your TTS audio-minute balance; the quote is based on inspected recording duration, rounded up to whole seconds. |
| Free sample | MP3 · up to 30 seconds · 5 MiB | Web only: one successful sample from the same five-sample TTS/STT allowance per device in a rolling 30-day window. Sign-in and verification are required; capacity limits apply. |
Paid credits are held during the job and charged when a usable transcript is ready. Failed, no-speech or uncertain outcomes release the hold; they are not successful transcripts. If a request is interrupted, check Recent recordings rather than starting another job. Recordings and transcripts are saved to your account. Provider file or duration limits do not increase these FasihTTS beta limits.
The beta provides editable plain text and TXT export. It does not promise a public model selector, speaker diarization, word timestamps, SRT/VTT export, streaming, or hour-long uploads.
Private voice design · Beta
Included with Basic, Pro, and paid Project Packs while paid access is valid. Beta capacity may temporarily limit new designs.
Use your existing FasihTTS account API key in x-api-key, on your server only. No provider key is needed. Design accepts a written description, not audio uploads or cloning. Basic includes 1 design attempt per paid billing cycle, Pro 3 per UTC calendar month, and each valid paid Project Pack 1 additional attempt until its expiry. Every paid option includes 1 saved private voice. Subscription attempts are used before Pack attempts.
GET /v1/voice-design or POST with action: status returns eligible, paidPlan, allowancePeriod, attemptsUsed, attemptsRemaining for the current allowance, availableAttempts including packs, allowanceResetsAt (also returned as the legacy monthResetsAt field), and your voices. Private IDs appear here; the anonymous /v1/voices catalog contains 128 public voice IDs across 16 dialects.
POST https://www.fasihtts.com/v1/voice-design
x-api-key: YOUR_FASIHTTS_API_KEY
Content-Type: application/json
{
"action": "create",
"name": "Calm narrator",
"description": "A warm fictional narrator with a calm pace and clear pronunciation.",
"gender": "male",
"dialect": "ar-msa",
"requestKey": "voice-design-project-001"
}Create requires name (1–60 characters), description (20–1,000 characters), gender (male or female), a supported dialect ID, and requestKey (16–100 ASCII letters, digits, underscores, or hyphens). Persist the key and complete payload before submitting. Retry the same operation only with that same key and identical payload; a new design needs a new key.
Create returns account status plus operationState and operationVoiceId; inspect replayed when present. A 202 response with pending or unknown does not mean failure. After an interrupted request, POST action: operation with the original requestKey to recover { voice } (or null if no operation is recorded). For a pending or unknown voice, use reconcile with its voiceId. Do not create again with a fresh key to resolve an uncertain result.
preview+ voiceId returns previewUrl and expiresIn: 300. Listen before saving.save+ voiceId activates the owned draft, or restores an archived voice only if it is still available from the provider. An active paid plan or valid Project Pack is required.archive+ voiceId makes the voice nonselectable while retaining metadata. Voices unused for 180 days are also archived. Prefer archive when you just want to stop using a voice.delete+ voiceId + confirmation: DELETE permanently removes that exact owned voice. This is irreversible. Wait for in-flight speech jobs to finish before deletion; voice_in_use returns 409.
For speech, pass the returned active custom-<UUID>-2 ID as voice, its explicit dialect, and a stable Idempotency-Key to the generate-tts-v2 endpoint shown above. Follow the same asynchronous job flow. Your existing speech allowance and minute/character accounting are unchanged; design attempts are separate. Archived, unavailable, or unowned voices cannot generate speech.
Errors: 400 invalid input or missing deletion confirmation; 401 authentication required; 403 valid paid access required; 404 voice unavailable or not owned; 409 attempt/capacity limit, changed payload for a reused key, or a voice in use. Temporary provider errors may return 502/503. Keep the original request key and check operation/status before deciding to retry.
Read the beta limits and voice retention detailsGetting Started
Generate an API key from your dashboard before using the API
Once you have an API key, send it in the x-api-key header with every request to the TTS endpoint.
Official API Surface
Paid TTS and STT integrations use REST, not WebSocket. Free samples use the web workflow.
Use the HD endpoint above for new voices and https://api.fasihtts.com for the previous v1 API. The web app is https://www.fasihtts.com. WebSocket TTS endpoints are not currently supported.
Endpoints under faseeh.ai are not official FasihTTS endpoints.
Authenticate on your server with the x-api-key header. Never expose API keys in browser code.
Previous voices: v1 API reference
Available endpoints, parameters, responses, and errors
For eligible legacy accounts and previous voice IDs only. This synchronous endpoint returns HTTP 200 with base64 audio and uses character allowance. HD and private voice IDs return 409 api_upgrade_required: use the asynchronous HD endpoint instead. Legacy aliases do not grant access or bypass retirement.
403 voice_unavailable: this voice is unavailable for your account. Choose an available HD voice from /v1/voices and use generate-tts-v2. A new subscription or upgrade does not grant legacy voice access. Do not retry the unchanged request.
Generate TTS
Endpoint: https://api.fasihtts.com/v1/tts
Method: POST
Content-Type: application/json
Available Endpoints
| Endpoint | Method | Description |
|---|---|---|
/v1/tts | POST | Generate Arabic speech audio |
/v1/voices | GET | List public FasihTTS voices |
/v1/dialects | GET | List supported dialect IDs |
/v1/usage | GET | View authenticated usage and recent usage events |
Request Headers
| Header | Description |
|---|---|
x-api-key | Your API key |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
text | String | Yes | The Arabic text to convert to speech |
voice | String | No | Public FasihTTS voice ID, such as ar-msa-formal-male-1. Legacy aliases such as male1 remain supported for eligible accounts while the voice is available. |
dialect | String | No | Dialect ID, such as ar-msa or ar-sa-najdi. Legacy IDs such as msa still work. |
styleInstruction | String | No | Voice style instruction |
longForm | Boolean | No | Enable sentence-based chunking, retry, and final audio stitching for longer scripts |
Response
| Field | Type | Description |
|---|---|---|
audioContent | String | Base64-encoded audio content |
format | String | Audio container format, currently mp3 or wav |
characters | Number | Number of characters processed |
remaining | Number | Remaining characters after a successful generation |
requestId | String | Support reference ID for this request |
chunks | Number | Number of generated chunks stitched into the returned audio |
Error Reference
| Status | Meaning | Action |
|---|---|---|
| 400 | Missing text or invalid input | Check the request body |
| 401 | Missing or invalid API key | Send a valid x-api-key header |
| 403 | Eligible paid character allowance required or exhausted | Subscribe, upgrade, or contact support |
| 409 | api_upgrade_required | Use generate-tts-v2 for HD or private voices |
| 410 | voice_retired | Choose an available replacement explicitly |
| 503 | Temporarily unavailable | Wait; do not assume an upgrade is needed |
| 500 | Speech generation failed | Keep the request ID; do not blindly retry an uncertain paid request |
Legacy synchronous code examples
Previous voices only. For new integrations use the HD downloads above. Set FASIHTTS_API_KEY privately; never run these examples in a browser.