Text-to-Speech API: Integration Guide for Developers

By EchoGrid editorial team · Updated 2026-11-18

This guide helps product teams integrate EchoGrid’s text-to-speech API into app notifications, onboarding flows, and interface feedback. You will learn to generate audio files using simple cURL commands or the OpenAI SDK, with clear steps for authentication, parameter configuration, and error handling.

Designed for developers who need reliable, predictable audio without enterprise bloat, this page covers practical workflows. You will find exact endpoint URLs, rate limits, and voice selection details to ensure smooth integration into your existing infrastructure.

Text-to-Speech API: Integration Guide for Developers

Frequently asked questions

What is the API endpoint?

Send your request to POST https://api.666xapk.com/v1/audio/speech. The endpoint accepts a JSON body containing your text, voice selection, and format preferences. This endpoint is the core of the service, allowing you to convert text into audio files efficiently.

How do I authenticate?

Include an Authorization header with your Bearer token: Authorization: Bearer tts-.... Each account has one active key. You can generate a new key at any time, which immediately invalidates the previous one, ensuring secure access to your API resources.

Which models are available?

Two models are available: tts-1 and tts-1-hd. Both use the same engine and pricing structure. Select the model that fits your quality needs, knowing that both models use the same engine.

How do I specify a voice?

Include the voice field in your JSON body with one of eight presets: aria, nova, luna, sage, felix, milo, atlas, or orion. Each voice has a distinct tone, from warm narrators to energetic promos.

What input formats are supported?

The API accepts plain text input via the input field. There is no support for SSML, phoneme dictionaries, or custom pronunciation lexicons. You provide the raw text string, and the system handles the synthesis without requiring additional markup or formatting structures.

How do I handle errors?

If synthesis fails, the charge is returned in full. You should check the HTTP status code and response body for details. Failed requests do not consume your character balance, ensuring you are not billed for unsuccessful audio generation attempts during your integration.

Can I use the OpenAI SDK?

Yes, the official OpenAI SDKs work by changing the base_url to https://api.666xapk.com/v1. Use your site's key for authentication. This allows you to leverage familiar SDK methods while connecting to our TTS endpoint, simplifying integration for developers already using OpenAI tools.

How do I set the language?

Use the optional language field with an ISO code. If omitted, the system guesses the language, defaulting to English for Latin script. For non-English Latin text, explicitly set the language to ensure accurate synthesis, as any voice can speak any of the 23 supported languages.

What is the maximum character limit?

Each request supports up to 4096 characters in the input field. Spaces and punctuation count toward this limit. If your text exceeds this length, you must split it into multiple requests and join the resulting audio files for a complete output.

How do I process long texts?

Split your text into chunks of up to 4096 characters. Send each chunk as a separate request and join the returned audio files. This approach ensures reliable synthesis for longer content, such as onboarding flows or detailed interface feedback, without hitting character limits.

What audio formats are returned?

You can choose from mp3, wav, opus, flac, or pcm via the response_format field. Each generated file includes an inaudible watermark marking it as synthetic speech. Select the format that suits your app's audio processing pipeline and storage requirements.

How do I handle rate limits?

The limit is 60 requests per minute per key, or 10 per minute before the first top-up. Requests are processed sequentially, so under load, they may queue. Monitor your usage to avoid delays, especially during high-volume notification bursts or batch processing tasks.

Is streaming supported?

No, streaming, WebSocket, or real-time partial audio is not supported. The API returns the complete audio file after synthesis. This design ensures reliable, complete audio chunks for your app notifications and interfaces, without the complexity of managing partial stream data.

How do I rotate my API key?

Issue a new key from your account dashboard. The new key becomes active immediately, and the old one stops working at once. This allows seamless rotation without downtime, ensuring your integrations continue to function smoothly while maintaining security for your TTS API access.

First request

curl

curl https://api.666xapk.com/v1/audio/speech \
  -H "Authorization: Bearer $TTS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"tts-1","voice":"aria","input":"Hello from the API.","response_format":"mp3"}' \
  --output hello.mp3

Python (openai)

from openai import OpenAI

client = OpenAI(base_url="https://api.666xapk.com/v1", api_key="tts-...")

with client.audio.speech.with_streaming_response.create(
    model="tts-1", voice="nova", input="Hello from Python.", response_format="mp3"
) as response:
    response.stream_to_file("hello.mp3")

Node.js (openai)

import OpenAI from "openai";
import fs from "node:fs";

const client = new OpenAI({ baseURL: "https://api.666xapk.com/v1", apiKey: process.env.TTS_API_KEY });
const res = await client.audio.speech.create({ model: "tts-1", voice: "milo", input: "Hello from Node.js." });
fs.writeFileSync("hello.mp3", Buffer.from(await res.arrayBuffer()));
voice
ariafemale
novafemale
lunafemale
sagefemale
felixmale
milomale
atlasmale
orionmale
language
arالعربية
zh中文
daDansk
nlNederlands
enEnglish
fiSuomi
frFrançais
deDeutsch
elΕλληνικά
heעברית
hiहिन्दी
itItaliano
ja日本語
ko한국어
msBahasa Melayu
noNorsk
plPolski
ptPortuguês
ruРусский
esEspañol
swKiswahili
svSvenska
trTürkçe

