Text-to-Speech API: Quickstart Guide for Developers

By QK EduVoice editorial team · Updated 2026-11-18

This guide details the QK EduVoice Text-to-Speech API, designed for developers integrating synthetic narration into educational platforms for children. You will find precise technical specifications for generating audio files from text, covering authentication, endpoint structures, and parameter constraints. The documentation explains how to utilize voices based on licensed recordings, with generated files carrying an inaudible watermark that marks them as synthetic speech.

Readers will learn to implement requests using standard HTTP or the OpenAI SDK, with examples for cURL, Python, and JavaScript. Key sections cover rate limits, speed adjustment, and language handling. This resource is intended for engineers building audio content pipelines who need reliable, character-counted billing and clear error handling without enterprise overhead.

Text-to-Speech API: Quickstart Guide for Developers

Frequently asked questions

What is the base URL for the API?

The API base URL is https://api.qk5888.com/v1. The speech endpoint is POST https://api.qk5888.com/v1/audio/speech. Other endpoints include GET /v1/voices and GET /v1/models.

Which SDKs are compatible with this API?

The API accepts the same request shape as the OpenAI speech endpoint. Official OpenAI SDKs work by changing the base_url to https://api.qk5888.com/v1. We do not provide an official SDK of our own. You can also use plain HTTP requests.

How do I set the voice parameter?

Set the voice parameter to one of eight presets. Female voices include aria, nova, luna, and sage. Male voices include felix, milo, atlas, and orion. You can retrieve the full list of available voices using the GET /v1/voices endpoint.

Can I use the OpenAI Python SDK?

Yes, the OpenAI Python SDK is compatible. Configure the base_url to https://api.qk5888.com/v1 and use your QK EduVoice key. The request shape matches the OpenAI speech endpoint, allowing seamless integration with existing OpenAI SDK workflows.

What is the maximum input length?

The maximum input length is 4096 characters per request. Spaces and punctuation count toward this limit. For texts exceeding this length, split the text into parts of up to 4096 characters and join the resulting audio files.

How do I handle rate limits?

Rate limits are 60 requests per minute per key. Before the first top-up, the limit is 10 requests per minute. Requests are processed sequentially, so under load, a request may wait in a queue. Monitor your usage to avoid delays.

Is the API RESTful?

It uses standard HTTP methods like POST for speech generation and GET for retrieving voices and models. Requests are sent as JSON bodies, and responses contain the generated audio or metadata in standard formats.

Can I specify the output format?

Yes, set the response_format field to mp3, wav, opus, flac, or pcm. This allows you to choose the audio format that best suits your application. The generated audio is returned directly in the API response.

How does language detection work?

If the language field is not set, it is guessed from the script. Latin text defaults to English. For non-English Latin-script text, you must explicitly set the language parameter. Supported languages include Arabic, Chinese, English, and others listed in the docs.

What happens if the text is too long?

Split the text into parts of up to 4096 characters. Send each part to the API and join the resulting audio files. This ensures that all content is processed, as each request is limited to 4096 characters.

Is JSON the only request body format?

It includes fields like model, input, voice, response_format, and speed. The API expects a standard JSON object containing these parameters for text-to-speech synthesis.

How do I authenticate my requests?

Include the Authorization header with your Bearer token. The format is Authorization: Bearer tts-... . Each account has one active key. You can issue a new key at any time, which stops the old one immediately.

Can I rotate my API key?

Yes, you can issue a new API key at any time. When a new key is issued, the old one stops working immediately. This allows you to rotate keys without downtime, ensuring secure access to the API.

Are there any latency guarantees?

No, there are no latency guarantees. Requests are processed sequentially, so under load, a request may wait in a queue. Typical speed is roughly real time for long texts, but short phrases may take a few seconds.

First request

curl

curl https://api.qk5888.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.qk5888.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.qk5888.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 authentication via a Bearer token included in the Authorization header. You obtain this key by signing in on the /get-api-key/ page using Google or email. Each account holds one active key at a time.

API Key Generation

API Key Generation

Keys are generated exclusively on the /get-api-key/ dashboard. Accounts created with email and password start without trial credit, while Google sign-ins receive a $0.50 trial valid for 7 days. The dashboard displays your current key, balance, and usage statistics.

