Text-to-Speech API Documentation for Developers

By ToonSonic editorial team · Updated 2026-11-18

This documentation defines the ToonSonic text-to-speech API for animation developers. You will find precise endpoint specifications, parameter constraints, and integration patterns for generating consistent voice assets via standard HTTP requests. The guide covers authentication, request structures, and response handling to help you integrate TTS into your production pipeline efficiently.

Use this reference to implement voice synthesis for dialogue, promos, and narration across 23 languages. We detail rate limits, error codes, and SDK compatibility so you can deploy reliable audio generation without managing complex infrastructure. This page assumes you have an API key and focuses on technical implementation details for developers building cartoon or animation content.

Text-to-Speech API Documentation for Developers

Frequently asked questions

What is the base URL for the API?

The API base URL is https://api.u777play.com/v1. All requests, including speech synthesis and voice listing, are directed to this endpoint. You can use this base URL with standard HTTP clients or compatible SDKs to interact with the ToonSonic text-to-speech service.

Does the API support streaming audio?

No, the API does not support streaming, WebSocket, or real-time partial audio. It returns the complete audio file in the response after synthesis is finished. You must wait for the full response to receive the generated audio data.

How do I specify the audio format?

Include the response_format field in your JSON request body. Valid values are mp3, wav, opus, flac, and pcm. The API returns the audio file in the format you specify, allowing you to choose the best codec for your animation pipeline.

Can I use the OpenAI Python SDK?

Yes, the official OpenAI SDKs work by changing the base_url to https://api.u777play.com/v1 and using your ToonSonic API key. The request shape matches the OpenAI speech endpoint, allowing you to reuse existing code with minimal configuration changes.

What happens if the text exceeds 4096 characters?

You must split the text into parts of up to 4096 characters each and send separate requests. After receiving the audio files for each part, you should join them to create the final audio file for your animation project.

How do I set the voice speed?

Use the speed field in your request body, with a value between 0.25 and 4.0. This allows you to adjust the pacing of the narration to match the timing of your animation scenes without needing post-processing.

Is SSML supported?

No, the API does not support SSML. It accepts plain text input. If you need precise control over pronunciation or pauses, you must manage those directly in the text input or handle them in your post-processing pipeline.

Can I specify the language explicitly?

Yes, use the optional language field with an ISO code. If omitted, the language is guessed from the script, defaulting to English for Latin text. Explicitly setting the language ensures correct pronunciation for non-English Latin-script text.

How do I handle API errors?

Failed requests are free, and the charge is returned in full. Check the HTTP status code and response body for error details. Ensure your API key is valid and your request format matches the required JSON structure for synthesis.

What is the maximum request size?

The maximum input text size is 4096 characters per request. Spaces and punctuation count toward this limit. For longer texts, split your content into chunks of this size and process them sequentially or in parallel.

Do I need to install specific libraries?

No proprietary library is required. You can use any standard HTTP client or the official OpenAI SDK by adjusting the base URL to https://api.u777play.com/v1. The API uses standard JSON requests and responses, making it compatible with most programming environments and tools.

How do I rotate my API key?

You can issue a new API key at any time from your account dashboard. The new key becomes active immediately, and the old key stops working at once. This allows you to rotate keys without downtime for your applications.

What is the difference between tts-1 and tts-1-hd?

Both models use the same engine and share the same price. The only difference is the model identifier in your request. You can use tts-1 or tts-1-hd interchangeably, as they produce identical audio quality and incur the same cost per character.

Can I use custom voices?

No, the API does not offer custom voice cloning or uploading your own voice. You can choose from eight preset voices based on licensed recordings. Each generated file includes an inaudible watermark marking it as synthetic speech.

First request

curl

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

ToonSonic API keys authenticate requests via the standard Bearer scheme. Include your key in the Authorization: Bearer tts-... header of every request to the https://api.u777play.com/v1 base URL.

Bearer Token Authorization

Pass your unique API key as a Bearer token in the HTTP Authorization header. This single credential grants access to all endpoints, including speech synthesis and voice listing.

Single Active Key Per Account

Each account maintains one active key at any given time. If you generate a new key, the previous key becomes invalid immediately, ensuring strict access control.

Key Rotation Process

Rotate your key via the dashboard at /get-api-key/. The new key takes effect instantly, and the old one stops working immediately, preventing any further usage with the stale token.

Speech Endpoint

Sound wave illustration for: Speech Endpoint

The core synthesis engine receives your text payload and returns the resulting audio file. This single endpoint handles all conversion logic, allowing you to trigger speech generation with a standard HTTP POST request. The service processes requests sequentially, so under heavy load, responses may queue behind previous submissions.

POST /v1/audio/speech

