Quickstart Guide: Integrate TTS into Your Game Projects

By EchoSprite editorial team · Updated 2026-11-18

This guide walks game developers through integrating EchoSprite’s text-to-speech API into NPC dialogue systems. You will learn to generate high-quality audio files from text using a simple HTTP endpoint that mirrors the OpenAI speech format. We cover everything from obtaining your API key to handling rate limits and errors, ensuring you can scale dialogue generation for your startup without managing complex infrastructure.

Readers will find concrete examples for cURL, Python, and other languages, along with details on voice selection, speed control, and language support. Whether you are prototyping a single character or scaling to thousands of lines, this reference helps you implement reliable, cost-effective synthetic speech that fits directly into your existing game engine workflows.

Quickstart Guide: Integrate TTS into Your Game Projects

Frequently asked questions

How do I get an API key?

Sign up on /get-api-key/ using Google or email. You receive one active key per account. You can issue a new key anytime, which immediately invalidates the old one. The dashboard displays your key, balance, and usage details for immediate integration into your game’s audio pipeline.

Can I use the OpenAI SDK?

Yes. The endpoint shape matches the OpenAI speech endpoint. Use the official OpenAI SDKs by changing the base_url to https://api.play48x.com/v1 and providing your site’s key. This allows you to leverage existing client libraries without writing custom HTTP request logic for your NPC dialogue system.

What is the base URL?

The API base URL is https://api.play48x.com/v1. Use POST https://api.play48x.com/v1/audio/speech for synthesis. Other endpoints include GET /v1/voices for available options and GET /v1/models. Ensure your client configuration points to this domain to route requests correctly to the EchoSprite infrastructure.

How do I set the voice?

Include the voice field in your JSON body with one of eight presets: aria, nova, luna, sage, felix, milo, atlas, or orion. Each voice supports all 23 languages. If unspecified, the system guesses the language from the script, defaulting to English for Latin text.

What formats are supported?

Specify response_format as mp3, wav, opus, flac, or pcm. These formats cover standard game engine requirements. MP3 and Opus are efficient for bandwidth, while WAV and FLAC offer lossless quality. PCM provides raw audio data for custom processing pipelines within your game’s audio middleware.

How do I adjust speed?

Use the speed field with a value between 0.25 and 4.0. This allows you to speed up or slow down the NPC dialogue without re-synthesizing audio. Adjustments are applied during generation, helping you match the pacing of your game’s cutscenes or interactive dialogue sequences.

What are the rate limits?

You are limited to 60 requests per minute per key, or 10 per minute before your first top-up. Requests are processed sequentially, so load may cause queuing. Monitor your dashboard for usage stats. Failed requests do not incur charges.

How do I handle errors?

Failed synthesis requests are free, with charges returned in full. If an error occurs, check your input text length (max 4096 characters) and voice validity. The API returns standard HTTP error codes. Ensure your authentication header is correct and your balance covers the request cost.

First request

curl

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

Accessing the EchoSprite API requires a valid authentication key. This key authorizes your game server to send text and receive synthesized audio files. You manage credentials through your account dashboard, where you can also track usage and balance.

Obtaining your key is the first step in integrating NPC dialogue. The process is straightforward and designed to get developers into the API quickly without unnecessary overhead.

Sign up on /get-api-key/

Sign up on /get-api-key/

Navigate to the /get-api-key/ page on play48x.com. This is the dedicated entry point for acquiring your API credentials. The page displays your current key, balance, trial status, and a ready-to-use cURL example for immediate testing.

  • View your active API key
  • Check remaining character balance
  • See usage statistics
  • Copy ready-made cURL examples

Use Google or email registration

Use Google or email registration

You can register using your Google account for quick access, or create a standard account with an email and password. Accounts are specific to the play48x.com site. Google sign-ups include a $0.50 free trial credit valid for 7 days, equivalent to about 50,000 characters. Email-based accounts start with zero balance.

  • Google sign-up includes free trial
  • Email registration available
  • Instant account creation
  • No credit card required

One active key per account

Each account maintains a single active API key. If you need to revoke access or rotate credentials, you can issue a new key at any time. The old key stops working immediately upon issuance of the new one, ensuring tight control over your game's audio requests.

  • Single active key
  • Instant revocation
  • Easy key rotation
  • Secure credential management

First request with cURL

Sound wave illustration for: First request with cURL

Generate NPC dialogue instantly by sending a POST request to the TTS endpoint. This method works for any game engine or backend service that supports standard HTTP calls.

The request body must include the text to be synthesized, the chosen voice preset, and the output format. The API returns a binary audio file that you can directly play in your game's audio engine.

Send POST request to endpoint

Direct your HTTP client to POST https://api.play48x.com/v1/audio/speech. Include your API key in the Authorization header as Bearer <your_key>. This endpoint accepts JSON payloads and returns raw audio data.

  • Endpoint: POST https://api.play48x.com/v1/audio/speech
  • Header: Authorization: Bearer <your_key>

Include model and voice parameters

