Text-to-Speech API: Quickstart & Examples for Game Developers

By LineVoice editorial team · Updated 2026-11-18

This guide provides concrete, step-by-step instructions for indie game developers integrating LineVoice’s text-to-speech API into Unity, Unreal, or browser-based engines. You will find exact request examples, parameter details, and workflow tips for generating natural-sounding NPC dialogue using licensed voices without complex pipelines.

Learn how to authenticate with a Bearer token, select models like tts-1-hd, and handle responses in MP3, WAV, or FLAC. We cover character limits, speed multipliers, language detection, and rate limits. The documentation focuses on practical implementation details, helping you generate audio efficiently for game assets with clear, specific examples.

Text-to-Speech API: Quickstart & Examples for Game Developers

Frequently asked questions

What is the API endpoint?

Send POST requests to https://api.dior678app.com/v1/audio/speech. Include your text in the JSON body with the required fields like model, voice, and input. The API returns the generated audio file directly in the response, allowing you to integrate it into your game’s audio pipeline.

How do I authenticate?

Include your API key in the request header as Authorization: Bearer tts-... You receive one active key per account. If needed, you can issue a new key at any time, which immediately invalidates the previous one, ensuring secure access to the TTS service for your game projects.

Can I use the OpenAI SDK?

Yes. The request shape matches the OpenAI speech endpoint exactly. You can use the official OpenAI SDKs by simply changing the base_url to https://api.dior678app.com/v1 and providing your LineVoice key. This allows for easy integration into existing codebases without learning a new library structure.

What base URL should I use?

Configure your client to use https://api.dior678app.com/v1 as the base URL. This applies whether you are using plain HTTP requests or the OpenAI SDK. All endpoints, including speech generation and voice listing, are prefixed with this base URL for consistent API access.

What models are available?

Two models are available: tts-1 and tts-1-hd. Both use the same engine and pricing structure. You can choose either based on your preference, as both use the same engine and price.

What is the difference between models?

There is no difference in price between tts-1 and tts-1-hd; they use the same engine. They use the same engine and cost the same amount per character. The distinction is purely naming; you can use either model ID interchangeably without affecting the output quality or your billing balance.

How do I set the language?

Pass the optional ISO language code in the request body. This ensures accurate pronunciation for non-English Latin-script text. While the system can guess the language, explicitly setting it prevents errors and guarantees the correct voice output for your NPCs, especially when using mixed-language dialogues.

What if I don't set the language?

The system guesses the language from the script. Latin script defaults to English. For other languages using Latin characters, you should explicitly set the language parameter to avoid incorrect pronunciation. This ensures your NPC dialogue sounds natural and matches the intended language of the game text.

What speeds are supported?

You can adjust the speech speed between 0.25 and 4.0. This allows you to create varied NPC personalities, from slow, deliberate speech to fast, energetic delivery. The speed parameter is part of the JSON body sent to the speech endpoint, giving you precise control over audio timing.

What audio formats can I request?

You can request audio in mp3, wav, opus, flac, or pcm formats. Choose the format that best fits your game engine’s requirements. MP3 and Opus are compressed formats, while WAV and FLAC offer lossless quality. PCM is available for raw audio processing needs.

What is the character limit?

Each request supports up to 4096 characters of input text. For longer dialogues, split the text into parts of this size and join the resulting audio files. This limit applies per request, so plan your API calls accordingly to handle extensive NPC dialogue sequences efficiently.

What are the rate limits?

You are limited to 60 requests per minute per key. Before your first top-up, the limit is 10 requests per minute. If your game generates many lines quickly, requests may queue. Monitor your usage to ensure smooth playback during intense gameplay moments without hitting these limits.

How do I handle errors?

Check the HTTP status code and response body for error details. Common issues include invalid keys, rate limits, or malformed JSON. Implement retry logic with exponential backoff for transient errors. Requests are processed sequentially, so high load may cause delays; handle timeouts gracefully in your game client.

Do failed requests cost money?

No. If synthesis fails, the charge is returned in full. You only pay for successful audio generation. This ensures you are not billed for errors, making the API cost-effective for testing and production environments in your game development workflow.

First request

curl

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

Access the /get-api-key/ page to create your LineVoice account. You can register using Google or a standard email and password combination. This step initializes your account on dior678app.com and prepares your dashboard for API key management.

Once registered, you will receive a unique API key. This key authenticates your requests to the speech endpoint. Keep it secure, as it allows access to your character balance and usage history.

Sign Up on /get-api-key/

