API Documentation for Text-to-Speech Integration

By DiningVoices editorial team · Updated 2026-11-18

This documentation provides a practical guide for indie developers building voice interfaces for dining halls, delivery apps, and menu systems. You will learn how to integrate the DiningVoices text-to-speech API using the official OpenAI SDK, leveraging a familiar request shape to convert text into natural-sounding audio files. The guide covers essential parameters like voice selection, speed control, and language specification, ensuring your application handles 23 languages accurately.

We detail authentication via Bearer tokens, rate limits, and error handling specific to our infrastructure. You will find a ready-to-use cURL example and explanations for model selection, input constraints, and response formats. This page is designed to help you quickly implement a reliable, cost-effective TTS solution without unnecessary complexity, focusing on the concrete steps needed to get your voice interface working.

API Documentation for Text-to-Speech Integration

Frequently asked questions

How do I get an API key?

Sign up on /get-api-key/ using Google or email and password. The dashboard displays your active API key, balance, and usage statistics. Each account holds one active key; issuing a new one immediately invalidates the previous one. Accounts created via email start without trial credit, while Google sign-ins receive $0.50.

What is the base URL for the API?

The API base URL is https://api.dd12login.com/v1. You send POST requests to https://api.dd12login.com/v1/audio/speech. This endpoint accepts JSON bodies identical to the OpenAI speech endpoint, allowing you to use the official OpenAI SDK by simply pointing it to this base URL.

Can I use the OpenAI SDK?

Yes. The request shape matches the OpenAI speech endpoint exactly. You can use the official OpenAI SDKs by changing the base_url to https://api.dd12login.com/v1 and providing your site-specific API key. No custom SDK is required; standard HTTP requests also work.

What is the character limit per request?

Each request supports up to 4096 characters in the input field. Spaces and punctuation count toward this limit. For texts exceeding this length, you must split the text into parts, generate audio for each part, and join the resulting audio files.

How do I set the language?

Include the optional language field with an ISO code in your request. If omitted, the system guesses the language from the script, defaulting to English for Latin text. Explicitly setting the language is recommended for non-English Latin-script texts to ensure accuracy.

What formats can I receive audio in?

You can receive audio in mp3, wav, opus, flac, or pcm formats. Specify the desired format using the response_format parameter in your JSON request body. The generated audio is returned directly in the response and is not stored by the service.

Is there a rate limit?

Yes, the limit is 60 requests per minute per key. Before your first top-up, the limit is 10 requests per minute. Requests are processed sequentially, so high load may cause queuing delays. Failed requests are free: if synthesis fails, the charge is returned in full.

Can I change the voice speed?

Yes, you can adjust the speed between 0.25 and 4.0 using the speed parameter. This allows you to slow down narration for clarity or speed up content for brevity. The default speed is 1.0.

Do I need SSML?

No, SSML is not supported. The API accepts plain text input. You cannot use phoneme dictionaries or custom pronunciation lexicons. If you need precise control, you must split your text and adjust speed or voice parameters in separate requests.

How do I handle long texts?

Split your text into chunks of up to 4096 characters. Send each chunk as a separate request to the speech endpoint. Once you receive the audio files for each part, join them sequentially to create the final audio output.

Are failed requests billed?

No. If synthesis fails, the charge is returned in full. Failed requests are free: if synthesis fails, the charge is returned in full. Request metadata is kept for billing.

Can I use multiple keys?

Each account holds one active key at a time. You can issue a new key at any time, but doing so immediately invalidates the previous one. There is no support for multiple simultaneous keys per account; rotate keys as needed.

What is the tts-1-hd model?

The tts-1-hd model uses the same engine and pricing as tts-1. It is available as an alternative model option in your requests. Both models support all eight voice presets and 23 languages, with identical character limits and speed settings.

How do I revoke my key?

Revoke your key by issuing a new one via the dashboard. When you generate a new key, the old one stops working immediately. You can continue using the new key for subsequent API requests without interruption to your service.

First request

curl

curl https://api.dd12login.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.dd12login.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.dd12login.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 for the DiningVoices TTS API relies on a single bearer token passed in the Authorization header. This key authenticates your requests to the endpoint and tracks your usage against your account balance.

Each account maintains exactly one active key at a time. When you generate a new key, the previous one becomes invalid immediately, ensuring that lost or compromised credentials cannot be used to generate audio indefinitely.

Bearer token in Authorization header

Bearer token in Authorization header

Include your key in every request header as Authorization: Bearer tts-.... The API validates this token before processing the speech synthesis job. Ensure the token is sent without extra spaces or line breaks.

  • Format: Authorization: Bearer YOUR_API_KEY
  • Case-sensitive header name
  • Required for all endpoints

