Quickstart Guide to the TTS API for Developers

By LinguaScript editorial team · Updated 2026-11-18

This guide helps indie mobile developers integrate LinguaScript’s text-to-speech API into iOS and Android apps. You will find exact request structures, language support details, and pricing facts to evaluate engine suitability for your project.

We cover curl examples, OpenAI SDK configuration, and parameter limits. Read on for concrete integration steps, rate limit handling, and audio format comparisons to choose the right voice and codec for your app’s user experience.

Quickstart Guide to the TTS API for Developers

Frequently asked questions

How do I get an API key?

Sign up on the /get-api-key/ page using Google or email with a password. Your account is specific to this site. The dashboard displays your active API key, current balance, and usage statistics immediately after registration.

Can I use the OpenAI SDK?

Yes. The API endpoint matches the OpenAI speech endpoint shape. You can use official OpenAI SDKs by changing the base_url to https://api.pk6app.com/v1 and providing your LinguaScript API key for authentication.

What is the base_url?

The API base URL is https://api.pk6app.com/v1. Use this for all requests, including the speech endpoint at /v1/audio/speech and the voices listing at /v1/voices.

How do I split long texts?

Split your input text into parts of up to 4096 characters each. Send each part as a separate POST request to the speech endpoint. You must then join the resulting audio files client-side to create the final output.

What audio formats are available?

You can request audio in mp3, wav, opus, flac, or pcm formats. Specify your preferred format using the response_format field in your JSON request body. All formats are generated using the same engine and pricing.

What are the rate limits?

You are limited to 60 requests per minute per API key. New accounts start with a limit of 10 requests per minute. This limit resets every minute.

How do I handle errors?

If synthesis fails, the charge is returned in full. Check the HTTP status code and response body for details. Failed requests do not consume your character balance or billing credits.

Is streaming supported?

No streaming or WebSocket support is available. The API returns the complete audio file in the response after processing. You must wait for the full file before playing or saving it.

Does the API support SSML?

No SSML support is provided. You send plain text in the input field. There are no SSML tags for controlling pauses, emphasis, or pronunciation within the text payload.

Can I customize pronunciation?

No custom pronunciation lexicons or phoneme dictionaries are available. You must rely on the standard pronunciation of the selected voice. There is no way to override how specific words are spoken.

How do I rotate my API key?

You can issue a new API key at any time via your dashboard. The old key stops working immediately when the new one is generated. Only one key is active per account.

What is the character limit?

Each request supports up to 4096 characters in the input field. Spaces and punctuation count toward this limit. For longer texts, split the content into multiple requests of this size.

How do I join audio files?

The API does not join audio files server-side. You must split long texts into chunks, download each audio response, and concatenate them using your own code or audio library.

What happens if I exceed limits?

Requests are processed sequentially. If you exceed the rate limit, your request may wait in a queue or be rejected. Under load, processing may take longer than usual due to queuing.

First request

curl

curl https://api.pk6app.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.pk6app.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.pk6app.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 on pk6app.com to create your account. You can sign in instantly using Google or register with an email and password. This step initializes your account on the LinguaScript network.

Once authenticated, the dashboard displays your active API key, current balance, and usage statistics. This key authenticates all requests to the TTS engine.

Sign up with Google or email

Sign up with Google or email

Create an account via Google or email/password. Google sign-ups receive a $0.50 free trial valid for 7 days. Email accounts start without trial credit.

The account is specific to this storefront site. You do not need to manage subscriptions or seats.

  • Google sign-in provides $0.50 trial credit
  • Email sign-in starts with zero balance
  • No monthly plans or subscriptions required

Locate key in dashboard

Locate key in dashboard

The dashboard immediately shows your active API key starting with 'tts-'. Use this key in the Authorization header of your requests.

You can view your current balance, characters used, and a ready-to-use cURL example directly in this interface.

  • Key format: Bearer tts-...
  • View balance and usage stats
  • Copy-ready cURL examples provided

Rotate keys if needed

You can issue a new API key at any time from the dashboard. The old key stops working immediately upon rotation.

This allows you to revoke compromised keys without losing your account or balance data.

  • Issue new key anytime
  • Old key stops instantly
  • No downtime during rotation

First Request with Curl

Sound wave illustration for: First Request with Curl

Generate speech with a single HTTP POST request. The API accepts plain text and returns audio directly, requiring no complex infrastructure. This approach works for both iOS and Android backends.

Use the curl example below to verify your API key and get your first audio file. Replace YOUR_API_KEY with your actual credential from the dashboard.

Basic curl example

Run this command in your terminal to synthesize text into an MP3 file.

The request sends your text to the endpoint and saves the resulting audio to speech.mp3.

  • -H "Authorization: Bearer YOUR_API_KEY" authenticates the request.
  • -d '{...}' sends the JSON payload with model, voice, and input text.

