Cloud Text-to-Speech API: Generate Audio from Text

By SpeakNode editorial team · Updated 2026-11-19

This documentation outlines the integration steps for the SpeakNode text-to-speech API, designed specifically for indie developers building applications and games. You will find precise details on authentication, request parameters, and response formats to ensure smooth implementation without unnecessary complexity.

We cover essential workflows including rate limits, error handling, and SDK usage for Python and JavaScript using the official OpenAI SDKs. By the end of this guide, you will know exactly how to generate audio files, manage your API key, and handle common edge cases like character limits and language detection.

Cloud Text-to-Speech API: Generate Audio from Text

Frequently asked questions

How do I get my API key?

Sign up on /get-api-key/ using Google or email. Your key appears on the dashboard alongside your balance and usage stats. You can regenerate it anytime; the old key stops immediately. This key authenticates your requests via the Authorization header.

What is the base URL for the OpenAI SDK?

Set your SDK base URL to https://api.qq221.info/v1. The request shape matches the OpenAI speech endpoint exactly. This allows you to use standard OpenAI SDKs by simply pointing them to our API domain instead of OpenAI’s servers.

Does the API support streaming audio?

No, the API does not support streaming, WebSocket, or real-time partial audio. You send a POST request and receive the complete audio file in the response. For long texts, split the input into chunks and join the resulting files.

Can I use the Python OpenAI SDK with this API?

Yes, the official OpenAI SDKs work by changing the base_url to https://api.qq221.info/v1. Use the standard speech endpoint with your SpeakNode key. This provides a familiar integration path for developers already accustomed to the OpenAI Python library structure.

What is the maximum speed setting for audio?

The speed parameter accepts values between 0.25 and 4.0. This allows you to slow down narration or speed up dialogue. Adjust this setting to match your content’s pacing requirements.

How do I handle rate limit errors?

You have a limit of 60 requests per minute per key (10 before top-up). If you exceed this, requests queue or fail. Implement exponential backoff in your code. Monitor your usage dashboard to track consumption and avoid hitting limits during bursts.

Is the API key reusable across different projects?

Yes, one active key per account works across all your projects. You can issue a new key anytime, which invalidates the old one immediately. This simplifies management for indie developers running multiple apps or games with a single authentication credential.

Does the API support WebSocket connections?

No, there are no WebSocket connections for real-time audio. The API is a standard REST endpoint. You send text via POST and receive the audio file directly. This synchronous model is simpler for batch processing and game asset generation.

What happens if I exceed the character limit?

Each request supports up to 4096 characters. If your text is longer, split it into parts. Generate audio for each part and join the files. This ensures all your content is synthesized without truncation or errors from oversized payloads.

Can I customize the audio format in the request?

Yes, specify response_format as mp3, wav, opus, flac, or pcm. This gives you control over file size and compatibility. Choose formats suitable for your platform, such as mp3 for web or wav for desktop applications, directly in the JSON body.

Is there a limit to the number of voices I can use?

No, you can use all 8 voices (aria, nova, luna, sage, felix, milo, atlas, orion) in your requests. Switch voices per request or per text segment. Each voice supports all 23 languages, allowing diverse narration styles within a single project.

Do I need to install any specific libraries?

No specific library is required. You can use plain HTTP or the official OpenAI SDKs. For Python, install the standard openai package. For other languages, use your preferred HTTP client to send POST requests to the speech endpoint with your key.

How do I regenerate my API key?

Go to the /get-api-key/ dashboard page. Issue a new key at any time. The previous key stops working immediately. This is useful for security or if you rotate credentials between development and production environments without downtime.

Does the API support asynchronous requests?

The API processes requests synchronously but queues them under load. You receive the audio file once generation is complete. There is no separate async endpoint. For long texts, split them manually and join the results to manage processing time effectively.

First request

curl

curl https://api.qq221.info/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.qq221.info/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.qq221.info/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

SpeakNode uses a single active API key for authentication, issued upon account creation. The key follows the format tts- followed by alphanumeric characters and must be kept secure.

All requests require the key in the Authorization header to validate access and track usage against your balance.

API Key Format

API Key Format

Your API key is a string starting with tts- and containing random alphanumeric characters. It is generated uniquely for your account and serves as the sole credential for all API interactions.

Bearer Token Header

Bearer Token Header