One key per account

One key per account

Your account is tied to a single active API key. You can view and manage this key on your dashboard. Only one key can be active at any given moment to simplify security and billing tracking.

Revoke old keys instantly

Issuing a new key automatically revokes the previous one. The old key stops working immediately, even if it was already shared or embedded in your application code. This provides instant security without waiting for a timeout.

Endpoint: POST /v1/audio/speech

Sound wave illustration for: Endpoint: POST /v1/audio/speech

To generate audio, send a POST request to the speech endpoint with a JSON body. The API processes your text and returns the audio file directly in the response body. This single endpoint handles all synthesis tasks, from short menu items to longer descriptions, without requiring complex streaming setups or additional WebSocket connections.

JSON body request

Structure your request with the required fields: model, input, voice, response_format, and optional speed or language. The endpoint expects standard JSON formatting, making it easy to integrate with existing HTTP clients or the OpenAI SDK. Each request is processed independently, ensuring predictable behavior for your dining hall or delivery app workflows.

  • Required fields: model, input, voice, response_format
  • Optional fields: speed, language
  • Standard JSON structure for easy integration

Model selection: tts-1 or tts-1-hd

Choose between tts-1 and tts-1-hd models. Both use the same underlying engine and pricing structure, allowing you to switch between standard and high-quality audio without changing your integration logic. This flexibility lets you optimize for cost or quality based on the context, such as using high-definition for complex menu descriptions.

  • Both models use the same engine
  • Identical pricing structure
  • Switchable without code changes

Input text up to 4096 characters

Each request supports up to 4096 characters of input text. For longer content, such as full daily specials, split the text into chunks and join the resulting audio files. This approach maintains audio quality while accommodating the character limit, ensuring seamless playback for customers in dining halls or delivery apps.

  • Maximum 4096 characters per request
  • Split longer texts into chunks
  • Join audio files for playback

Request Parameters

Sound wave illustration for: Request Parameters

The API accepts eight distinct voice presets, each designed for specific audio contexts in dining applications. Female voices include Aria for clear narration, Nova for upbeat menus, Luna for storytelling, and Sage for instructional guidance. Male options feature Felix for energetic promos, Milo for conversational interactions, Atlas for neutral news-style updates, and Orion for deep documentary tones. All voices support any of the 23 available languages.

You can choose the output format from mp3, wav, opus, flac, or pcm. This flexibility allows integration into various player environments. The speed parameter ranges from 0.25 to 4.0, enabling precise control over playback rate without affecting voice quality.

Voice selection from 8 presets

Select from eight licensed voices derived from public domain audiobooks. Each voice offers a distinct tonal quality suitable for different dining hall or delivery app contexts. Voices are language-agnostic, meaning any voice can speak any supported language naturally.

The voices are based on licensed recordings from LibriTTS-R (CC BY 4.0) and LibriVox. Every generated audio file includes an inaudible watermark identifying it as synthetic speech.

  • 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 format: mp3, wav, opus, flac, pcm

Specify the desired audio format in the response_format field. Supported formats include mp3, wav, opus, flac, and pcm. Choose the format that best fits your application's playback requirements and bandwidth constraints.

The API returns the audio file directly in the response body. No additional processing is required to access the generated speech.

Speed control from 0.25 to 4.0

Adjust the playback speed using the speed parameter, which accepts values between 0.25 and 4.0. This allows you to speed up menu announcements or slow down instructions for clarity.

Changing the speed does not alter the voice characteristics. The generated audio maintains natural intonation regardless of the selected rate, though pitch may shift.

Language Specification

Sound wave illustration for: Language Specification

Specify the language parameter using an ISO 639-1 code to ensure precise synthesis. Our API supports 23 languages, from Arabic to Turkish. Any voice can speak any supported language, giving you flexibility for international dining apps or menu systems.

Optional ISO language code

Pass the language code in the request body. This is crucial when your text uses Latin script but is not English, such as German, Dutch, or Finnish. Without this hint, the engine might misinterpret the pronunciation.

  • 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 for Latin script

The API detects non-Latin scripts automatically. If you send text in Cyrillic, Kanji, or Arabic, the engine identifies the language without needing an explicit language field. This reduces boilerplate for single-language deployments.

Default to English if unspecified

If you omit the language parameter and the text is in Latin script, the API defaults to English. For non-English Latin text, always set the language. This prevents awkward mispronunciations in menu items or voice prompts.

OpenAI SDK Integration

Sound wave illustration for: OpenAI SDK Integration

