API Documentation for Text-to-Speech Integration

By Ufacamth Audio editorial team · Updated 2026-11-18

This documentation explains how to integrate Ufacamth Audio’s text-to-speech API into your game engine or content pipeline. We provide a straightforward HTTP interface that generates high-quality, human-sounding NPC dialogue from text, designed specifically for game developers and content creators who need realistic voice acting without complex integrations.

You will find concrete examples for authenticating with your API key, sending requests via cURL or the OpenAI SDK, and handling response formats like MP3 and WAV. The guide covers voice selection, language parameters, rate limits, and error handling to help you generate consistent audio assets efficiently.

API Documentation for Text-to-Speech Integration

Frequently asked questions

What is the API endpoint?

Send your requests to POST https://api.ufacamth.com/v1/audio/speech. The JSON body structure matches the OpenAI speech endpoint exactly, allowing you to integrate quickly without learning a new format. You can also retrieve available voices and models via GET /v1/voices and GET /v1/models respectively.

How do I authenticate requests?

Include your API key in the HTTP header as Authorization: Bearer tts-... . Each account holds one active key at a time. If you generate a new key, the previous one stops working immediately, ensuring secure access to your character generation credits.

Which SDKs are compatible?

The API uses the same request shape as the OpenAI speech endpoint. This means the official OpenAI SDKs work perfectly by simply changing the base_url to https://api.ufacamth.com/v1. You do not need a custom client or proprietary library to start generating NPC dialogue.

What audio formats are available?

You can choose from mp3, wav, opus, flac, or pcm. Select the format that best fits your game engine or content pipeline. Every generated file carries an inaudible watermark that marks it as synthetic speech.

How do I set the language?

Pass the optional ISO code in the language field. If omitted, the system guesses the language from the script, defaulting to English for Latin text. For non-English Latin-script text, always set the language explicitly to ensure accurate pronunciation and natural delivery for your characters.

What are the rate limits?

You are limited to 60 requests per minute per key. New accounts start with a lower limit of 10 requests per minute until the first top-up is processed. This ensures fair usage across the network while allowing you to scale up as your game production grows.

How long is the maximum text length?

Each request can contain up to 4096 characters of input text. Spaces and punctuation count toward this limit. For longer dialogues, you should split the text into chunks of this size and join the resulting audio files to create seamless NPC conversations or monologues.

Can I adjust the speech speed?

Yes, you can set the speed between 0.25 and 4.0. This allows you to create varied NPC personalities, from slow, thoughtful delivery to rapid, energetic speech. Adjusting speed helps differentiate characters and enhances the immersive experience without needing additional voice actors or complex audio editing.

How are errors handled?

If synthesis fails, the charge is returned in full. Failed requests do not cost you credits. You can retry your request with adjusted parameters. This ensures you only pay for successfully generated audio files, protecting your budget during development and testing phases of your game.

Is the API synchronous?

Requests are processed one after another, so under load a request may wait in a queue. Typical speed is roughly real-time, generating about 25 characters per second. Short phrases may take a few seconds, so design your UI to handle these slight delays gracefully.

How do I handle long texts?

Split your text into parts of up to 4096 characters. Generate audio for each part separately, then join the audio files. This workflow ensures you stay within limits while creating long dialogues or narration tracks. It is the recommended approach for extensive NPC scripts or audiobooks.

Do I need a custom client?

No, you can use the official OpenAI SDKs by changing the base_url. Plain HTTP requests also work directly. There is no proprietary SDK required. This flexibility allows you to integrate the API into your existing build pipelines or custom engines without learning new tools.

Are responses cached?

Generated audio is returned in the response and not stored by the API. Input text is used only to produce the audio and is not used for training. Request metadata is kept for billing purposes. You are responsible for caching or storing the resulting audio files.

How do I rotate my API key?

You can issue a new key at any time from your account page. When a new key is generated, the old one stops working immediately. This allows you to rotate keys securely without downtime. Ensure your integration updates to the new key promptly to avoid interruptions.

First request

curl

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

Sign up on the /get-api-key/ page using Google or an email/password account. The process is instant, granting access to your dashboard where your API key, balance, and usage stats are displayed immediately.