Bearer Token Usage

Bearer Token Usage

Include your key as Authorization: Bearer tts-... in every request header. The token authenticates all API calls, including speech generation and voice listing. Ensure the key is transmitted securely over HTTPS.

Key Rotation

You can issue a new key at any time via the dashboard. When a new key is generated, the previous one becomes inactive immediately. This allows seamless rotation without downtime for your applications.

Endpoints Overview

Sound wave illustration for: Endpoints Overview

The API exposes three primary endpoints to manage audio synthesis and configuration. The Speech Generation endpoint accepts POST requests to convert text into audio files, while the Voices List and Models endpoints provide metadata for integration.

Speech Generation Endpoint

Send text to POST https://api.qk5888.com/v1/audio/speech to receive an audio file. The request body follows the OpenAI speech endpoint schema, allowing direct use of official OpenAI SDKs by adjusting the base_url.

Voices List Endpoint

Access GET /v1/voices to retrieve available voice presets, supported languages, and format options. This endpoint confirms that any of the eight voices can speak any of the 23 supported languages.

  • Returns voice ID, name, and language capabilities.

Models Endpoint

Query GET /v1/models to verify available model identifiers. The API supports "tts-1" and "tts-1-hd", which share the same engine and pricing structure.

Request Parameters

Sound wave illustration for: Request Parameters

Configure your API requests by selecting a model and voice preset that match the narrative style of your educational content. The API accepts specific parameters to control audio generation, ensuring the output aligns with your pedagogical goals.

Model Selection

Choose between "tts-1" and "tts-1-hd" for synthesis. Both models use the same engine and pricing structure, allowing you to switch based on quality needs without affecting cost calculations.

Voice Presets

Select one of eight licensed voice presets tailored for clear narration. Female voices include aria, nova, luna, and sage; male voices include felix, milo, atlas, and orion. Each voice supports all 23 available languages, enabling consistent storytelling across different educational materials.

  • aria: warm, clear narrator
  • nova: bright, upbeat
  • luna: soft, storytelling
  • sage: calm, instructional
  • felix: energetic, promo
  • milo: friendly, conversational
  • atlas: neutral, news
  • orion: deep, documentary

Input Text Limits

Each request supports a maximum of 4096 characters in the input field. For longer fairy tales or stories, split the text into chunks of this size and join the resulting audio files. Spaces and punctuation count toward the character limit.

Response Formats

Sound wave illustration for: Response Formats

The API returns synthesized audio in the format specified by the response_format parameter. Supported formats include MP3, WAV, Opus, FLAC, and PCM, allowing flexibility for different playback environments and storage requirements.

MP3 Output

MP3 is the default format. It provides a compressed audio file suitable for most web players and mobile applications, balancing file size and quality for children's content distribution.

WAV Output

WAV delivers uncompressed audio, preserving the full fidelity of the generated speech. This format is ideal for high-quality archival, editing in classroom audio tools, or direct playback on devices requiring lossless audio.

Other Formats

Opus, FLAC, and PCM are also available. Opus and FLAC are available formats. Opus offers efficient compression, while FLAC provides lossless compression. PCM returns raw audio data.

  • Opus: Efficient compression for streaming
  • FLAC: Lossless compression
  • PCM: Raw audio data

Speed and Language

Sound wave illustration for: Speed and Language

The API accepts a speed parameter ranging from 0.25 to 4.0, allowing you to adjust narration pace relative to the default. This ensures the audio fits specific educational contexts, from slow storytelling for young children to faster reading for older students.

Speed Adjustment Range

Adjustable between 0.25 and 4.0, this parameter scales the generation speed. Use lower values for clear, deliberate articulation in educational materials and higher values for quicker content delivery.

Language Code Setting

Explicitly define the language field using an ISO code (e.g., en, de, fr) to ensure accurate pronunciation. This is critical when the text script does not clearly indicate the language, such as Latin-script text that is not English.

  • Supported languages: Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, Turkish.

Auto-Detection

If the language field is omitted, the system guesses the language based on the text script. Latin script defaults to English; other scripts trigger their respective language models. Explicitly setting the language is recommended to avoid mispronunciation.

Speed and Language

Error Handling

Sound wave illustration for: Error Handling