Authentication

Sound wave illustration for: Authentication

The API requires a bearer token for all requests. Your unique key, formatted as tts-..., authenticates your account and tracks usage against your balance.

API Key Format

API Key Format

Keys begin with the prefix tts- followed by alphanumeric characters. This string is your sole credential for accessing the endpoint.

Header Configuration

Header Configuration

Include the header Authorization: Bearer tts-<your_key> in every request. The OpenAI SDKs work by setting the base_url to https://api.666xapk.com/v1 and passing this key as the API key.

  • Header: Authorization: Bearer tts-...
  • Base URL: https://api.666xapk.com/v1

Key Rotation

Each account holds one active key. Generating a new key immediately invalidates the old one, ensuring only one valid token exists at a time.

Endpoint

Sound wave illustration for: Endpoint

The API exposes three primary endpoints for generating audio and managing resources. Each endpoint follows a standard RESTful structure under the base URL https://api.666xapk.com/v1. Developers interact with these endpoints to retrieve configuration details and generate speech files.

All requests require authentication via the Authorization: Bearer header. The endpoints handle JSON payloads and return audio data or metadata, enabling straightforward integration into backend services or frontend applications without complex protocol overhead.

Speech Endpoint

Use POST /v1/audio/speech to convert text into audio. Send a JSON body containing the model, voice, input text, and format. The API returns the generated audio file directly in the response.

This is the core endpoint for production usage. Ensure your input text respects the 4096 character limit per request. For longer texts, split the input and concatenate the resulting audio files.

  • Method: POST
  • Path: /v1/audio/speech
  • Input: JSON body with model, voice, input, response_format

Voices Endpoint

Call GET /v1/voices to retrieve the list of available voices, their associated languages, supported formats, and pricing details. This endpoint helps you select the appropriate voice preset for your application's tone.

The response includes metadata for all 8 presets, such as aria, nova, and atlas. Use this data to dynamically populate voice selection menus in your UI before making speech requests.

  • Method: GET
  • Path: /v1/voices
  • Returns: List of voices with metadata

Models Endpoint

Use GET /v1/models to fetch the available model identifiers. Currently, the API supports tts-1 and tts-1-hd, which share the same engine and pricing structure.

This endpoint allows you to verify model availability programmatically. It returns a list of model objects, ensuring your integration can handle potential future model updates gracefully without hardcoding values.

  • Method: GET
  • Path: /v1/models
  • Returns: List of model IDs

Request Parameters

Sound wave illustration for: Request Parameters

Configure the request body with the required parameters to synthesize audio. The model parameter selects the engine, while voice determines the speaker's tone. You must also provide the input text and specify the desired response_format.

Model Selection

Use tts-1 for standard quality or tts-1-hd for high-definition audio. Both models use the same engine and incur identical pricing per character, allowing you to choose based on your audio quality needs without cost penalty.

Voice Selection

Select from eight presets such as aria, nova, or atlas. Each voice is designed for specific contexts, from warm narration to neutral news delivery. You can also optionally specify a language ISO code to guide the synthesis engine.

  • Female: aria, nova, luna, sage
  • Male: felix, milo, atlas, orion

Input Text

Provide your script in the input field, limited to 4,096 characters per request. Spaces and punctuation count toward this limit. For longer content, split the text into chunks and join the resulting audio files sequentially.

Response Format

Sound wave illustration for: Response Format

The API returns the generated audio file directly in the response body, eliminating the need for polling or secondary download requests. Supported formats include mp3, wav, opus, flac, and pcm, allowing seamless integration into various media players and application interfaces without additional conversion steps.

Every generated file carries an inaudible watermark that marks it as synthetic speech, providing a clear indicator of origin for compliance or transparency purposes.

Audio File

The response body contains the raw audio data in the format you specified via the response_format parameter. You can save this directly to a file or play it locally. The file size varies by format and duration, but the encoding is standard and widely supported.

Error Responses

If synthesis fails (e.g., invalid input or server error), the API returns an error object with a clear message. Failed requests are free, so you are not charged for characters processed during a failed attempt. Always check the response body to diagnose issues quickly.

  • Check the message field for specific failure reasons like character limit exceeded or invalid voice ID.

Status Codes

The HTTP status code indicates the result of the request. A 200 OK means the audio was generated successfully. Use 4xx codes for client errors (like bad keys) and 5xx for server issues. Always handle non-200 responses gracefully in your application logic to prevent crashes.

Code Examples

Sound wave illustration for: Code Examples

This section demonstrates how to integrate the TTS API using standard tools. You can use simple cURL commands or the OpenAI Python SDK by adjusting the base URL.

All examples use the tts-1 model. Replace YOUR_API_KEY with your key from the dashboard.

cURL Example

Use this command to generate speech. Replace the placeholder key and text.

The response returns an audio file directly to your terminal or a file.

  • curl -X POST https://api.666xapk.com/v1/audio/speech
  • -H "Authorization: Bearer YOUR_API_KEY"
  • `-d '{"model": "tts-1", "input": "Hello world", "voice": "nova"}'`

