TTS API for Audioguides: cURL & OpenAI SDK Integration

By VoxTrail editorial team · Updated 2026-11-18

This guide shows developers how to integrate VoxTrail’s text-to-speech API into audioguide and audio tour platforms. You will learn to generate multilingual audio files using standard HTTP requests or the OpenAI SDK, covering authentication, endpoint structures, and parameter configurations. The documentation focuses on practical implementation details for tourism startups building scalable voice content.

We cover request limits, language detection, and error handling with specific examples. You will see how to manage character counts, handle failures, and ensure reliable delivery of speech data. This page is designed for engineers who need clear, technical instructions to connect their applications to the API quickly and correctly.

TTS API for Audioguides: cURL & OpenAI SDK Integration

Frequently asked questions

What is the endpoint URL?

Use POST https://api.play78n.com/v1/audio/speech. This endpoint accepts JSON bodies containing your text, voice selection, and format preferences. It mirrors the OpenAI speech endpoint structure, ensuring compatibility with standard HTTP clients and SDKs that support this request shape for generating audio files from text input.

How do I authenticate my requests?

Include your API key in the Authorization header as: Authorization: Bearer tts-<your_key>. Each account holds one active key at a time. If you issue a new key, the previous one becomes invalid immediately. Ensure your key is active and correctly formatted to avoid authentication errors during synthesis requests.

Can I use the OpenAI Python SDK?

Yes. Configure the OpenAI SDK by setting the base_url to https://api.play78n.com/v1 and providing your site-specific API key. The request shape matches the OpenAI speech endpoint, allowing you to use existing OpenAI SDK methods without modification. This enables seamless integration into your existing Python workflows for audioguide generation.

What is the max text length?

Each request supports up to 4096 characters of input text. Spaces and punctuation count toward this limit. For longer texts, split the content into chunks of 4096 characters or fewer, generate audio for each part, and join the resulting audio files to create a complete audioguide track.

How do I specify the language?

Include the optional 'language' field with an ISO code in your request body. If omitted, the system guesses the language based on the script, defaulting to English for Latin text. Explicitly setting the language ensures accurate synthesis for non-English Latin-script texts or specific dialects supported by the eight voice presets.

What happens if I exceed rate limits?

Requests are processed sequentially. If you exceed the limit of 60 requests per minute, subsequent requests will be rejected with a 429 error. Failed requests are free, but queued requests may experience delays. Ensure your application handles potential latency gracefully, especially during high-volume audioguide generation bursts.

Is SSML supported in the input?

No, SSML is not supported. The API accepts plain text input only. You cannot use SSML tags for pronunciation or pacing control. For custom pronunciation, you must rely on the standard text input.

How do I get a list of voices?

Send a GET request to https://api.play78n.com/v1/voices. This endpoint returns details on available voices, languages, formats, and pricing. You can select from eight presets, including female and male voices, each with a specific tone like narration, storytelling, or news.

Can I generate audio in WAV format?

Yes. Specify 'wav' in the 'response_format' field of your request body. The API supports mp3, wav, opus, flac, and pcm formats. WAV files are uncompressed and suitable for high-quality audioguide distribution, though they result in larger file sizes compared to compressed formats like mp3 or opus.

Do I need to split long texts?

Yes, if your text exceeds 4096 characters. Split the text into chunks of 4096 characters or less, generate audio for each chunk, and join the resulting audio files. This ensures each request stays within the character limit.

First request

curl

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

Sound wave illustration for: Authentication

Authentication is handled via a Bearer token passed in the Authorization header of every request. Your API key identifies your account and tracks usage against your balance and rate limits.

Bearer token in header

Bearer token in header

Include the header Authorization: Bearer tts-... in all API calls. The key must be generated from your account dashboard and remains valid until revoked or replaced.

  • Format: Authorization: Bearer YOUR_API_KEY
  • Include with every POST and GET request

One active key per account

One active key per account

Each account holds a single active key. Generating a new key immediately invalidates the previous one, ensuring only one credential is valid at any time.

Revoke old keys instantly

When you issue a new key via the dashboard, the old key stops working immediately. This provides instant revocation without waiting for session timeouts.

Endpoint Structure

