API Documentation for Text-to-Speech Integration

By ToonTTS Lab editorial team · Updated 2026-11-18

This documentation helps animation developers integrate ToonTTS into their production pipelines. You will find clear examples for generating voiceovers directly from scripts using standard HTTP requests or the OpenAI SDK. The guide covers authentication, voice selection, and audio format options so you can automate character dialogue without hiring actors for every draft.

We explain how to handle long scripts by splitting text into manageable chunks and joining the resulting audio files. You will also learn about rate limits, error handling, and pricing details specific to agency workflows. This page is designed for engineers who need reliable, scalable synthetic speech for cartoon projects.

API Documentation for Text-to-Speech Integration

Frequently asked questions

What is the base URL for the ToonTTS API?

The API base URL is https://api.ak99apk.com/v1. You send POST requests to https://api.ak99apk.com/v1/audio/speech for synthesis. This endpoint accepts JSON bodies containing your text, voice selection, and desired output format. Use this URL for all programmatic interactions with the ToonTTS service.

Can I use the official OpenAI Python SDK?

Yes, the official OpenAI SDKs work by changing the base_url to https://api.ak99apk.com/v1. You must use your ToonTTS API key instead of an OpenAI key. The request shape matches the OpenAI speech endpoint, allowing you to integrate quickly without rewriting your client code.

How do I set the Authorization header?

Include the header Authorization: Bearer tts-... where the value is your unique API key. You can find this key on your /get-api-key/ dashboard page. Each account has one active key; issuing a new one immediately invalidates the previous key. Keep this key secure.

What is the maximum length of text per request?

The maximum input length is 4096 characters per request. Spaces and punctuation count toward this limit. For longer scripts, split your text into parts of up to 4096 characters and join the resulting audio files manually in your workflow.

Which models are available for animation?

Two models are available: tts-1 and tts-1-hd. Both use the same engine and price structure. Choose based on your quality preference. The model parameter is required in your JSON request body to specify which synthesis engine to use for your animation voiceover.

How do I specify the language for non-English scripts?

Set the optional language parameter to an ISO code. If omitted, the system guesses the language, defaulting to English for Latin script. For non-English Latin text, always set the language explicitly to ensure accurate pronunciation and correct voice selection.

Can I request audio in PCM format?

Yes, you can request PCM format by setting the response_format field to pcm. Other supported formats include mp3, wav, opus, and flac. Select the format that best fits your animation pipeline and audio editing requirements.

What happens if I exceed the rate limit?

The limit is 60 requests per minute per key (10 per minute before the first top-up). Requests are processed sequentially, so exceeding limits may cause queuing delays. Failed requests are free, but successful ones consume your balance and count toward the limit.

How do I regenerate my API key?

You can issue a new key anytime from your account dashboard. The new key becomes active immediately, and the old key stops working at once. Visit /get-api-key/ to manage your keys and view your current balance and usage statistics.

Does the API support streaming responses?

No, the API does not support streaming, WebSockets, or real-time partial audio. You receive the complete audio file in the response body after synthesis is finished.

What is the default voice if none is specified?

You must provide a voice parameter from the eight presets. The voices are aria, nova, luna, sage, felix, milo, atlas, or orion. Ensure you select one explicitly for consistent results.

How long does it take to generate audio?

Typical speed is roughly real time, about 25 characters per second of generation. Short phrases take a few seconds. Requests are processed one after another, so under load, a request may wait in a queue before synthesis begins.

Can I use the API in a Node.js environment?

Yes, since the request shape matches the OpenAI speech endpoint, you can use the official OpenAI Node.js SDK by changing the base_url. Alternatively, you can use any HTTP client library to send POST requests to the /v1/audio/speech endpoint with your JSON body.

How do I handle errors in my code?

The API returns standard HTTP error codes if synthesis fails. Failed requests are free, and the charge is returned in full. Check the response status code and body for details. Implement retry logic for transient errors, keeping the 60 requests per minute limit in mind.

First request

curl

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

Get Your API Key

Sound wave illustration for: Get Your API Key

To start generating voiceovers for your animation scripts, sign up on /get-api-key/ using your Google account or email and password. This creates an independent account specific to ak99apk.com.

Your API key appears in the dashboard alongside your balance and character count. Use this key to authenticate your requests.

Sign up with Google or email

Sign up with Google or email

Use Google for instant access with a $0.50 free trial credit valid for 7 days. Email signups do not include trial credit.