Send a POST request to the endpoint https://api.u777play.com/v1/audio/speech. The endpoint accepts JSON bodies containing the model, input text, voice selection, and optional formatting parameters. It returns the synthesized audio file directly in the response body, matching the standard speech endpoint structure.

  • Endpoint: POST https://api.u777play.com/v1/audio/speech
  • Input: JSON payload
  • Output: Raw audio file

JSON Request Body

The request body requires a model field ("tts-1" or "tts-1-hd"), an input string (max 4096 characters), and a voice preset. You may also specify response_format, speed, and an optional language ISO code. Spaces and punctuation count toward the character limit.

  • model: "tts-1" or "tts-1-hd"
  • input: string (max 4096 chars)
  • voice: one of 8 presets
  • response_format: mp3, wav, opus, flac, pcm
  • speed: 0.25–4.0
  • language: optional ISO code

Audio Response Stream

Despite the name, no streaming protocol is used. The API waits for the entire synthesis job to complete before returning the full audio file. For long texts, you must split the input into chunks of 4096 characters, generate each segment, and join the resulting files client-side.

Speech Endpoint

Required Parameters

Sound wave illustration for: Required Parameters

The API requires three mandatory fields in every request: model, input, and voice. These parameters define the synthesis engine, the content to be converted, and the specific voice preset used to generate the audio file.

Select the model identifier, ensure the text does not exceed the character limit, and choose from the eight available voice presets. All voices can speak any of the 23 supported languages, but gender is fixed per preset.

Model Selection: tts-1 or tts-1-hd

Both tts-1 and tts-1-hd use the same engine and price. The identifier distinguishes the request format but does not imply a difference in fidelity or quality. Choose either based on your preference for the parameter name.

Input Text Limit: 4096 Characters

The input field accepts a maximum of 4096 characters per request. Spaces and punctuation count toward this limit. For longer scripts, split the text into chunks and join the resulting audio files sequentially.

Voice Preset Selection

Choose from eight presets: Female (aria, nova, luna, sage) or Male (felix, milo, atlas, orion). Each voice has a distinct tone, such as 'warm, clear narrator' for aria or 'deep, documentary' for orion. Any voice can produce any of the 23 supported languages.

  • aria: warm, clear narrator
  • nova: bright, upbeat
  • luna: soft, storytelling
  • sage: calm, instructional
  • felix: energetic, promo
  • milo: friendly, conversational

Optional Parameters

Sound wave illustration for: Optional Parameters

The API accepts response_format, speed, and language to customize audio output. These optional fields allow you to adjust file types, playback rate, and language detection without changing the core synthesis engine.

Response Format: MP3, WAV, OPUS

Specify the desired audio container format in the request body. Supported formats include mp3, wav, opus, flac, and pcm. The API returns the binary audio data in the requested format.

  • mp3, wav, opus, flac, pcm

Speed Control: 0.25 to 4.0

Adjust the playback speed relative to the default voice performance. The speed parameter accepts values between 0.25 and 4.0. A value of 1.0 represents the standard rate.

  • Range: 0.25–4.0

Language ISO Code

Set the language field to an ISO 639-1 code to enforce specific language output. If omitted, the system guesses the language from the text script, defaulting to English for Latin script. Explicitly set this for non-English Latin text to ensure accuracy.

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

Quickstart with cURL

Sound wave illustration for: Quickstart with cURL

Generate audio files directly from the terminal using the standard curl command. This method requires a valid Bearer token and a POST request to the speech endpoint. Ensure the base_url matches your site’s API domain to avoid connection errors during initial integration.

The command structure mirrors the OpenAI SDK format, making it easy to transition between manual testing and programmatic implementation. You can immediately verify audio generation before embedding the logic into your animation pipeline or content creation workflow.

Basic cURL Command

Send a synthesis request with your API key and desired parameters. Replace YOUR_API_KEY with your active token and YOUR_VOICE with one of the eight presets (e.g., aria, nova). The response is the audio file binary data.

```bash curl -X POST "https://api.u777play.com/v1/audio/speech" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "tts-1", "input": "Hello world", "voice": "aria", "response_format": "mp3"}' \ -o output.mp3 ```

  • Use -o to save the binary response directly to a file.
  • Ensure the JSON body is valid; missing fields like model or input cause immediate rejection.
  • Supported formats include mp3, wav, opus, flac, and pcm.

Error Handling

If the request fails, the API returns an HTTP status code and a JSON error object. Common issues include invalid characters exceeding the 4096 limit or an unauthorized key. Check the response body for specific error messages to debug quickly.

Failed requests do not incur charges, so you can safely retry after fixing the input data. Always inspect the status code before parsing the audio binary to avoid corrupting your output files.

  • 400: Invalid input parameters or text length exceeded.
  • 401: Invalid or expired Bearer token.
  • 429: Rate limit exceeded (check your 60 requests/minute quota).