JSON body structure

The request body is a standard JSON object. It includes the model identifier, the text to speak, and the desired voice preset.

All fields are strictly defined. The input field accepts up to 4096 characters. The voice must be one of the eight available presets.

  • model: "tts-1" or "tts-1-hd"
  • `input": "Your text here"
  • `voice": "aria"
  • `response_format": "mp3"

Response format

A successful request returns an HTTP 200 status code with the binary audio data in the response body. No JSON wrapper is used for the audio itself.

If the request fails, you receive an error JSON object with a status code and message. Failed synthesis requests are refunded automatically.

Using the OpenAI SDK

Sound wave illustration for: Using the OpenAI SDK

The OpenAI SDKs work directly with our API by changing the base_url to https://api.pk6app.com/v1. This allows you to use standard libraries for iOS and Android integration without learning a new client.

Configure your SDK instance with your API key and the adjusted base URL. You can then call the standard speech endpoint as you would with OpenAI, receiving audio files instantly.

Install OpenAI SDK

Install the official OpenAI SDK for your preferred language. This provides the necessary classes to handle JSON requests and audio responses efficiently.

  • pip install openai
  • npm install openai
  • gem install openai

Set base_url

Update the SDK configuration to point to our API endpoint. This ensures all requests route through our infrastructure while maintaining compatibility.

  • base_url="https://api.pk6app.com/v1"
  • api_key="tts-<your-key>"

Use standard speech endpoint

Call the /v1/audio/speech endpoint using the standard method. Pass your text, voice, and format preferences as parameters. The SDK handles the JSON serialization and audio download.

Request Parameters

Sound wave illustration for: Request Parameters

The API accepts a JSON payload with specific fields to control synthesis. You must define the model, input text, voice, and output format. Optional parameters like speed and language allow fine-tuning for your app’s needs.

Each parameter directly affects the resulting audio file. Use the correct model for your quality tier and ensure the input text respects the character limit to avoid errors.

Model: tts-1 or tts-1-hd

Both models use the same engine and pricing. Choose 'tts-1' for standard quality or 'tts-1-hd' for higher fidelity. The API handles the engine selection internally based on this field.

There is no performance difference in generation speed between the two models. Both support the same voice presets and languages.

  • Use 'tts-1' for cost-effective bulk generation
  • Select 'tts-1-hd' for premium audio quality

Input: text up to 4096 chars

The 'input' field accepts a single string of up to 4096 characters. Spaces and punctuation count toward this limit. Longer texts must be split into multiple requests.

Each request generates one audio file. You must join these files client-side for long narratives. Short phrases may take a few seconds to process.

  • Maximum length: 4096 characters per request
  • Includes spaces and punctuation in the count

Voice: 8 presets

Select from eight licensed voices, ranging from warm narrators to energetic promos. Every generated file carries an inaudible watermark that marks it as synthetic speech.

Voices are gendered by name but can speak any supported language. For example, 'aria' provides a clear, warm tone suitable for storytelling.

  • Female: aria, nova, luna, sage
  • Male: felix, milo, atlas, orion

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

Specify the desired audio format using the 'response_format' field. MP3 offers compressed, widely supported audio. WAV provides lossless quality but larger files.

OPUS is available as a response format. FLAC and PCM are available as response formats. The API returns the audio file directly in the response.

  • MP3: compressed, widely supported
  • WAV: lossless, large files
  • OPUS: efficient for mobile
  • FLAC and PCM: uncompressed options

Speed: 0.25–4.0

The 'speed' parameter adjusts the playback rate from 0.25 to 4.0. A value of 1.0 is normal speed. Faster speeds reduce generation time slightly but may affect clarity.

Slower speeds can enhance comprehension for complex content. Adjust this parameter to match your app’s user experience requirements.

  • Range: 0.25 to 4.0
  • Default: 1.0

Language: optional ISO code

The 'language' field is optional. If omitted, the API guesses the language from the script. Latin text defaults to English. Set this field for non-English Latin-script text.

All eight voices can speak all 23 supported languages. Setting the language explicitly ensures accurate pronunciation and intonation.

  • Optional ISO code
  • Defaults to English for Latin text

Audio Formats

Sound wave illustration for: Audio Formats

Selecting the right audio format impacts both user experience and data efficiency in mobile applications. The API supports five distinct output formats, allowing you to balance file size, quality, and compatibility based on your app’s specific needs.

MP3: compressed, widely supported

MP3 is the most universally supported format across iOS and Android devices. It offers a good balance between file size and audio quality, making it ideal for general-purpose narration or background speech in apps where bandwidth conservation is important.

WAV: lossless, large files

WAV provides uncompressed, lossless audio, preserving the full fidelity of the generated voice. This format is suitable for high-quality applications where file size is less critical than audio precision, though it results in significantly larger payloads.

OPUS: efficient for mobile

OPUS delivers high-quality audio at very low bitrates, making it highly efficient for mobile network transmission. It is an excellent choice for apps requiring low-latency playback or operating in constrained data environments.

FLAC and PCM options

FLAC offers lossless compression, reducing file size without sacrificing quality, while PCM provides raw, uncompressed audio data. These formats are best suited for professional editing workflows or specialized audio processing pipelines within your application.

Audio Formats

Rate Limits

Sound wave illustration for: Rate Limits

The API enforces a strict limit of 60 requests per minute per active key. This cap ensures stable performance for indie apps under variable load, preventing sudden spikes from degrading audio generation quality for other users.

60 requests per minute

Once your account is funded, you can process up to 60 synthesis requests per minute. This throughput is sufficient for most batch processing jobs and moderate real-time usage in mobile applications.

10 requests before top-up

New accounts start with a lower limit of 10 requests per minute. This restriction applies until you add your first top-up. Once credited, the limit automatically increases to the standard 60 req/min.

Handling rate limits

Exceeding the limit returns a 429 error. Implement exponential backoff in your client code to handle retries gracefully. Since requests are processed sequentially, under load, subsequent requests may also experience slight delays beyond the rate limit.

  • Monitor your dashboard for real-time usage stats.
  • Use the 7-day free trial credit ($0.50) to test limits without paying.
  • Rotate API keys if you need multiple independent rate limit buckets.

Error Handling

Sound wave illustration for: Error Handling

Our API returns standard HTTP status codes to indicate request outcomes. A 400 error typically means your input text exceeded the 4096-character limit or contained invalid parameters. A 429 error signals you have hit the rate limit of 60 requests per minute.

If synthesis fails due to server-side issues, the charge is returned in full. You only pay for successfully generated audio files.

Common error codes

Use 400 for bad requests (e.g., invalid JSON, missing fields). Use 401 if your Bearer token is missing or expired. Use 429 when you exceed 60 requests per minute, or 10 per minute before the first top-up.

  • 400 Bad Request: Check input length and format.
  • 401 Unauthorized: Verify your API key.
  • 429 Too Many Requests: Wait before retrying.

Failed request refunds

If the server cannot generate audio (e.g., internal error), the character count is not deducted from your balance. Credits are automatically restored to your account.

Retry logic

Implement exponential backoff for 429 errors. For transient 5xx errors, a simple retry after 1–2 seconds is usually sufficient. Avoid rapid retries to prevent queue congestion.

Integration Tips

Sound wave illustration for: Integration Tips

Integrating LinguaScript’s TTS API into mobile apps requires handling text length limits and network variability. By splitting input into 4096-character chunks, you ensure reliable synthesis and maintain consistent audio quality across iOS and Android platforms.

Joining the resulting audio segments seamlessly is crucial for a natural listening experience. Properly concatenating files prevents gaps or abrupt transitions, preserving the narrative flow for your end users.

Split long texts

The API accepts a maximum of 4096 characters per request. For longer content, divide the input string into segments that respect this limit before sending individual synthesis jobs.

This approach ensures that every request stays within bounds, avoiding silent failures or truncation of your app's audio output.

  • Max input length: 4096 characters
  • Count spaces and punctuation as characters
  • Split at natural sentence boundaries when possible

Join audio files

Once you receive the audio files from each chunked request, concatenate them in the correct order. Use a library compatible with your target platform (e.g., AVFoundation for iOS, MediaCodec for Android) to merge the files.

Ensure the audio formats match (e.g., all MP3 or all WAV) to avoid conversion artifacts during the join process.

  • Maintain original order of segments
  • Verify format consistency before merging
  • Test for seamless playback transitions

Handle queues

Requests are processed sequentially. Under load, a request may wait in a queue, potentially delaying playback start times. Implement exponential backoff for retries to avoid overwhelming the API.

Since typical generation speed is roughly real-time (25 characters per second), plan your app's buffer accordingly to prevent audio stuttering during playback.

Remember that failed requests are free, so retry logic does not incur extra costs if synthesis fails.

  • Implement exponential backoff for retries
  • Buffer audio ahead of playback
  • Check status codes for immediate failure

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Consistency ensures the voice does not drift in pitch or emotion mid-sentence.

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-node on GitHub
  3. openai-python on GitHub
  4. Python documentation
  5. Node.js documentation
  6. FFmpeg documentation
  7. ISO 639 language codes
  8. LibriTTS-R paper (arXiv 2305.18802)
  9. LibriTTS-R corpus (OpenSLR 141)
  10. Creative Commons Attribution 4.0
  11. TRON developer hub: TRC-20
  12. MDN: Web Speech API

More on this site