Find key in dashboard

Find key in dashboard

Navigate to /get-api-key/ to view your active key, usage stats, and a ready-to-use cURL example.

  • One active key per account
  • Copy the tts-... token directly

Regenerate key if needed

Generate a new key anytime from the dashboard. The old key stops working immediately upon creation of the new one.

First Request with cURL

Sound wave illustration for: First Request with cURL

To generate your first audio clip, send a POST request to the API endpoint with your authentication token. The system expects a standard JSON payload containing the text to be synthesized and the desired voice preset. This structure mirrors common industry standards, making it easy to integrate into existing animation pipelines.

Basic JSON body structure

The request body must include the model, input (your text), and voice parameters. You can optionally specify response_format (e.g., mp3, wav) and speed. Ensure the text does not exceed 4096 characters per request.

  • model: "tts-1" or "tts-1-hd"
  • input: The text string (max 4096 chars)
  • voice: One of the 8 available presets
  • response_format: mp3, wav, opus, flac, or pcm

Required fields: model, input, voice

You must specify a model (tts-1 or tts-1-hd), the text content in input, and a voice ID from our list. The input field accepts up to 4096 characters. Spaces and punctuation count toward this limit.

Sending your first audio file

Use the following cURL command to test the endpoint. Replace YOUR_API_KEY with your key from the dashboard and aria with your chosen voice. The response will return the audio file directly.

  • Replace YOUR_API_KEY with your actual key.
  • Try different voices like nova for upbeat dialogue or sage for narration.
  • Check the response headers for content type to ensure proper handling.

Using the OpenAI SDK

Sound wave illustration for: Using the OpenAI SDK

ToonTTS Lab’s API mirrors the OpenAI speech endpoint structure, allowing you to use official OpenAI SDKs with minimal configuration. By simply pointing the base_url to https://api.ak99apk.com/v1, your existing animation pipeline code can route requests to our engine without rewriting core logic.

This compatibility means you can generate voiceovers for cartoon scripts using familiar libraries, ensuring a smooth transition for development teams already accustomed to OpenAI’s authentication patterns and JSON bodies.

Set base_url to our endpoint

Configure your SDK client to use https://api.ak99apk.com/v1 as the base URL. This single change redirects all speech synthesis requests to our infrastructure while maintaining standard JSON payload formats.

Use official SDKs with auth token

Pass your API key via the Authorization: Bearer tts-... header. The SDK handles token validation automatically, ensuring secure access to your character voiceovers without extra wrapper code.

Compatibility with tts-1 models

Both tts-1 and tts-1-hd models are supported under this compatibility layer. You can switch between standard and high-definition audio quality by changing the model name in your request body, using the same SDK methods.

  • Standard tts-1 for rapid drafting
  • High-definition tts-1-hd for final polish
  • Identical JSON structure for both

Supported Audio Formats

Sound wave illustration for: Supported Audio Formats

To select the output format, include the response_format field in your JSON payload. You can choose from mp3, wav, opus, or flac to match your production pipeline. The API returns the audio file directly in the response body.

MP3 for web playback

MP3 is the standard for web delivery. It offers a good balance between file size and quality, making it ideal for embedding voiceovers directly into your animation projects or web apps. Most players and editors support this format natively.

WAV for high quality editing

WAV provides uncompressed audio, preserving every detail of the synthetic voice. This format is best for post-production workflows where you need to apply effects, normalize volume, or mix multiple tracks without generation loss. It is larger than MP3 but ensures maximum fidelity.

OPUS and FLAC options

OPUS offers efficient compression for storage-constrained environments. FLAC provides lossless compression, reducing file size while keeping the audio identical to the original WAV. Both are valid choices depending on your storage and bandwidth requirements.

Voice Selection and Speed

Sound wave illustration for: Voice Selection and Speed

ToonTTS provides eight distinct voice presets optimized for animation workflows, allowing you to assign specific tonal qualities to different characters. Each voice is built from licensed recordings, ensuring consistent synthetic speech that fits cartoon dialogue without the cost of hiring actors for every draft.

Speed control lets you adjust playback from 0.25x to 4.0x, enabling precise timing for comedic pauses or rapid-fire dialogue. You can tune the delivery to match your animation’s pacing exactly, ensuring the audio aligns seamlessly with visual cues.

Choose from 8 presets