To integrate DiningVoices with the official OpenAI SDK, you simply adjust the client configuration. The API follows the exact same request structure as the OpenAI speech endpoint, allowing you to swap providers without rewriting your core logic. This ensures a seamless drop-in replacement for existing voice interface implementations.

Change base_url to api domain

Point your SDK client to our API base URL: https://api.dd12login.com/v1. This directs all speech synthesis requests to our infrastructure while maintaining the standard endpoint paths. Your existing authentication headers and payload structures remain valid without modification.

Use official OpenAI SDKs

Leverage the official OpenAI SDKs for your preferred language. Pass your DiningVoices API key (starting with tts-...) as the Authorization header. The SDK handles the JSON serialization and response parsing exactly as it would for OpenAI, requiring no custom adapters.

  • No custom client library needed
  • Standard JSON payload structure
  • Works with Python, Node.js, and other official SDKs

Same request shape as OpenAI

The request body mirrors the OpenAI /v1/audio/speech format. You send model, input, voice, and optional response_format or speed. The API returns the audio file directly in the response, compatible with standard HTTP client handling.

OpenAI SDK Integration

Example Curl Request

Sound wave illustration for: Example Curl Request

The following curl command demonstrates a basic synthesis request. Replace YOUR_API_KEY with your key from the dashboard. This example sends a short menu description to the tts-1 model using the nova voice in English.

The request body includes the text input and desired output format. The API processes the request and returns the audio data directly in the response body.

Basic text-to-speech command

Send a POST request to the speech endpoint with your Bearer token. Ensure the text does not exceed 4096 characters to avoid truncation.

The command below generates an MP3 file using the nova voice, suitable for upbeat dining announcements.

  • Endpoint: https://api.dd12login.com/v1/audio/speech
  • Method: POST
  • Key: Bearer YOUR_API_KEY

Headers and body structure

Include the Authorization header with your API key. The JSON body defines the model, voice, and input text.

Set the response_format to mp3 for broad compatibility. The speed parameter defaults to 1.0 but can range from 0.25 to 4.0.

Audio response handling

The API returns an audio file in the response body. Save this binary data to a file on your server.

Failed requests do not incur charges. Check the HTTP status code to confirm success or handle errors appropriately.

Rate Limits and Quotas

Sound wave illustration for: Rate Limits and Quotas

Your API key allows 60 requests per minute once your account is active. This limit applies uniformly across all endpoints, ensuring predictable throughput for your dining hall or menu system integrations.

60 requests per minute per key

The standard rate limit is 60 requests per minute. This capacity supports steady-state generation for menu descriptions or voice interfaces.

10 requests before first top-up

New accounts start with a lower threshold of 10 requests per minute. This restricts usage until you complete your first USDT top-up, after which the limit increases to the standard 60 rpm.

Queue handling under load

Requests are processed sequentially. If you exceed the limit, subsequent requests enter a queue rather than failing immediately. Processing speed is roughly real-time, so long texts may take seconds to generate.

Error Handling

Sound wave illustration for: Error Handling

Failed requests are free: if synthesis fails, the charge is returned in full. If a request fails due to server errors or timeout, the character count is not deducted from your balance. This ensures that temporary infrastructure hiccups do not impact your project's budget.

Failed requests are free

Synthesis failures result in a zero-charge outcome. The system returns an error status code without consuming any of your prepaid characters. You can retry the same input immediately without worrying about double-charging for a failed generation attempt.

  • Zero cost for failed synthesis attempts
  • No character deduction on error
  • Immediate retry capability without balance impact

Charge returned in full

Any prepaid amount associated with a failed request is refunded automatically. Request metadata is kept for billing. You will see the credit restored in your account dashboard immediately after the failure is confirmed.

Standard HTTP error codes

The API returns standard HTTP status codes to indicate the nature of the failure. Common codes include 400 for invalid input parameters, 401 for authentication issues, and 500 for server-side errors. Use these codes to implement robust retry logic in your dining hall voice interfaces.

  • 400: Invalid parameters or input format
  • 401: Authentication or token issues
  • 500: Internal server error

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. We built a cozy virtual dining hall where players can craft their own culinary experiences and share stories with friends.

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. Creative Commons Attribution 4.0
  3. MDN: Web Speech API
  4. Python documentation
  5. W3C WAI: making audio and video accessible
  6. TRON developer hub: TRC-20
  7. FFmpeg documentation
  8. ISO 639 language codes
  9. Tether (USDT)
  10. LibriTTS-R paper (arXiv 2305.18802)
  11. IETF RFC 7845: Ogg Opus
  12. openai-node on GitHub

More on this site