Sign Up Process

Sign Up Process

Accounts are created per site. If you use Google, you receive a $0.50 trial credit valid for 7 days. Email-based accounts start with zero credit.

Key Management

Key Management

Each account holds one active API key starting with "tts-". You can view your current key, balance, and character usage directly in the dashboard. Ensure your key is kept secure in your game's build settings or server environment.

  • One active key per account
  • Starts with "tts-"
  • Viewable in dashboard

Key Rotation

You can issue a new key at any time. The old key stops working immediately, ensuring no overlap or accidental usage during rotation. This is useful if you suspect a key was exposed in your game client.

First Request with cURL

Sound wave illustration for: First Request with cURL

To generate NPC dialogue, send a POST request to the speech endpoint with your text and voice parameters. The API returns the audio file in the response body.

Use the provided JSON body to define the model, input text, and desired voice. This straightforward structure ensures quick integration for content creators who need human-sounding dialogue without complex configuration overhead.

JSON Body Structure

The request body is a standard JSON object containing the text to be synthesized and the voice preset to use. You can also specify the output format and playback speed to match your game's audio requirements.

  • model: "tts-1" or "tts-1-hd"
  • input: The text string (up to 4096 characters)
  • voice: One of the 8 available presets (e.g., "aria", "atlas")
  • response_format: "mp3", "wav", "opus", "flac", or "pcm"
  • speed: Float between 0.25 and 4.0

Required Fields

Every request must include the model, input, and voice fields. The input field accepts plain text up to 4096 characters, which is sufficient for most single NPC lines. If the text exceeds this limit, split it into multiple requests.

  • model: Required; choose "tts-1" or "tts-1-hd"
  • input: Required; your dialogue text
  • voice: Required; select from the 8 presets
  • response_format: Optional; defaults to mp3
  • speed: Optional; defaults to 1.0

Response Format

A successful request returns the audio file directly in the response body with the specified format. If synthesis fails, you receive a JSON error object, and no charges are applied to your balance. Failed requests are refunded in full.

Using the OpenAI SDK

Sound wave illustration for: Using the OpenAI SDK

The OpenAI SDKs work seamlessly with Ufacamth Audio because we mirror the official speech endpoint structure. You only need to adjust the base URL to point to our API instead of OpenAI's servers, keeping your existing integration logic intact.

Base URL Configuration

Update your SDK client’s base URL to https://api.ufacamth.com/v1. This single change directs all requests to our infrastructure while maintaining the standard JSON request shape.

SDK Compatibility

The official OpenAI SDKs are fully compatible. Since our endpoint accepts the same fields (model, input, voice, etc.), you can use the same Python or Node.js libraries you are already familiar with.

Code Example

Here is a minimal Python example using the OpenAI SDK to generate NPC dialogue: ```python from openai import OpenAI client = OpenAI( base_url="https://api.ufacamth.com/v1", api_key="tts-your-api-key-here" ) audio = client.audio.speech.create( model="tts-1", voice="nova", input="Welcome to the tavern, traveler." ) audio.stream_to_file("npc_dialogue.mp3") ``` This code generates a warm, clear narration suitable for game interfaces.

Supported Audio Formats

Sound wave illustration for: Supported Audio Formats

Choose the audio format that best fits your game’s pipeline. MP3 offers efficient storage for general use, while WAV provides uncompressed audio for maximum fidelity during development or high-quality cutscenes.

MP3

Use mp3 for efficient storage. It reduces file size significantly without noticeable quality loss for most NPC dialogue, making it ideal for streaming or large game assets.

WAV

Select wav for uncompressed audio. This format preserves the full fidelity of the generated speech, which is useful when you need to apply further audio effects or processing in your engine.

OPUS, FLAC, PCM

OPUS provides excellent compression for real-time streaming with low latency. FLAC offers lossless compression, balancing file size and quality. PCM is raw uncompressed audio, useful for immediate processing without decoding overhead.

  • OPUS: Best for low-latency streaming
  • FLAC: Lossless compression
  • PCM: Raw, uncompressed data

Voice and Language Parameters

Sound wave illustration for: Voice and Language Parameters