Include your key in the HTTP header as Authorization: Bearer tts-<your-key>. This standard Bearer token format ensures compatibility with OpenAI SDKs and standard HTTP clients.

Ensure the header is correctly formatted to avoid 401 Unauthorized errors. The key is case-sensitive and must not include extra spaces.

Key Management

Key Management

You have one active key per account. If compromised, you can issue a new key via the dashboard; the old key stops working immediately.

Manage your key on the /get-api-key/ page alongside your balance and usage statistics.

Keys do not expire by default but remain active until revoked or replaced.

  • Single active key per account
  • Instant revocation upon issuing a new key
  • View key on /get-api-key/ dashboard

Endpoint Overview

Sound wave illustration for: Endpoint Overview

The API exposes three primary endpoints for integration. The speech endpoint processes text input and returns audio, while the voices and models endpoints provide metadata about available configurations without generating audio.

These endpoints allow you to verify available voices and model versions before making costly synthesis requests, ensuring your application uses the correct parameters for the desired output format.

Speech Generation Endpoint

Send a POST request to /v1/audio/speech with a JSON body containing the text, selected voice, and desired audio format. The API processes the request and returns the generated audio file directly in the response body.

This endpoint handles all synthesis logic, including language detection if the language field is omitted. It supports up to 4096 characters per request, with longer texts requiring client-side splitting.

  • Method: POST
  • URL: https://api.qq221.info/v1/audio/speech
  • Content-Type: application/json

Voices List Endpoint

Query GET /v1/voices to retrieve a list of all available voice presets, their associated languages, and supported audio formats. This helps you match voice characteristics to your application's needs without guessing IDs.

The response includes details for all eight voices, such as Aria, Nova, and Atlas, along with their supported languages and formats.

  • Method: GET
  • URL: https://api.qq221.info/v1/voices
  • Returns: JSON array of voice objects

Models Endpoint

Use GET /v1/models to check the currently available TTS models. This ensures your requests use valid model identifiers like tts-1 or tts-1-hd before submission.

The endpoint confirms which engine versions are active and ready to accept synthesis requests, preventing errors from outdated model references.

  • Method: GET
  • URL: https://api.qq221.info/v1/models
  • Returns: JSON list of model objects

Request Parameters

Sound wave illustration for: Request Parameters

Configure your TTS requests using three core parameters: model, input text, and voice. These fields determine the synthesis engine, content length, and vocal style of the generated audio.

Model Selection

Choose between "tts-1" or "tts-1-hd". Both models use the same engine and pricing structure, allowing seamless switching without cost implications.

Input Text Limits

The input field accepts up to 4096 characters per request. Spaces and punctuation count toward this limit. For longer texts, split the content into chunks and join the resulting audio files.

Voice Selection

Select one of eight preset voices (e.g., aria, nova, atlas) via the voice parameter. Each voice supports all 23 available languages. If the language field is omitted, the system guesses the language, defaulting to English for Latin script.

Response Formats

Sound wave illustration for: Response Formats

The API returns synthesized audio as binary data in the response body, eliminating the need for intermediate file storage. The content type matches the requested format, allowing direct piping to local files or memory buffers.

Audio File Formats

Select mp3, wav, opus, flac, or pcm via the response_format parameter. MP3 offers efficient compression for web delivery, while WAV provides uncompressed lossless audio for editing. OPUS balances quality and bandwidth for efficient delivery.

  • mp3: Standard compressed audio
  • wav: Uncompressed PCM audio
  • opus: Efficient web streaming
  • flac: Lossless compression
  • pcm: Raw 16-bit mono

Binary Response

Successful requests return raw binary data in the response body. The audio file carries an inaudible watermark marking it as synthetic speech. Ensure your client handles binary streams correctly without interpreting them as JSON.

Error JSON

Failures return a JSON object with an error field containing the code and message. Failed requests incur no charge, and the balance is restored immediately. Common errors include invalid characters or exceeding the 4096-character limit.

Curl Example

Sound wave illustration for: Curl Example

The following curl command demonstrates a basic synthesis request. Replace <YOUR_API_KEY> with your active key. The API expects a JSON body containing the model, input text, and voice parameters. This example generates 5 seconds of speech using the 'nova' voice in English.

Ensure you have the correct base URL and headers configured to avoid authentication errors. The response returns the audio binary directly, which you can save to a local file for immediate use in your application.

Basic Request Command