OpenAI SDK

Install the OpenAI Python package. Set the API key and base URL to point to our endpoint.

Call the audio.speech.create method with your parameters. The API handles the request format.

  • import openai
  • client = openai.OpenAI(api_key='YOUR_API_KEY', base_url='https://api.666xapk.com/v1')
  • speech = client.audio.speech.create(model='tts-1', voice='nova', input='Hello world')

Python Example

The Python SDK returns the audio data. Save this stream to a file or play it directly.

You can adjust speed and format using additional parameters in the request body.

  • speech.stream_to_file('output.mp3')
  • # Supports mp3, wav, opus, flac, pcm
  • # Speed range: 0.25 to 4.0
Code Examples

Languages

Sound wave illustration for: Languages

The API automatically detects the language from the text script, defaulting to English for Latin characters. For non-English Latin text, explicitly setting the language ensures accurate synthesis.

Supported languages include Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, and Turkish. Any voice can speak any of these languages.

Auto-Detection

The system infers the language from the input text script. If the text uses Latin script and no language is specified, it defaults to English. This simplifies integration for single-language apps but requires caution for mixed-script inputs.

Explicit Language

Set the language parameter with an ISO code to override detection. This is essential for non-English Latin-script text to ensure the correct voice pronunciation and intonation are applied.

Unsupported Languages

Vietnamese, Indonesian, Thai, Ukrainian, Romanian, Czech, Bengali, and other languages not listed are not supported. The API may not synthesize these texts accurately.

There is no custom voice cloning or phoneme dictionary to manually correct pronunciation for unsupported languages.

  • Vietnamese
  • Indonesian
  • Thai
  • Ukrainian
  • Romanian
  • Czech
  • Bengali

Limits

Sound wave illustration for: Limits

Understand the operational constraints to ensure smooth integration. Our API enforces specific limits on request frequency, input length, and playback speed to maintain consistent synthesis quality for your product notifications and interface feedback.

Knowing these boundaries helps you design robust retry logic and input validation. We recommend handling rate limits gracefully by implementing exponential backoff in your application logic.

Rate Limiting

You are allowed 60 requests per minute per API key. Before your first top-up, this limit is lower at 10 requests per minute. If you exceed the limit, the API returns a 429 error. Failed requests are free of charge.

  • Standard limit: 60 requests/minute
  • Pre-top-up limit: 10 requests/minute
  • Failed requests are free and do not count toward the limit

Character Limit

Each request supports up to 4,096 characters of input text. Spaces and punctuation count toward this total. For longer texts, split the content into chunks of 4,096 characters or less and join the resulting audio files on the client side. This approach ensures reliable processing and predictable generation times.

  • Maximum input: 4,096 characters per request
  • Includes spaces and punctuation
  • Split long texts manually or via your app logic

Speed Range

The speed parameter accepts values from 0.25 to 4.0. The default speed is 1.0. Adjusting the speed allows you to tailor the voice for different contexts, such as slower narration for onboarding flows or faster delivery for brief interface alerts. Values outside this range will result in an error.

  • Acceptable range: 0.25 to 4.0
  • Default speed: 1.0
  • Adjustable per request

Troubleshooting

Sound wave illustration for: Troubleshooting

Integration issues usually stem from authentication headers, character limits, or transient network conditions. Verify your API key format and ensure input text does not exceed 4,096 characters per request.

Common Errors

Ensure the Authorization header uses the exact Bearer tts-... format. Invalid keys return 401 errors. If synthesis fails mid-process, the charge is returned in full, so no credit is lost for failed requests.

  • Check that input is under 4,096 characters.
  • Verify model is either tts-1 or tts-1-hd.
  • Confirm voice matches one of the 8 presets.

Timeout Handling

Short phrases may take a few seconds to generate. If your client times out too quickly, increase the timeout value. Long texts are processed sequentially, so expect longer durations for larger inputs.

Queue Waits

Requests are processed one after another. Under load, a request may wait in a queue before generation begins. This is normal behavior and does not indicate a service failure. Plan for slight delays during peak usage.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Clear notifications guide product teams toward smarter decisions without overwhelming daily workflows.

Avatar of the voice aria
ariafemale
Avatar of the voice nova
novafemale
Avatar of the voice luna
lunafemale
Avatar of the voice sage
sagefemale
Avatar of the voice felix
felixmale
Avatar of the voice milo
milomale
Avatar of the voice atlas
atlasmale
Avatar of the voice orion
orionmale

23 languages

Any voice speaks any of these languages.

Sources and further reading

  1. Wikipedia
  2. W3C WAI: making audio and video accessible
  3. openai-python on GitHub
  4. TRON developer hub: TRC-20
  5. MDN: Web Speech API
  6. openai-node on GitHub
  7. OpenAI API reference: create speech
  8. Node.js documentation
  9. LibriTTS-R corpus (OpenSLR 141)
  10. LibriVox public-domain audiobooks
  11. curl documentation
  12. Tether (USDT)

More on this site