Set the model to either tts-1 or tts-1-hd for consistent pricing and quality. Choose one of the eight available voices, such as aria or atlas, to define the character's tone. Specify the response_format (mp3, wav, opus, flac, or pcm) to match your game's audio pipeline.

Receive audio file in response

The API returns the synthesized audio as a binary stream. Save this data to a temporary file or feed it directly into your game's audio player. If the request fails, you are not charged, allowing for safe retries.

OpenAI SDK integration

Sound wave illustration for: OpenAI SDK integration

Leverage your existing OpenAI SDK infrastructure to integrate EchoSprite’s TTS into your game engine with minimal code changes. The API mirrors the standard speech endpoint structure, allowing you to swap dependencies without rewriting your audio generation logic.

This compatibility ensures that developers familiar with OpenAI’s client libraries can immediately start generating NPC dialogue using their preferred language bindings, reducing onboarding time for new team members.

Change base_url to api.play48x.com

Initialize your OpenAI SDK client by overriding the default base URL. Point it to https://api.play48x.com/v1 instead of the standard OpenAI endpoint. This directs all subsequent API calls to the EchoSprite infrastructure while maintaining the standard request format.

Use official OpenAI SDKs

Utilize the official OpenAI SDKs for Python, Node.js, or other supported languages. Authenticate using your EchoSprite API key in the Authorization header. The SDK handles serialization and error parsing exactly as it would for native OpenAI requests.

Same request shape as OpenAI

Send a POST request to /v1/audio/speech with the same JSON structure: model, input, voice, and response_format. The parameters behave identically, ensuring that your existing game logic for text-to-speech generation requires no structural adjustments.

Supported parameters

Sound wave illustration for: Supported parameters

The model parameter accepts either tts-1 or tts-1-hd, both using the same engine and pricing. This simplifies integration, as switching quality does not require code changes beyond the model name. The voice field selects from eight distinct presets, allowing you to assign specific character voices directly in your game logic. You can map aria for narrators or atlas for news-style updates without additional configuration.

The response_format parameter determines the audio output, supporting mp3, wav, opus, flac, and pcm. This flexibility ensures compatibility with various game engines and audio pipelines. Since requests are processed sequentially, selecting the appropriate format helps manage bandwidth and storage efficiently during bulk NPC dialogue generation.

Model: tts-1 or tts-1-hd

The model field accepts tts-1 or tts-1-hd. Both use the same underlying engine and pricing structure, making it easy to swap quality levels without changing your integration code. This uniformity reduces testing overhead when optimizing audio assets for different game scenes.

Using tts-1-hd may result in slightly higher quality output, but the processing time is similar to tts-1. Since requests are queued under load, choosing the right model helps balance quality and latency for real-time NPC interactions.

  • - tts-1: Standard quality, consistent pricing
  • - tts-1-hd: High definition, same price
  • - Both use identical engine logic

Voice: one of 8 presets

Select from eight voice presets to match your game’s tone. aria offers a warm, clear narration style, while nova provides a bright, upbeat delivery. For more specific roles, luna suits storytelling, and sage delivers calm, instructional dialogue.

Male voices include felix for energetic promos, milo for conversational interactions, atlas for neutral news updates, and orion for deep documentary styles. Each voice is based on licensed recordings, ensuring consistent quality across all generated audio files.

  • - Female: aria, nova, luna, sage
  • - Male: felix, milo, atlas, orion
  • - All voices support all 23 languages

Response format: mp3, wav, opus, flac, pcm

The response_format parameter allows you to choose between mp3, wav, opus, flac, and pcm. This ensures compatibility with various game engines and audio pipelines. MP3 and OPUS are ideal for reducing bandwidth, while WAV and FLAC provide lossless quality for high-fidelity audio needs.

PCM offers raw audio data, useful for specific processing pipelines. Each format is returned directly in the API response, allowing you to save the audio file immediately without additional conversion steps.

  • - MP3: Compact, widely supported
  • - WAV: Lossless, high quality
  • - OPUS: Efficient compression
  • - FLAC: Lossless, smaller size
  • - PCM: Raw audio data

Speed and language

Sound wave illustration for: Speed and language

Adjust the generation speed between 0.25 and 4.0 to match your game’s pacing. Slower speeds clarify dialogue for complex instructions, while faster rates suit rapid-fire NPC chatter. This flexibility ensures audio aligns precisely with your animation timelines without requiring post-processing.

Set the language using an ISO code to guarantee accurate pronunciation. If omitted, the system guesses the language from the text script. For non-English Latin script, always specify the language parameter to avoid misinterpretation of accented characters or proper nouns.

Speed range: 0.25 to 4.0

Use the speed parameter to control voice pacing. Values range from 0.25 (slow) to 4.0 (fast). This allows fine-tuning for different character types, from elderly narrators to excited robots, ensuring consistent audio quality across varied dialogue speeds.

Optional ISO language code

Include the language field with a valid ISO code (e.g., 'es', 'fr', 'de') to force a specific language output. This is critical for multilingual games or when sending text in a language that might otherwise be misidentified by the auto-detection logic.

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

Auto-detect for Latin script

If you do not provide a language code, the system infers the language from the text script. Latin script defaults to English. For accurate results with other Latin-based languages, always explicitly set the language parameter to prevent fallback to English pronunciation.