Use this command to generate audio. Replace the placeholder key and adjust the text as needed for your use case.

  • curl -X POST https://api.qq221.info/v1/audio/speech \ -H 'Authorization: Bearer <YOUR_API_KEY>' \ -H 'Content-Type: application/json' \ -d '{"model": "tts-1", "input": "Hello, this is a test.", "voice": "nova", "response_format": "mp3"}'

Headers Configuration

The Authorization header must include your Bearer token. The Content-Type header specifies JSON. Incorrect headers will result in a 401 Unauthorized error.

Audio Output

The response body contains the raw audio bytes. Redirect the output to a file to save the generated speech.

  • -o output.mp3

OpenAI SDK Integration

Sound wave illustration for: OpenAI SDK Integration

SpeakNode’s API mirrors the OpenAI speech endpoint structure, allowing you to reuse existing OpenAI SDKs with minimal configuration. By adjusting the base URL, you can leverage familiar libraries for Python and JavaScript without learning a new client.

This approach simplifies integration for indie developers who already use OpenAI tools. You simply point the SDK to our API base and use your SpeakNode key for authentication.

Base URL Configuration

Set the API base URL to https://api.qq221.info/v1. This directs requests to the correct endpoint while maintaining compatibility with standard OpenAI client libraries.

Ensure your authentication header uses the format Bearer tts-... with your unique API key. This key is generated in your account dashboard.

Python SDK Usage

Install the official OpenAI Python library. Initialize the client with your API key and the custom base URL.

Use the audio.speech.create() method, passing your text, voice selection, and desired response format. The library handles the JSON payload and binary response automatically.

  • Use base_url="https://api.qq221.info/v1"
  • Pass model="tts-1" or tts-1-hd
  • Specify voice from the 8 available presets

JavaScript SDK Usage

Initialize the OpenAI JavaScript client with your key and the SpeakNode base URL.

Call the speech creation method with your input text and parameters. The response contains the audio data, which you can save directly to a file.

Handle errors gracefully, as failed requests are free and return specific error codes.

Rate Limits

Sound wave illustration for: Rate Limits

The API enforces a rate limit of 60 requests per minute per key. This cap applies to the POST /v1/audio/speech endpoint. Requests are processed sequentially, so complex or high-volume generation may queue briefly under load.

Requests Per Minute

Each API key is limited to 60 requests per minute. This ensures fair usage and stable generation times for indie developers. Exceeding this limit results in a 429 Too Many Requests error.

Initial Limit

New accounts without a top-up start with a reduced limit of 10 requests per minute. This allows testing the integration without immediate high-volume usage.

Limit After Top-Up

Once you top up your balance via USDT (TRC-20), the limit increases to the full 60 requests per minute. The limit applies per key, not per account.

Error Handling

Sound wave illustration for: Error Handling

When requests fail, the API returns a JSON error object with a status code and a message, ensuring you can programmatically handle issues without parsing raw text. Failed synthesis attempts are free, so you won’t be charged for invalid requests or transient errors, making it safe to retry automatically.

Common Error Codes

The API uses standard HTTP status codes to indicate success or failure. A 200 OK means the audio was generated successfully. Use 400 Bad Request for invalid parameters, 401 Unauthorized for missing or incorrect API keys, and 429 Too Many Requests if you exceed the rate limit of 60 requests per minute.

  • 400: Invalid JSON or missing required fields like 'model' or 'input'

Retry Logic

Implement exponential backoff for transient errors like 429 or 500 Internal Server Error. Since requests are processed sequentially, under load a request may wait in a queue, causing temporary delays. Wait at least one second before retrying to avoid hitting the rate limit again immediately after a failure.

Invalid Input

Ensure the input text does not exceed 4096 characters. If you need to generate longer audio, split the text into smaller chunks and join the resulting audio files. Verify that the voice name and response format are valid before sending the request to avoid wasted API calls.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Amazon Polly provides text-to-speech synthesis with a focus on seamless integration within the AWS ecosystem.

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. MDN: Web Speech API
  3. Tether (USDT)
  4. LibriTTS-R corpus (OpenSLR 141)
  5. OpenAI API reference: create speech
  6. curl documentation
  7. LibriTTS-R paper (arXiv 2305.18802)
  8. LibriVox public-domain audiobooks
  9. Creative Commons Attribution 4.0
  10. FFmpeg documentation
  11. Node.js documentation
  12. IETF RFC 7845: Ogg Opus

More on this site