REST API

Text to Speech API

Add natural-sounding AI voices to your applications with our simple REST API. 17 voices, low latency, flexible pricing. Get started in minutes.

REST API on Pro from $4.99/mo • Web playground free, no credit card

New to voiceovers? See how to create text-to-speech audio in the web app first, then integrate with the API.

API Features

RESTful API

Simple HTTP endpoints that work with any programming language or platform.

17 AI Voices

Access all voices via API - American, British, and Australian accents.

Low Latency

Fast response times optimized for real-time applications.

High Quality

Neural TTS powered by Google Cloud for natural-sounding output.

Flexible Output

JSON responses include base64-encoded MP3 ready to decode or save to disk.

Usage Tracking

Monitor your character usage and API calls in real-time.

API Documentation

Simple REST endpoints to generate speech from text. Works with any language or framework.

POST/api/tts

Generate speech from text

Request Body

{
  "text": string,     // Required. Text to convert (max 5000 characters per request)
  "voice": string,    // Required. Voice ID (e.g., "af_heart")
  "speed": number     // Optional. Speed multiplier (0.5-2.0, default 1.0)
}

Response

{
  "success": true,
  "audio": string,      // Base64-encoded audio data
  "format": "mp3",      // Audio format
  "voice": "af_heart",  // Voice used
  "characters": 13      // Characters processed
}

Available Voice IDs

af_heartaf_bellaaf_sarahaf_nicoleaf_emilyam_adamam_michaelam_jamesam_thomasbf_emmabf_isabellabm_georgebm_lewisaus_sophiaaus_graceaus_jackaus_oliver
GET/api/voices

List all available voices

{
  "voices": [
    {
      "id": "af_heart",
      "name": "Heart",
      "gender": "female",
      "accent": "American",
      "style": "warm"
    },
    // ... more voices
  ]
}

Code Examples

$ cURL
curl -X POST https://speaklucid.com/api/tts \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "text": "Hello, world!",
    "voice": "af_heart",
    "speed": 1.0
  }'
JS JavaScript / Node.js
const response = await fetch('https://speaklucid.com/api/tts', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY',
  },
  body: JSON.stringify({
    text: 'Hello, world!',
    voice: 'af_heart',
    speed: 1.0
  })
});

const { audio, format } = await response.json();
// audio is base64-encoded MP3
Python
import requests
import base64

response = requests.post(
    'https://speaklucid.com/api/tts',
    headers={'Authorization': 'Bearer YOUR_API_KEY'},
    json={
        'text': 'Hello, world!',
        'voice': 'af_heart',
        'speed': 1.0
    }
)

data = response.json()
audio_bytes = base64.b64decode(data['audio'])

with open('output.mp3', 'wb') as f:
    f.write(audio_bytes)

HTTP Status Codes & Errors

Every response uses standard HTTP semantics. Handle these codes in your integration to build reliable applications.

200OK

Synthesis succeeded. Response body: { success, audio, format, voice, characters }.

400Bad Request

Missing or invalid parameter. Common causes: text omitted, voice ID unrecognized, text exceeds 5,000 characters, speed outside 0.5–2.0.

401Unauthorized

Missing or invalid API key. Include Authorization: Bearer YOUR_API_KEY or X-API-Key: YOUR_API_KEY in every request.

403Forbidden

REST API access requires a Pro or Business plan. Use the web playground on Free and Starter, or upgrade at /pricing.

429Too Many Requests

Character budget exhausted for the current period. Response body includes upgradeUrl. Upgrade your plan or wait for quota reset.

503Service Unavailable

TTS backend not reachable. Retry with exponential back-off. Contact support if the issue persists.

Authentication

Programmatic access to /api/tts requires a Pro or Business plan API key:

  • Authorization: Bearer YOUR_API_KEY — from Dashboard (Pro+)
  • X-API-Key: YOUR_API_KEY — alternative header

Free and Starter plans use the web playground only. Keep API keys server-side — never expose them in client-side JavaScript or public repositories.

How SpeakLucid Compares

See how the SpeakLucid text to speech API stacks up against ElevenLabs, Google Cloud TTS, Amazon Polly, and others on pricing, voice quality, and simplicity.

Not using the API? Try the free text to speech tool in the browser — no code required.

Text to Speech API – Frequently Asked Questions

How do I authenticate with the SpeakLucid TTS API?

REST API access requires a Pro or Business plan. Create an API key in your Dashboard, then send Authorization: Bearer YOUR_API_KEY or X-API-Key on every POST /api/tts request. Signed-in users on any plan can use the web playground; guests can try up to 1,000 characters in the browser without an API client.

What does the free text to speech API tier include?

The Free plan does not include REST API access — use the web playground instead. Upgrade to Pro for API keys, 5,000 requests/hour, and 300,000 characters/month. See Pricing for current limits.

What is the maximum text length per API request?

Each request can include up to 5,000 characters of input text (aligned with Google Cloud TTS limits). Split longer scripts into multiple requests.

What HTTP status codes and errors does the API return?

Successful synthesis returns 200 with JSON { success, audio, format, voice, characters }. 400 means bad input (missing text, unknown voice, text too long, speed outside 0.5–2.0). 429 means your account exceeded its character budget for the current period—see upgradeUrl in the response. 503 usually means TTS credentials are not configured on the server.

Can I call the API from the browser (CORS)?

The API responds to OPTIONS with CORS headers for simple integrations. For production, prefer calling the API from your backend so your app secrets and session handling stay server-side, then stream or deliver audio to clients.

What audio format does the API return?

Successful responses include base64-encoded MP3 in the audio field, plus format: "mp3". Decode base64 to bytes and write a .mp3 file or pipe to a player. The web app uses the same synthesis path.

What programming languages does the TTS API support?

Any language that can send HTTPS POST with JSON works. We document cURL, JavaScript (fetch), and Python (requests); the same contract applies to PHP, Go, Ruby, etc.

How fast is the text to speech API?

Most requests complete in a few seconds depending on length. Latency includes neural synthesis; keep requests reasonably sized for responsive UX.

What happens if I pick an invalid voice ID?

The API returns 400 with a message listing valid voice IDs. Use GET /api/voices to retrieve names, accents, and IDs before generating.

Does the API support SSML or custom pronunciation?

The documented contract uses plain text plus voice and speed. For advanced SSML or custom lexicons, contact us about enterprise workflows.

Get more free characters & tips

Create a free account for 5,000 chars/month and stay updated on new voices.

API Pricing

Start free in the web playground. Upgrade to Pro for REST API access.

Free

$0

Web only requests

1,250/week chars

Starter

$1.99/mo

Web only requests

100,000/month chars

Pro

$4.99/mo

5,000/hour requests

300,000/month chars

Business

$14.99/mo

10,000/hour requests

1,000,000/month chars

Ready to integrate TTS into your app?

Upgrade to Pro for REST API access — 300,000 characters/month and 5,000 requests/hour.