Sign Up on /get-api-key/

Navigate to the /get-api-key/ page on dior678app.com. Click the sign-up button to begin the registration process. You will be directed to a secure form where you can choose your preferred authentication method.

Generate Key via Google

Select the Google sign-in option. You will be redirected to Google’s authentication page to grant permission. Upon successful verification, your account is created instantly, and a $0.50 free trial credit is added. This credit covers approximately 50,000 characters and is valid for 7 days.

Your API key appears on the dashboard immediately. You can copy it for use in your Unity or Unreal Engine projects.

  • Instant account creation
  • $0.50 trial credit added automatically
  • 7-day validity period

Generate Key via Email

Choose the email and password option. Enter your email address and create a secure password. You may need to verify your email address via a confirmation link sent to your inbox.

After verification, your account is created without the trial credit. You can generate your API key from the dashboard and begin integrating the TTS API into your game pipeline.

  • Requires email verification
  • No trial credit included
  • Standard account setup

Authentication

Sound wave illustration for: Authentication

Authentication is handled via a single active Bearer token per account. Include this key in every request to prove ownership and track usage against your balance.

Bearer Token Header

Include your key in the HTTP header as follows: Authorization: Bearer tts-.... The API validates this token against your account to authorize the request and deduct characters from your balance.

Key Format

Keys start with the prefix tts- followed by a unique string. You can view your current key on the /get-api-key/ dashboard page alongside your balance and usage stats.

  • Prefix: tts-
  • Single active key per account
  • Viewable in your account dashboard

Key Rotation

You may issue a new key at any time via the dashboard. When a new key is generated, the previous one stops working immediately, ensuring secure access management without downtime.

Speech Endpoint

Sound wave illustration for: Speech Endpoint

Use the POST method to send text data and receive synthesized audio. This single endpoint handles all speech generation requests for your game’s NPC dialogue or narration.

POST Method

Send a JSON payload containing your text, voice selection, and format preferences. The server processes the request and returns the audio file directly in the response body.

Base URL

Direct all requests to https://api.dior678app.com/v1/audio/speech. This base URL works with the official OpenAI SDKs by setting the base_url configuration, allowing you to use familiar client libraries in Unity or Unreal.

Request Body

The request body is a JSON object. Required fields include model ("tts-1" or "tts-1-hd"), input (your text string), and voice (one of the 8 presets). You may also specify response_format (mp3, wav, opus, flac, pcm) and speed (0.25–4.0).

Keep text under 4096 characters. For longer dialogues, split the text into chunks, generate each audio file, and concatenate them in your game engine.

Request Parameters

Sound wave illustration for: Request Parameters

Configure the core parameters for your synthesis request. The API accepts specific models, character limits, and voice presets to generate audio that fits your game's needs.

Model Selection

Select either "tts-1" or "tts-1-hd". Both use the same engine and pricing, so choose based on your preference without affecting cost.

Input Text Limits

Each request accepts up to 4096 characters. For longer NPC dialogues, split your text into chunks and join the resulting audio files.

Voice Selection

Choose from eight licensed presets like Aria for narration or Felix for promos. Each voice supports all 23 languages, allowing consistent character voices across different linguistic regions.

  • Aria: Warm, clear narrator
  • Nova: Bright, upbeat
  • Luna: Soft, storytelling
  • Sage: Calm, instructional
  • Felix: Energetic, promo
  • Milo: Friendly, conversational

Response Formats

Sound wave illustration for: Response Formats

The API returns synthesized audio directly in the HTTP response body. This design allows game engines to receive binary data without managing temporary files or complex download logic. The response includes standard headers indicating the content type and length.

You can choose from five supported audio formats to balance quality and file size for your specific use case. Each format serves different needs, from streaming compatibility to high-fidelity storage.

Audio File Return

The response body contains the raw audio bytes. No JSON wrapper surrounds the audio data itself, ensuring minimal parsing overhead for your game client.

The Content-Type header matches the requested format, allowing standard HTTP clients to handle the response correctly without additional configuration.

Supported Formats

Select the format that best fits your engine’s audio pipeline. Common choices include MP3 for broad compatibility or WAV for uncompressed quality.

Other options like Opus, FLAC, and PCM offer specific trade-offs between compression efficiency and processing speed for different platforms.

  • mp3
  • wav
  • opus
  • flac
  • pcm

Binary Response

Treat the response as a binary stream. Directly feed this data into your engine’s audio loader or save it to a local asset folder for later use.

Response Formats

Speed and Language