Response Parsing

The response body contains the raw audio data. For scripting, capture this binary stream and save it directly to disk. No additional parsing of the audio content is required, as the format is determined by your response_format parameter.

Use standard file I/O operations in your script to handle the output. Since the API returns binary data, ensure your script does not interpret the response as JSON unless an error occurs.

  • Save the response directly to a file using the -o flag.
  • Verify the file extension matches the requested response_format.
  • No metadata is embedded in the audio file itself; use request logs for tracking.
Quickstart with cURL

Integration with OpenAI SDK

Sound wave illustration for: Integration with OpenAI SDK

The ToonSonic TTS API mirrors the request shape of the OpenAI speech endpoint, allowing you to reuse existing OpenAI SDK clients. This compatibility means you can integrate our service into your animation pipeline without rewriting your HTTP logic, simply by pointing the client to our base URL.

Base URL Configuration

Update your client's base URL to https://api.u777play.com/v1. This redirects all standard speech requests to our infrastructure while maintaining the same JSON payload structure expected by the OpenAI SDK.

SDK Compatibility

The API accepts the same parameters as the OpenAI tts-1 and tts-1-hd endpoints. Since our endpoint returns the complete audio file rather than streaming chunks, use standard file write methods (e.g., write_to_file) instead of streaming variants to avoid confusion with our non-streaming architecture.

Example Code Snippet

```python from openai import OpenAI client = OpenAI(base_url="https://api.u777play.com/v1", api_key="tts-...") response = client.audio.speech.create( model="tts-1", voice="nova", input="Animation assets ready for rendering." ) response.write_to_file("output.mp3") ```

Rate Limits

Sound wave illustration for: Rate Limits

Rate limits apply to each API key independently. The standard limit is 60 requests per minute. This cap ensures stable performance for your animation workflow without requiring complex throttling logic on your end.

60 Requests Per Minute

Each active API key is allowed a maximum of 60 requests per minute. This limit resets continuously as the window slides, allowing for burst usage as long as the average does not exceed the threshold.

10 Requests Before Top-Up

New accounts or those with low balances start with a reduced limit of 10 requests per minute. This restriction applies until the first top-up is processed. Once USDT is credited via TRC-20, the limit increases to the standard 60 RPM.

Queue Behavior Under Load

Requests are processed sequentially rather than in parallel. Under heavy load, additional requests may wait in a queue before synthesis begins. Short phrases typically take a few seconds, while longer texts generate at roughly real-time speed (25 characters per second).

Failed requests are free but still consume API quota. The system returns the audio file directly in the response stream, eliminating the need for separate polling endpoints.

  • Requests are processed one after another
  • Failed requests count against your limit
  • No parallel processing during high load
Rate Limits

Error Codes

Sound wave illustration for: Error Codes

ToonSonic returns standard HTTP status codes to indicate the state of your speech synthesis requests. Understanding these responses allows you to implement robust error handling in your animation pipeline.

Most errors are immediate and prevent unnecessary character consumption. Failed synthesis attempts are free, ensuring you only pay for successfully generated audio files.

400 Bad Request

This error indicates an issue with the request structure, such as an invalid voice ID, a model that does not exist, or text exceeding the 4096-character limit per request.

The response body includes a detailed message explaining the validation failure. No characters are deducted from your balance when this error occurs.

  • Verify voice IDs against the /v1/voices endpoint.
  • Ensure input text is under 4096 characters.
  • Check that the model is either 'tts-1' or 'tts-1-hd'.

401 Unauthorized

The provided API key is missing, incorrect, or has been invalidated. This occurs if you rotate your key and continue using the old one, as only one key is active per account.

Generate a new key from your dashboard and update your Authorization header immediately.

  • Ensure the header format is 'Authorization: Bearer <key>'.

429 Too Many Requests

You have exceeded the rate limit of 60 requests per minute. New accounts start with a lower limit of 10 requests per minute until the first top-up is processed.

Requests may also queue under heavy load, potentially increasing latency. Implement exponential backoff in your integration to handle these retries efficiently.

  • Check your current usage via the dashboard.
  • Wait before retrying after receiving this code.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Bring your characters to life by mastering the subtle art of expressive timing and fluid motion in your animated scenes.

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. Tether (USDT)
  3. OpenAI API reference: create speech
  4. Python documentation
  5. ISO 639 language codes
  6. IETF RFC 7845: Ogg Opus
  7. TRON developer hub: TRC-20
  8. Node.js documentation
  9. LibriTTS-R corpus (OpenSLR 141)
  10. openai-node on GitHub
  11. Creative Commons Attribution 4.0
  12. curl documentation

More on this site