Select from four female and four male voices, each with a distinct character archetype. Aria offers a warm, clear narrator tone, while Luna provides a soft, storytelling quality ideal for gentle scenes. Nova delivers a bright, upbeat energy perfect for energetic heroes.

For male roles, Felix brings energetic promo-style delivery, whereas Milo offers a friendly, conversational tone suitable for everyday dialogue. Atlas provides a neutral, news-style baseline, and Orion’s deep, documentary voice adds gravity to serious or epic moments. Any voice can speak any supported language.

  • 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

Adjust speed from 0.25x to 4.0x

Use the speed parameter to scale the voice’s natural tempo. Values range from 0.25 (slow, deliberate) to 4.0 (fast, energetic). This allows you to compress long dialogue into tight scenes or stretch short lines for dramatic effect without re-recording.

Speed adjustments affect the entire clip uniformly. Combine this with voice selection to create unique character voices that feel distinct from one another, even when using the same base voice model.

Select voice by ID

Pass the voice name (e.g., aria, nova) as the voice string in your JSON body. The API accepts these eight preset IDs directly, mapping them to the corresponding synthetic voice models. You can switch voices between requests to alternate characters in a single script.

Voice Selection and Speed

Handling Long Texts

Sound wave illustration for: Handling Long Texts

To handle scripts longer than 4096 characters, split your text into smaller chunks and send each one individually. The API returns a separate audio file for every request, so you must combine them later to create a single continuous voiceover.

Split text into 4096 char chunks

Divide your script so each segment stays within the 4096-character limit. This ensures reliable synthesis without truncation. Since spaces and punctuation count as characters, use precise string splitting logic in your code to maintain sentence integrity where possible.

  • Maximum 4096 characters per request
  • Spaces and punctuation count toward the limit
  • Each chunk generates a separate audio file

Join audio files manually

After receiving multiple audio files, join them manually using an audio library or command-line tool. Concatenate the files in the exact order of your original script segments. This step is necessary because the API does not return a single unified file for long texts.

Manage request loops

Process chunks sequentially or in parallel while respecting the 60 requests per minute rate limit. If you exceed the limit, requests wait in a queue before processing. For very long scripts, batch your requests to avoid delays and ensure smooth playback synchronization.

  • Respect the 60 requests per minute limit
  • Requests queue automatically under load
  • Process chunks in script order

Rate Limits and Queues

Sound wave illustration for: Rate Limits and Queues

Rate limits protect the service during high demand. Each API key allows 60 requests per minute once your account is funded. This limit applies to all speech synthesis calls, so plan your batch jobs accordingly.

60 requests per minute limit

Once you top up, you can send up to 60 requests per minute. This throughput is sufficient for most animation pipelines, but large batch exports may require slight delays between requests to avoid hitting the cap.

10 requests before top-up

New accounts without a top-up are limited to 10 requests per minute. This ensures fair usage while you test the API. Upgrade your balance to access the full 60 requests per minute capacity immediately.

Queue handling under load

Requests are processed sequentially. During peak times, a request may wait in a queue before generation begins. Typical processing speed is roughly real-time (about 25 characters per second); short phrases take a few seconds. Under heavy load, wait times increase, so implement retry logic with exponential backoff for robustness.

Error Codes and Troubleshooting

Sound wave illustration for: Error Codes and Troubleshooting

Understanding error responses helps you integrate smoothly without halting your production pipeline. Most issues stem from simple input constraints or temporary service limits.

400 Bad Request examples

A 400 error typically indicates missing required fields or invalid values. Ensure your JSON body includes model, input, and voice. The input field must not exceed 4096 characters, and voice must match one of the eight available presets.

429 Rate Limit errors

You receive a 429 status if you exceed 60 requests per minute. New accounts start with a limit of 10 requests per minute until the first top-up. Implement exponential backoff to handle these pauses gracefully during batch generation.

Handling failed generations

If synthesis fails for any reason, the charge is returned in full. Check the response body for specific error codes to distinguish between temporary glitches and permanent configuration errors.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Our studio crafts vibrant characters and immersive worlds that bring your brand's story to life with captivating visual flair.

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. FFmpeg documentation
  3. Node.js documentation
  4. curl documentation
  5. openai-node on GitHub
  6. MDN: Web Speech API
  7. openai-python on GitHub
  8. OpenAI API reference: create speech
  9. Creative Commons Attribution 4.0
  10. Tether (USDT)
  11. LibriVox public-domain audiobooks
  12. TRON developer hub: TRC-20

More on this site