Selecting the right voice is critical for NPC dialogue. Our eight presets cover diverse character archetypes, from warm narrators to deep documentary styles. Each voice is generated from licensed recordings, ensuring consistent, human-sounding quality for game assets.

The API allows you to specify the voice and optional language code. If language is omitted, Latin script defaults to English. For other languages, you must set the code explicitly to avoid misidentification.

Voice Selection

Choose from eight distinct voices tailored for different game genres. Options include 'aria' for clear narration, 'nova' for upbeat interactions, 'atlas' for neutral news-style updates, or 'orion' for deep, authoritative lines.

All voices support any of the 23 supported languages, allowing you to reuse a single voice model across multiple regions without retraining or additional setup.

  • 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

Language Code

Specify the ISO language code to ensure accurate pronunciation. While the system guesses language from script, explicit codes prevent errors for Latin-script languages other than English, such as German or Dutch.

Supported languages include Arabic, Chinese, French, Japanese, Spanish, and many others. Voices are not locked to specific languages; any voice can speak any supported language.

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

Speed Adjustment

Adjust speech rate between 0.25 and 4.0 to match pacing needs. Faster speeds work well for quick NPC responses or urgent dialogue, while slower rates suit exposition or emotional scenes.

Speed changes do not affect pricing or character count. The generated audio file will simply play at the specified rate, maintaining the original voice characteristics.

Voice and Language Parameters

Rate Limits and Quotas

Sound wave illustration for: Rate Limits and Quotas

Ufacamth Audio enforces strict rate limits to ensure fair usage across all game developers. Each API key is capped at 60 requests per minute, allowing you to batch NPC dialogue generation efficiently without overwhelming the service during peak production hours.

Requests Per Minute

The standard limit is 60 requests per minute per active key. This applies uniformly regardless of text length or audio format, ensuring predictable throughput for your integration pipeline.

Pre-Top-Up Limits

New accounts without an initial top-up are restricted to a lower limit of 10 requests per minute. This ensures stability while you test the API with your $0.50 trial credit before committing to USDT payments.

Queue Behavior

Requests are processed sequentially. If you exceed the limit or the server is busy, your request waits in a queue. Longer texts take more time to synthesize, so under heavy load, generation may take longer than usual.

Handling Errors

Sound wave illustration for: Handling Errors

When synthesis fails, you receive a standard HTTP error code with a descriptive message. Common issues include invalid characters, unsupported voice names, or exceeding the 4096-character limit per request.

Common Error Codes

Errors typically return a 400 (Bad Request) for malformed JSON or invalid parameters, and 429 (Too Many Requests) if you exceed the rate limit of 60 requests per minute.

  • 400: Invalid JSON or missing required fields
  • 401: Invalid or expired API key
  • 429: Rate limit exceeded (60 req/min)

Retry Logic

For transient errors like 429, implement exponential backoff. Since requests are processed sequentially, short delays often resolve queue congestion effectively.

Refund Policy

If synthesis fails, the charge is returned in full. You are only billed for successfully generated audio files.

Long Text Handling

Sound wave illustration for: Long Text Handling

The API accepts up to 4096 characters per request, including spaces and punctuation. For longer dialogues, split your text into chunks that fit this limit and send each as a separate request.

Character Limits

Each request is capped at 4096 characters. If your NPC’s monologue exceeds this, you must divide it into smaller segments before sending.

  • Count all characters, including spaces and punctuation.
  • Limit is per request, not per session.

Splitting Text

Divide your script into parts of up to 4096 characters. Send each part as an individual POST request to ensure reliable synthesis and clear error handling.

Audio Joining

Concatenate the returned audio files in the order of your original text. Since requests are processed sequentially, the audio segments will align naturally with your script structure.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. This uniformity simplifies budgeting for large-scale dialogue trees where multiple characters speak frequently.

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. LibriTTS-R paper (arXiv 2305.18802)
  4. LibriVox public-domain audiobooks
  5. Creative Commons Attribution 4.0
  6. openai-node on GitHub
  7. TRON developer hub: TRC-20
  8. Tether (USDT)
  9. FFmpeg documentation
  10. MDN: Web Speech API
  11. W3C WAI: making audio and video accessible
  12. openai-python on GitHub

More on this site