Integrate the FasihTTS Arabic TTS REST API

A server-side integration path covering authentication, voice IDs, base64 audio, errors, and safe retries.

Minimal request

Create an API key from the dashboard and call the API from trusted server code. Never embed the key in a public browser bundle.

curl -X POST https://api.fasihtts.com/v1/tts \
  -H "content-type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "text": "مرحبًا بكم في فصيح",
    "dialect": "ar-msa",
    "voice": "ar-msa-formal-male-1"
  }'

Handle the response

A successful JSON response includes audioContent as base64 and a format such as mp3 or wav. Decode it on the server, store it with the matching extension and MIME type, and return a short-lived URL to your client when possible.

Validate before sending

  • Use /v1/dialects and /v1/voices as the public catalog instead of inventing IDs.
  • Confirm that the selected voice belongs to the selected dialect.
  • Reject empty text and enforce your own product-level length limits before the API call.

Retries and usage

Retry only transient failures, use a bounded backoff, and avoid parallel retries for the same user action. FasihTTS records successful generation usage; failed generation attempts do not reduce the character balance. Keep the returned request reference in your logs for support.

Try FasihTTS