Start Using Our TTS API: Curl, SDK, Voices, and Limits

By CartoonVoice editorial team · Updated 2026-11-18

This page shows you how to turn your cartoon scripts into audio using our TTS API. We provide simple curl examples and OpenAI SDK integration so animation freelancers can generate voiceovers for drafts without hiring actors. You will learn how to authenticate, choose voices, and handle character limits efficiently.

You will see exactly which models and formats we support, including speed controls and output options. We also cover rate limits, error handling, and how to split long texts. This guide helps you integrate synthetic speech into your storyboard workflow quickly, using only the facts we publish today.

Start Using Our TTS API: Curl, SDK, Voices, and Limits

Frequently asked questions

What is the base URL for the API?

The base URL is https://api.ph4apk.com/v1. You send POST requests to /v1/audio/speech for speech synthesis. Other endpoints like /v1/voices and /v1/models are also available at this base URL. Ensure your requests target this specific domain for correct routing and authentication.

Can I use the OpenAI Python SDK?

Yes. The API request shape matches the OpenAI speech endpoint. You can use the official OpenAI SDKs by changing the base_url to https://api.ph4apk.com/v1 and using your site's key. This allows you to leverage familiar SDK methods for your animation workflow.

How do I authenticate with the API?

Include your API key in the Authorization header as Bearer tts-... . Each account has one active key. If you issue a new key, the old one stops immediately. Ensure your key is valid to avoid authentication errors during your synthesis requests.

What voices are available for animation?

We offer eight presets: Aria, Nova, Luna, and Sage (female); Felix, Milo, Atlas, and Orion (male). These voices are based on licensed recordings from LibriTTS-R and LibriVox. You can select any voice for any language, allowing flexible tone choices for your cartoon characters.

Does the API support SSML markup?

No, the API does not support SSML markup. You send plain text input. If you need specific pacing or emphasis, you must adjust the speed parameter or split your text into smaller segments manually. Complex markup structures are not processed by the engine.

Can I stream audio in real-time?

No, there is no streaming or WebSocket support. The API returns the complete audio file in the response after synthesis finishes. For long texts, you must split the input and join the resulting files manually. Real-time partial audio delivery is not available.

What happens if I exceed the rate limit?

The limit is 60 requests per minute per key. If you exceed this, your requests may wait in a queue or be rejected. New accounts start with 10 requests per minute. Monitor your usage to ensure smooth generation, especially during high-volume animation drafts.

How do I handle text longer than 4096 characters?

Split your text into parts of up to 4096 characters. Send each part as a separate request and join the resulting audio files. This ensures each request stays within the character limit. Use a script to automate splitting and concatenation for longer scripts.

Is the audio format customizable?

Yes, you can choose mp3, wav, opus, flac, or pcm via the response_format field. Select the format that best fits your animation pipeline. All formats are generated from the same engine, so quality remains consistent regardless of the format you choose for delivery.

Do I need to install a specific SDK?

No, you do not need a specific SDK. You can use the OpenAI SDK or plain HTTP requests. The API follows standard REST conventions. Any HTTP client capable of sending JSON and handling audio responses can interact with the API effectively.

How do I detect the language automatically?

If you do not set the language field, the API guesses it from the script. Latin script defaults to English. For other Latin-script languages, explicitly set the language parameter to ensure correct pronunciation. Supported languages include Arabic, Chinese, French, German, and 19 others.

Are there any charges for invalid requests?

Failed requests are free. If synthesis fails, the charge is returned in full. You only pay for successful audio generation. This ensures you are not billed for errors or issues during the processing of your animation voiceover drafts.

Can I change my API key after creation?

Yes, you can issue a new key at any time. When you generate a new key, the old one stops immediately. This allows you to revoke access quickly if needed. Manage your keys directly from your account dashboard on the site.

Is there a webhook for completion notifications?

No, there is no webhook support. The API returns the audio file directly in the response. You must handle completion synchronously. For long texts, you manage the splitting and joining process yourself without relying on external notification systems for job status.

First request

curl

curl https://api.ph4apk.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.ph4apk.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.ph4apk.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 and API Key

Sound wave illustration for: Authentication and API Key

Access our TTS API by generating an API key on the /get-api-key/ page. You can sign up using Google or create an account with an email and password. Once logged in, your unique key is displayed alongside your current balance and usage statistics.

Get your key from /get-api-key/