Speed and language

Rate limits

Sound wave illustration for: Rate limits

Rate limits protect API stability by capping usage at 60 requests per minute per key. This ensures consistent performance for your game's dialogue generation. If you exceed this threshold, requests are processed in queue order rather than being immediately rejected.

The limit depends on your account status. Before your first top-up, you are limited to 10 requests per minute. This lower limit applies before the first top-up. Once a top-up is processed, the limit increases to the standard 60 req/min. This applies to both free trial and paid accounts.

60 requests per minute per key

Each API key allows up to 60 requests per minute. This limit is enforced server-side and applies to all endpoints. Exceeding this cap triggers a 429 status code.

Requests are processed sequentially under heavy load. Longer texts may take time to synthesize, potentially queuing subsequent requests until previous ones complete.

  • Standard limit: 60 requests/minute
  • Enforced per API key
  • Queued during high load

10 requests before first top-up

New accounts start with a 10 requests per minute limit. This applies to both free trial and paid accounts until a successful USDT transfer is confirmed.

This lower limit helps manage initial load while users test the service. Once a top-up is processed, the limit increases to the standard 60 req/min. This applies to both free trial and paid accounts until a successful USDT transfer is confirmed.

Queue under heavy load

When many requests are active, new ones join a queue. Processing is sequential, so wait times increase with load. Short phrases take seconds; long texts take longer.

Plan your voice lines accordingly. For real-time NPC dialogue, consider pre-generating lines or buffering audio assets to minimize latency during peak usage.

Error handling

Sound wave illustration for: Error handling

API responses include standard HTTP status codes to indicate success or failure. A 200 OK means the audio file is ready, while 4xx errors indicate client-side issues like invalid keys or parameters.

Always inspect the response body for specific error messages to debug integration issues quickly before proceeding to playback or storage.

Check status codes

Monitor the HTTP status code in your response headers. A 200 status confirms successful synthesis, while 400–499 codes indicate client errors such as missing fields or invalid voice IDs.

Use these codes to route errors appropriately in your game's debug logs or UI without crashing the audio pipeline.

Failed requests are free

If synthesis fails due to server errors or invalid input, you are not charged for that attempt. The character count remains unchanged, and your balance is unaffected.

This ensures you only pay for successfully generated audio files, reducing risk during development and testing phases.

Retry with exponential backoff

Implement exponential backoff for transient errors like 429 (Too Many Requests) or 500 (Internal Server Error). This prevents overwhelming the API during peak loads.

Start with a short delay and double it after each failed attempt, up to a reasonable maximum, to ensure reliable delivery of NPC dialogue.

  • Wait 1 second after the first failure
  • Double the wait time for subsequent retries
  • Cap maximum wait time at 60 seconds

Voices endpoint

Sound wave illustration for: Voices endpoint

The /v1/voices endpoint provides a complete list of available voices, their supported languages, and compatible audio formats. This allows your game to dynamically update voice options based on player preferences or regional settings without hardcoding values.

Use this endpoint to verify which voices support specific languages like Arabic, Hindi, or Japanese before attempting synthesis.

It also confirms available output formats such as mp3, wav, opus, flac, or pcm for your audio pipeline.

GET /v1/voices for list

Send a GET request to /v1/voices to retrieve all 8 presets. Each entry includes the voice ID, gender, and description (e.g., aria, nova, luna, sage, felix, milo, atlas, orion). This list is static and does not change frequently, so cache the response locally in your game client or backend.

The response includes metadata about each voice, helping you select the right tone for NPCs.

  • Returns a JSON array of voice objects.
  • Each object contains voice ID, gender, and description.
  • Use this data to populate UI dropdowns for player voice selection.

Check language support

Each voice can speak any of the 23 supported languages, including English, German, Spanish, and Korean. Verify the language code (ISO 639-1) in the voice object to ensure compatibility with your target market.

If the language field is omitted in the speech request, the system guesses the language from the script. For non-English Latin-script text, always set the language parameter explicitly to avoid incorrect synthesis.

Not supported languages like Vietnamese, Indonesian, or Thai will return an error if specified. Use the /v1/voices response to filter available languages dynamically.

  • All 8 voices support all 23 listed languages.
  • Latin text defaults to English if language is unset.
  • Explicitly set language for non-English Latin text to ensure accuracy.

Verify format availability

The /v1/voices response includes the supported response_format options for each voice. All voices support mp3, wav, opus, flac, and pcm.

Choose the format based on your game engine’s audio processing capabilities. MP3 is ideal for small file sizes, while WAV or FLAC offers lossless quality for high-fidelity soundtracks.

PCM is available for raw audio processing if needed. Ensure your audio pipeline can handle the selected format before making synthesis requests.

  • All voices support mp3, wav, opus, flac, and pcm.
  • MP3 is recommended for small file sizes.
  • WAV/FLAC provide lossless quality for soundtracks.
  • PCM is available for raw audio processing.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Our AI powers lifelike non-player characters that drive immersive gaming experiences for the next generation of interactive entertainment startups.

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

More on this site