Error handling ensures reliable integration for educational audio workflows. The API returns standard HTTP status codes to indicate success or failure, allowing developers to implement robust retry logic for transient issues without losing progress on story generation tasks.

Common Error Codes

The API uses standard HTTP status codes. A 200 OK response indicates successful synthesis. A 4xx error indicates a client-side issue, such as an invalid API key or malformed request body. A 5xx error indicates a temporary server issue.

  • 401 Unauthorized: Invalid or expired API key.
  • 400 Bad Request: Missing required fields or invalid JSON.
  • 429 Too Many Requests: Rate limit exceeded (see Rate Limits section).
  • 500 Internal Server Error: Temporary service issue.

Rate Limit Errors

Each API key is limited to 60 requests per minute. New accounts start with a 10 requests per minute limit until the first top-up is processed. Exceeding this limit returns a 429 status code. Requests are processed sequentially, so under load a request may wait in a queue.

Input Validation

The input text field accepts up to 4096 characters per request. If the text exceeds this limit, the API returns a 400 error. Spaces and punctuation count towards the character limit. Ensure that the text is properly encoded as UTF-8. If the input is empty or null, a 400 error is returned.

  • Maximum input length: 4096 characters.
  • Spaces and punctuation count as characters.
  • UTF-8 encoding required.

Code Examples

Sound wave illustration for: Code Examples

Generate audio files programmatically using standard HTTP requests or compatible SDKs. The API accepts JSON payloads and returns binary audio data directly in the response body.

Below are minimal examples for common environments. All requests require a valid Bearer token and adhere to the 4096-character input limit per call.

cURL Request

Use cURL to send a POST request to the speech endpoint. Replace YOUR_API_KEY with your credential and specify the voice, model, and input text.

```bash curl -X POST "https://api.qk5888.com/v1/audio/speech" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "tts-1", "voice": "nova", "input": "Once upon a time, there was a little bear.", "response_format": "mp3"}' \ -o output.mp3 ```

Python with OpenAI SDK

Configure the OpenAI SDK to point to our base URL. This allows you to use the same Audio client interface for generating speech files.

```python import openai client = openai.OpenAI(api_key="YOUR_API_KEY", base_url="https://api.qk5888.com/v1") with client.audio.speech.create( model="tts-1", voice="sage", input="The quick brown fox jumps over the lazy dog." ) as response: response.stream_to_file("output.mp3") ```

JavaScript Example

Fetch the audio data as a blob and save it locally. Ensure your environment handles binary data correctly.

```javascript const response = await fetch("https://api.qk5888.com/v1/audio/speech", { method: "POST", headers: { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" }, body: JSON.stringify({ model: "tts-1", voice: "luna", input: "Once upon a time..." }) }); const blob = await response.blob(); ```

Rate Limits

Sound wave illustration for: Rate Limits

The API enforces a standard limit of 60 requests per minute for verified accounts, ensuring stable processing for batch generation tasks. This capacity is sufficient for most educational content workflows when texts are split into 4,096-character segments.

Requests Per Minute

Accounts with active balance are limited to 60 requests per minute per API key. This limit applies to the total number of synthesis attempts, regardless of text length or format.

Pre-Top-Up Limit

New accounts without a top-up are restricted to 10 requests per minute. This lower threshold applies to accounts without a top-up. The free trial provides $0.50 credit valid for 7 days.

  • Standard limit: 60 requests/minute
  • Trial limit: 10 requests/minute
  • Limit resets every 60 seconds

Queuing Behavior

Requests are processed sequentially. If the limit is reached, subsequent requests wait in a queue. Processing time is roughly real-time, averaging 25 characters per second of audio generated.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Engage young learners by weaving traditional motifs into interactive read-aloud sessions for deeper comprehension.

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. LibriTTS-R corpus (OpenSLR 141)
  3. ISO 639 language codes
  4. MDN: Web Speech API
  5. Creative Commons Attribution 4.0
  6. openai-python on GitHub
  7. LibriVox public-domain audiobooks
  8. FFmpeg documentation
  9. Node.js documentation
  10. openai-node on GitHub
  11. Tether (USDT)
  12. LibriTTS-R paper (arXiv 2305.18802)

More on this site