Navigate to the dashboard to retrieve your key. This credential is essential for authenticating your requests. The page also shows your trial credit status and character limits.

Use Bearer token in Authorization header

Include your key in the HTTP header as Authorization: Bearer tts-.... This standard format works with any HTTP client or SDK, ensuring secure access to the speech generation endpoint.

One active key per account at a time

Each account holds only one active key. If you generate a new key, the previous one becomes invalid immediately. This ensures clear tracking of your usage and billing across your animation projects.

First Request with Curl

Sound wave illustration for: First Request with Curl

Send a POST request to https://api.ph4apk.com/v1/audio/speech with your Bearer token. Include model (tts-1 or tts-1-hd), input text (max 4096 chars), voice preset, and response_format.

Send POST to /v1/audio/speech

Point your curl command at the speech endpoint. Attach your API key in the Authorization header to authenticate the request.

Include model, input, voice, and format

Define the JSON body with your script text, chosen voice (e.g., aria for narration), and desired output format like mp3 or wav.

  • model: tts-1 or tts-1-hd
  • input: your script text
  • voice: one of 8 presets
  • response_format: mp3, wav, opus, flac, or pcm

Receive audio file in response

The API returns the generated audio file directly in the response body. Save this binary data to your local project folder for use in your animation draft.

First Request with Curl

Using the OpenAI SDK

Sound wave illustration for: Using the OpenAI SDK

Switching to our API with the OpenAI SDK is straightforward. You only need to update the base URL in your client configuration to point to our domain. This allows you to keep using the standard methods you already know, such as audio.speech, without rewriting your integration logic.

The official SDKs work seamlessly because our endpoint shape matches theirs. You simply pass your API key and standard parameters like model, input, and voice. It is a drop-in replacement for development and prototyping, letting you focus on your animation script rather than API quirks.

Set base_url to our API domain

Configure your client’s base URL to https://api.ph4apk.com/v1. This directs all requests to our infrastructure while maintaining the standard OpenAI path structure. You do not need to change the endpoint path for speech generation, only the host.

Ensure your authentication header uses the Bearer token from your account dashboard. The SDK will handle the header injection automatically if configured correctly.

  • Base URL: https://api.ph4apk.com/v1
  • Endpoint path remains /v1/audio/speech
  • Use your site-specific API key

Use standard OpenAI client methods

Call the audio.speech method just as you would for OpenAI. Pass your text in the input field and select one of the eight preset voices. The response will contain the audio data, which you can save directly to your project folder.

You can also specify the response_format (e.g., mp3, wav) and speed multiplier. These parameters behave exactly as defined in the standard schema, making debugging easy since you can use existing examples.

  • Method: audio.speech
  • Params: model, input, voice, response_format
  • Returns audio binary data

Works with official SDKs

Since we mirror the OpenAI request shape, any official OpenAI SDK (Python, Node.js, etc.) works out of the box. You just need to ensure you are using a recent version that supports the audio namespace.

This compatibility means you can prototype quickly in your local environment before deploying to your animation pipeline. No custom client libraries or wrappers are required for basic usage.

  • Compatible with Python, Node.js, and other official SDKs
  • No custom wrappers needed
  • Standard parameter structure

Supported Models and Voices

Sound wave illustration for: Supported Models and Voices

Both models use the same high-quality engine and pricing, so choose based on your preference for file size versus audio fidelity. The API accepts either "tts-1" or "tts-1-hd" in the request model field without any difference in cost or voice characteristics.

tts-1 and tts-1-hd models

Since the underlying engine is identical for both options, you can swap them easily. Use "tts-1-hd" if you need slightly higher fidelity for final renders, or stick with "tts-1" for faster processing during quick storyboarding iterations.

8 preset voices for animation

We provide eight distinct voice presets licensed from public-domain readings, optimized for clear character distinction. You can assign different voices to different characters in your script, such as using the warm, clear narration of Aria for the protagonist or the energetic promo style of Felix for a commercial spot.

  • Aria (warm narrator), Nova (bright), Luna (soft storyteller)
  • Felix (energetic), Milo (friendly), Atlas (neutral news)
  • Milo (friendly), Orion (deep documentary)

No custom voice cloning

These voices are fixed presets based on licensed recordings; we do not offer custom voice cloning or the ability to upload your own voice samples. If you need a specific actor's voice, you must select the closest preset from our library.