Sound wave illustration for: Endpoint Structure

The API exposes three primary endpoints for audioguide generation. Use POST /v1/audio/speech to submit text and receive audio files. Retrieve available voices, languages, and pricing details via GET /v1/voices, and list supported models with GET /v1/models.

POST /v1/audio/speech

Submit text for synthesis. The endpoint accepts JSON bodies containing the model, input text, voice selection, and optional parameters like speed or language code. It returns the generated audio file directly in the response.

GET /v1/voices

Returns a list of available voices, supported languages, output formats, and associated pricing. This endpoint allows your application to dynamically populate voice selection menus for tourists or museum visitors.

GET /v1/models

Lists the available synthesis models (tts-1 and tts-1-hd). Both models use the same engine and pricing.

Request Body Parameters

Sound wave illustration for: Request Body Parameters

Configure the synthesis engine and payload via the request body. The model field selects the engine, while input carries the script text. voice determines the speaker identity from the available presets.

model: tts-1 or tts-1-hd

Use tts-1 or tts-1-hd to select the same underlying engine. Both options incur identical pricing, so choose based on your quality preference without worrying about cost differences.

input: text up to 4096 chars

Pass your audioguide script in the input field. The API accepts up to 4,096 characters per request. For longer tours, split the text into chunks, generate audio for each, and join the files.

  • Spaces and punctuation count toward the character limit.
  • Each request generates a separate audio segment.

voice: 8 preset names

Select one of eight voice presets for your content. These are deterministic audio models based on licensed recordings, ensuring consistent tone across your multilingual tours.

Available voices: aria, nova, luna, sage, felix, milo, atlas, orion.

  • 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

Response Formats

Sound wave illustration for: Response Formats

Select the output format via the response_format parameter to match your audioguide player’s requirements. Supported formats include mp3, wav, opus, flac, and pcm. MP3 and Opus are efficient for bandwidth-limited mobile tours, while WAV and FLAC preserve high fidelity for museum installations. PCM provides raw, uncompressed data for direct processing.

mp3, wav, opus, flac, pcm

Each format balances file size and audio quality differently. MP3 and Opus offer significant compression, reducing storage and transfer costs for large-scale tours. WAV and FLAC provide lossless quality, ideal for high-end audio guides. PCM returns raw 16-bit linear audio, useful for immediate DSP processing without decoding overhead.

  • MP3: Compressed, widely supported, smaller file sizes.
  • WAV: Uncompressed, high fidelity, larger files.
  • Opus: Efficient compression, good for mobile data.
  • FLAC: Lossless compression, archive-quality audio.
  • PCM: Raw, uncompressed linear audio data.

Binary audio data in response

The API returns the generated audio directly as binary data in the HTTP response body. This allows saving to disk without intermediate parsing steps. For long texts split into segments, each request returns a separate binary audio file that must be concatenated by the client to form the complete guide.

Ensure your client handles binary payloads correctly. The response headers will indicate the content type based on the requested format. This direct binary transfer minimizes latency and simplifies integration with tourism apps and museum kiosks.

Error JSON on failure

If synthesis fails, the API returns a JSON error object instead of audio data. This includes details about the failure, such as invalid input or rate limits. Failed requests are refunded immediately, ensuring you only pay for successful generations. Check the response status code to distinguish between client errors (4xx) and server issues (5xx).

  • Failed requests are free.
  • Error JSON includes failure details.
  • Refund issued automatically on failure.

Rate Limits

Sound wave illustration for: Rate Limits

Rate limits protect service stability for high-volume audioguide generation. Your API key allows 60 requests per minute under normal conditions. This limit applies per key, so manage concurrent requests accordingly to avoid throttling during peak production hours.

Before your first top-up, the limit is reduced to 10 requests per minute. Once you add USDT (TRC-20), the limit increases to the standard 60 requests per minute. There are no monthly plans or tiered limits; the rate limit remains consistent regardless of your balance size.

60 requests per minute

The standard limit is 60 requests per minute per active key. This capacity is sufficient for most museum and tourism startup workflows, allowing you to generate multiple audio segments for a single tour or exhibit description without hitting bottlenecks.