Sound wave illustration for: Speed and Language

Adjust the voice speed with the speed parameter (0.25–4.0) to match NPC pacing. Faster speeds suit rapid dialogue; slower rates enhance dramatic pauses.

Set the language field using an ISO code (e.g., 'en', 'de', 'ja') to ensure accurate pronunciation. This overrides auto-detection for precise control.

Speed Multiplier

The speed parameter accepts values from 0.25 to 4.0. Use 1.0 for normal speech. Higher values accelerate delivery for energetic characters like Felix. Lower values slow narration for atmospheric storytelling with Luna.

Speed adjustments apply uniformly. Test edge cases near 0.25 or 4.0 to maintain intelligibility for your specific voice preset.

  • Min speed: 0.25x
  • Max speed: 4.0x
  • Default: 1.0

Language Code

Pass the language field (e.g., 'fr', 'es', 'ko') to force pronunciation for any of the 23 supported languages. Any voice can speak any supported language.

Explicitly setting the language prevents mispronunciation, especially for non-English Latin text or mixed-script inputs.

  • 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-Detection

If language is omitted, the API guesses the language from the text script. Latin script defaults to English.

For non-English text using Latin characters (e.g., German or Spanish), always set the language code to avoid incorrect English pronunciation.

Rate Limits

Sound wave illustration for: Rate Limits

Each API key processes requests sequentially, which means your synthesis jobs are handled one after another. For long texts split into multiple parts, the queue ensures order but may introduce slight delays if under load.

Requests Per Minute

The standard rate limit is 60 requests per minute per key. Since requests are processed sequentially, a burst of short phrases will queue up rather than fail immediately.

Initial Limit

New accounts without a top-up start with a lower limit of 10 requests per minute. This prevents rapid exhaustion of the free trial credit.

Limit After Top-Up

Once you top up your balance with USDT (TRC-20) (minimum $5), the limit increases to the standard 60 requests per minute. Credits are applied automatically within minutes.

Error Handling

Sound wave illustration for: Error Handling

The API returns standard HTTP status codes to indicate success or failure. A 200 OK response confirms that the audio file has been generated and is ready for download. Any other code indicates an issue that requires attention.

HTTP Status Codes

Use 401 Unauthorized if your API key is missing or invalid. A 429 Too Many Requests signal means you have exceeded the per-minute limit. Check your dashboard for current usage stats.

  • 400: Bad Request (invalid JSON or parameters)
  • 401: Unauthorized (invalid or expired key)
  • 429: Too Many Requests (rate limit exceeded)
  • 500: Internal Server Error (transient engine issue)

Retry Logic

Implement exponential backoff for 429 and 500 errors. Start with a short delay, such as one second, and double it with each retry. This prevents overwhelming the engine during high load.

  • Retry on 429 and 500 errors only
  • Use exponential backoff (e.g., 1s, 2s, 4s)
  • Max retries: 3 attempts per request
  • Do not retry 400 or 401 errors

Failed Request Refund

If synthesis fails, the charge is returned in full. You are not billed for audio that is not delivered. Check your balance in the dashboard after a failure.

FAQ

Sound wave illustration for: FAQ

The following answers address specific implementation details for integrating LineVoice into your game’s dialogue system.

What is the API endpoint?

Use POST https://api.dior678app.com/v1/audio/speech to generate audio from text.

How do I authenticate?

Include an Authorization header with your Bearer token: Authorization: Bearer tts-....

Can I use the OpenAI SDK?

Yes. Change the SDK’s base_url to https://api.dior678app.com/v1 and use your LineVoice key.

What base URL should I use?

The API base is https://api.dior678app.com/v1.

What models are available?

Available models are tts-1 and tts-1-hd.

What is the difference between models?

Both use the same engine and price; choose based on quality preference.

How do I set the language?

Pass the optional language parameter with an ISO code (e.g., 'en', 'de').

What if I don't set the language?

The system guesses from the script; Latin text defaults to English.

What speeds are supported?

Speed ranges from 0.25 to 4.0.

What audio formats can I request?

Request mp3, wav, opus, flac, or pcm.

What is the character limit?

Each request supports up to 4096 characters.

What are the rate limits?

Limit is 60 requests per minute per key (10 before top-up).

How do I handle errors?

Check HTTP status codes and implement retry logic for transient failures.

Do failed requests cost money?

No. Failed requests are free with a full charge return.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Her tone is approachable and steady, making her ideal for characters who need to convey information without emotional intensity.

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

More on this site