Output Formats and Speed

Sound wave illustration for: Output Formats and Speed

Choose the output format that best fits your animation workflow. We support MP3, WAV, OPUS, FLAC, and PCM, allowing you to balance file size and quality depending on your final delivery needs.

Control the pacing of your voiceovers with the speed parameter, adjustable from 0.25 to 4.0. This lets you match the voiceover rhythm to your storyboard’s timing, whether you need a slow, deliberate narration or a fast-paced comedic delivery.

The API returns the complete audio file upon request completion. We do not offer streaming, WebSockets, or real-time partial audio, so you must wait for generation to finish before proceeding to the next step in your pipeline.

MP3, WAV, OPUS, FLAC, PCM options

Select the format that suits your project’s technical requirements. Whether you need compressed MP3 for quick previews or uncompressed WAV for final animation syncing, the API handles the conversion efficiently.

  • MP3
  • WAV
  • OPUS
  • FLAC
  • PCM

Speed control from 0.25 to 4.0

Adjust the speed parameter to fine-tune the voice’s pace. This is essential for aligning synthetic speech with visual cues in animated shorts, ensuring the dialogue matches the character’s movements precisely.

No streaming or WebSocket support

Since we do not support streaming, each request generates a complete audio file. You will receive the full asset in the response, which you can then integrate directly into your animation software.

Output Formats and Speed

Handling Long Texts

Sound wave illustration for: Handling Long Texts

Animation scripts often exceed the 4096 character limit per request. To handle longer dialogues or narration, you must split your text into smaller chunks and process them sequentially.

Split text into 4096 character chunks

Divide your script into segments of up to 4096 characters. Ensure you do not cut words in half to maintain natural speech continuity.

Generate audio for each chunk

Send each chunk as a separate POST request to the speech endpoint. Each request generates an individual audio file containing the synthesized speech for that segment.

Join audio files for final output

Concatenate the resulting audio files in order to create the final voiceover. This allows you to iterate on specific scenes without regenerating the entire script.

Rate Limits and Errors

Sound wave illustration for: Rate Limits and Errors

Our API allows 60 requests per minute for each active API key. This limit ensures consistent performance for your animation workflow, whether you are generating short dialogue snippets or processing longer scene scripts.

60 requests per minute limit

You can make up to 60 requests per minute. If you exceed this limit, the API will return an error until the next minute begins. New accounts start with a lower limit of 10 requests per minute until the first top-up is processed.

Queue processing under load

Requests are processed sequentially. During peak times, your request may wait in a queue before synthesis begins. This means generation time might be slightly longer than usual, but your request will be completed in order.

Failed requests are free

If a synthesis request fails for any reason, you are not charged. The character count is returned to your balance, ensuring you only pay for successful audio generation.

Rate Limits and Errors

Voice and Language Details

Sound wave illustration for: Voice and Language Details

Our API supports 23 languages, including Arabic, Chinese, French, German, Japanese, Spanish, and more. Any voice can speak any of these languages, giving you flexibility for diverse cartoon characters.

You can retrieve the full list of available voices, languages, and formats by calling GET /v1/voices. This helps you plan your animation projects efficiently.

Fetch voices via GET /v1/voices

Use the GET /v1/voices endpoint to see all available presets and their supported languages.

It is the best way to verify which voices are available for your specific animation needs without guessing.

  • Retrieves all 8 voice presets
  • Shows supported languages per voice
  • Lists available output formats

Set language ISO code explicitly

Although the API guesses language from the script, setting the language parameter explicitly ensures accurate pronunciation for non-English Latin text.

For example, if your script is in French but uses Latin characters, always set language to fr to avoid default English pronunciation.

Default to English for Latin text

If you do not set the language parameter, the API defaults to English for any Latin-script text.

This is convenient for English cartoons but can cause errors for other languages using Latin characters, so always specify it when needed.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Create vibrant characters and engaging worlds that bring imagination to life through expressive animation and captivating cartoons.

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. openai-python on GitHub
  4. ISO 639 language codes
  5. openai-node on GitHub
  6. MDN: Web Speech API
  7. TRON developer hub: TRC-20
  8. W3C WAI: making audio and video accessible
  9. curl documentation
  10. OpenAI API reference: create speech
  11. IETF RFC 7845: Ogg Opus
  12. Creative Commons Attribution 4.0

More on this site