If you exceed this limit, requests are rejected with a 429 Too Many Requests error. Failed synthesis requests do not consume your character balance, but they still count toward your rate limit if they reach the engine.

10 requests before first top-up

New accounts start with a restricted rate of 10 requests per minute. This lower limit applies until you complete your first top-up using USDT on the TRON network. It ensures fair usage while you verify your integration.

Once the transfer is confirmed, your rate limit automatically increases to 60 requests per minute. No manual support ticket is required to adjust this limit; it updates based on your account's top-up status.

Queue behavior under load

Requests are processed sequentially during periods of high demand. If the system is busy, your request may wait in a queue before synthesis begins.

Longer texts may take additional time to process. Typical speed is roughly real-time (25 characters per second), but short phrases may take a few seconds due to queue delays. Plan your audio generation pipeline to account for this latency.

Rate Limits

Language Detection

Sound wave illustration for: Language Detection

Language detection relies on the Unicode script of the input text. The API identifies the language automatically, but explicit configuration ensures accuracy for complex inputs or mixed scripts.

Auto-detect from script

The system infers the language from the character set.

Set language ISO code

Pass the language parameter with an ISO 639-1 code (e.g., de, fr, ja). This overrides detection and ensures the correct voice synthesis for the target audience.

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

Latin defaults to English

If no language is set and the text uses Latin script, the API defaults to English. For German, Spanish, or other Latin-script languages, you must explicitly set the language parameter.

OpenAI SDK Compatibility

Sound wave illustration for: OpenAI SDK Compatibility

The OpenAI SDKs work seamlessly with the VoxTrail API. You only need to adjust the base URL to point to our endpoint. This allows you to use the same code structure you already know for generating audio.

No custom client library is required. The standard OpenAI SDK handles the request formatting, authentication, and response parsing exactly as it does for OpenAI’s speech endpoint.

This compatibility means you can integrate our TTS into your tourism or museum audio workflows without rewriting your integration logic.

Change base_url to api domain

Set your SDK’s base URL to https://api.play78n.com/v1. This directs all requests to our infrastructure while keeping the standard request schema.

Ensure your API key is passed in the Authorization header as Bearer <key>.

  • Base URL: https://api.play78n.com/v1
  • Auth: Bearer token
  • No SDK changes needed

Use official OpenAI SDK

Use any official OpenAI SDK (Python, Node.js, etc.). The client handles the HTTP details.

Initialize the client with your key and the custom base URL.

This approach leverages the mature, tested OpenAI client code for reliability.

Same request shape

The request body uses the standard fields: model, input, voice, response_format, and speed.

Send model as tts-1 or tts-1-hd. The API processes these exactly like the OpenAI format.

Response data returns as binary audio, matching the standard SDK behavior.

Error Handling

Sound wave illustration for: Error Handling

Errors return standard HTTP codes. Client errors (4xx) indicate invalid requests, such as malformed JSON or exceeding character limits. Server errors (5xx) signal temporary backend issues. The API returns JSON error details for debugging.

4xx for client errors

Common 4xx errors include invalid API keys, unsupported voice names, or text exceeding the 4096-character limit per request. Ensure your payload matches the required schema before sending.

  • 401: Unauthorized or invalid key
  • 400: Bad request (invalid JSON or params)
  • 429: Rate limit exceeded (60 req/min)

5xx for server issues

Server errors (5xx) are rare and indicate temporary processing failures. Requests may queue under load; wait a few seconds and retry. These do not consume your character balance.

  • 500: Internal server error
  • 503: Service unavailable (temporary)

Refund on failure

Failed synthesis requests are free. If the API returns a 5xx error or the audio generation fails, the charge is returned in full to your balance. No manual claim is needed.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Our innovative audioguide technology transforms museum visits into immersive storytelling experiences for modern travelers.

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. LibriVox public-domain audiobooks
  3. openai-node on GitHub
  4. FFmpeg documentation
  5. openai-python on GitHub
  6. Python documentation
  7. OpenAI API reference: create speech
  8. TRON developer hub: TRC-20
  9. IETF RFC 7845: Ogg Opus
  10. W3C WAI: making audio and video accessible
  11. MDN: Web Speech API
  12. LibriTTS-R paper (arXiv 2305.18802)

More on this site