Hindi Text-to-Speech API Quick Start Guide

By VoiceForPublic editorial team · Updated 2026-11-19

This guide shows you how to integrate Hindi text-to-speech into your applications using our REST API. You will learn to generate natural-sounding audio files in Hindi from plain text, handling voice selection, audio formats, and error cases. The instructions use concrete examples with curl and the official OpenAI SDK, so you can start building immediately.

Designed for developers working with multilingual content, this page covers the essential steps to get your first audio file. Whether you are building for NGOs or public services, you will find clear instructions on managing API keys, understanding rate limits, and processing long texts efficiently.

Hindi Text-to-Speech API Quick Start Guide

Frequently asked questions

Which OpenAI SDKs work with this API?

The official OpenAI SDKs work by changing the base_url to https://api.xxx111.info/v1 and using your site's key. This allows you to use standard libraries for Python, JavaScript, and other languages without needing a custom SDK.

Can I use the same API key on multiple servers?

Yes, you can use the same API key on multiple servers. Each account has one active key that can be used across different environments. If you issue a new key, the old one stops immediately, so manage your deployments accordingly.

What is the maximum text length per request?

The maximum text length per request is 4096 characters. For longer texts, you must split the input into parts of up to 4096 characters and join the resulting audio files. Spaces and punctuation count toward this limit.

Does the API support Hindi with special characters?

Yes, the API supports Hindi, which is one of the 23 supported languages. You can send text containing Hindi script characters. Ensure you set the language parameter to the appropriate ISO code if needed for accurate synthesis.

How do I handle rate limit errors in code?

The rate limit is 60 requests per minute per key. If you exceed this, you will receive an error. Implement retry logic with exponential backoff in your code to handle these errors gracefully and resume processing after the limit resets.

Is there a way to get audio in real-time streaming?

No, the API does not support streaming or WebSocket connections for real-time partial audio. You send a POST request and receive the complete audio file in the response. This is a standard request-response pattern, not a streaming service.

Can I change the voice mid-stream?

Since there is no streaming, you cannot change the voice mid-stream. Each request generates a single audio file with one voice. To change voices, you must send separate requests for each segment of your text with the desired voice parameter.

What happens if the network drops during generation?

If the network drops, you simply retry the request. Failed requests are free, so you are not charged for retries. The API processes requests sequentially, so ensure your client handles timeouts and retries appropriately to complete the synthesis.

Do I need to install any specific libraries?

No specific libraries are required beyond the standard HTTP client or the official OpenAI SDK. You can use plain HTTP requests or any language that supports JSON and HTTP POST. No custom SDK or specific package is mandatory.

Is the API compatible with serverless functions?

Yes, the API is compatible with serverless functions. Since it uses standard HTTP requests, you can call it from AWS Lambda, Vercel, or similar environments. Just ensure your function handles the JSON body and authentication header correctly.

Can I use WAV files for better quality?

Yes, you can request WAV files by setting the response_format to 'wav'. The API supports mp3, wav, opus, flac, and pcm formats. Choose the format that suits your quality and size requirements for the generated audio.

How do I detect if a request failed?

You detect failures by checking the HTTP status code and response body. Failed requests are free, and the charge is returned in full. Your code should inspect the response to determine if synthesis succeeded or if an error occurred.

Is the base URL the same for all regions?

Yes, the base URL is https://api.xxx111.info/v1. There is no regional variation for the API endpoint. All requests go to the same cloud infrastructure.

Can I use the API with Python or JavaScript?

Yes, the API works with Python and JavaScript. You can use the official OpenAI SDKs or plain HTTP requests in either language. The request shape is standard JSON, making it easy to integrate into your existing Python or JavaScript applications.

First request

curl

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

To start generating Hindi audio, create an account on /get-api-key/ using your Google account or an email address. Once registered, you receive a unique API key immediately, allowing your team to begin sending requests.

Sign up with Google or email

Sign up with Google or email

You can register via Google for quick access or use a standard email and password. Each account is tied to the site domain, so ensure you are on the correct page for your organization.

  • Google Sign-In for instant setup
  • Email and password option available

Key issued instantly

Key issued instantly

Your API key appears on the dashboard immediately after sign-up. Use this key in the Authorization header as Bearer tts-... for all subsequent requests. Note that accounts created with email/password do not receive the free trial credit; only Google sign-ups get the $0.50 trial.

Rotate keys anytime

For security, you can issue a new key at any time from your dashboard. The old key stops working immediately when the new one is active, ensuring seamless transitions without downtime for your audio pipelines.

First request with curl

Sound wave illustration for: First request with curl

Send a POST request to https://api.xxx111.info/v1/audio/speech with your Bearer token. The JSON body requires the model, input text, voice, and response format fields.

Basic JSON structure

Include the text in the input field (max 4096 characters). Use tts-1 or tts-1-hd for the model (same engine and price). The API returns an audio file directly in the response body.

  • model: "tts-1" or "tts-1-hd"
  • input: your text string
  • voice: one of 8 presets
  • response_format: mp3, wav, opus, flac, or pcm

Setting language to Hindi

Specify language: "hi" to ensure correct pronunciation. Without this, Latin-script Hindi might default to English generation.

Specifying voice and format

Choose a voice like nova for upbeat community announcements or sage for clear instructions. Select mp3 for web delivery or wav for archival quality.

Using OpenAI SDKs

Sound wave illustration for: Using OpenAI SDKs

Leverage the official OpenAI SDKs with minimal configuration. By updating the base URL to our endpoint, you can reuse existing client libraries without rewriting your integration logic. This ensures consistency with widely adopted developer tools.

The API mirrors the standard speech endpoint structure, meaning your existing code can be adapted quickly. This approach reduces development time for teams already familiar with OpenAI’s ecosystem.

Change base_url to our endpoint

Point your SDK client’s base URL to https://api.xxx111.info/v1. This single change directs all requests to our infrastructure while maintaining the standard request format.

Ensure your authentication header uses your unique tts-... key. This key authenticates your account for all SDK operations.

  • Base URL: https://api.xxx111.info/v1
  • Auth Header: Authorization: Bearer tts-...

Use official OpenAI libraries

Import the standard OpenAI Python or Node.js library. No custom wrappers are needed since our endpoint accepts the same parameters.

Initialize the client with your API key and the updated base URL. The library handles serialization and network requests as usual.

Same request shape

Pass model, input, voice, and response_format exactly as you would for the OpenAI speech endpoint. The SDK handles the JSON payload automatically.

This compatibility allows you to switch providers or test alternatives without changing your core application logic.

Supported audio formats

Sound wave illustration for: Supported audio formats

The response_format field lets you choose the output container, balancing file size and quality. The API returns raw audio bytes in the selected format, which your application must save or stream directly to the user.

MP3 for web playback

MP3 is the default and most compatible choice for web players and mobile apps. It offers a good balance between audio quality and small file sizes, making it ideal for distributing audio updates to community members on varying devices.

WAV for high quality

Choose WAV when you need uncompressed, lossless audio for professional editing or archiving. This format preserves the full fidelity of the generated speech without compression artifacts, resulting in larger file sizes compared to MP3.

FLAC, OPUS, PCM options

FLAC provides lossless compression for efficient storage without quality loss. OPUS offers efficient compression for low-bandwidth environments. PCM returns raw linear audio data, useful for direct processing by other audio software.

  • FLAC: Lossless, efficient storage
  • OPUS: Efficient streaming
  • PCM: Raw linear data

Handling errors

Sound wave illustration for: Handling errors

Errors are handled via standard HTTP status codes and clear JSON bodies. Understanding these responses helps you manage retries and avoid wasted credits on failed requests.

Failed synthesis requests are free, so you can safely retry without incurring extra costs while your API key balance remains intact.

Rate limit responses

When you exceed 60 requests per minute, the API returns a 429 Too Many Requests error. Before your first top-up, the limit is 10 requests per minute.

  • Monitor the Retry-After header for suggested wait times.
  • Implement exponential backoff to avoid hammering the API when throttled.

Invalid parameter errors

Common issues include exceeding the 4096 character limit per request or using an unsupported voice or format. The response body details the exact field that caused the failure.

  • Ensure input is under 4096 characters.
  • Verify voice is one of the 8 presets.
  • Check response_format against supported types.

Retry logic best practices

Since failed requests are free, retrying invalid parameters immediately is safe but likely to fail again. For rate limits, wait and retry. For network issues, use a standard retry with backoff.

  • Retry on 429 with backoff.
  • Retry on 5xx server errors.
  • Do not retry 4xx errors unless you fix the parameter.
Handling errors

Rate limits and performance

Sound wave illustration for: Rate limits and performance

Your API key allows 60 requests per minute under normal conditions. This limit applies per key, so rotating keys does not increase your overall throughput. Failed requests do not count against this quota and are refunded.

60 requests per minute

The standard rate limit is 60 requests per minute per active key. This applies to all request types. You can check your current usage in the dashboard.

  • Limit is per key, not per IP
  • Failed requests are free and do not count
  • Rotate keys to manage limits effectively

10 requests before first top-up

New accounts without a top-up start with a lower limit of 10 requests per minute. This allows you to test the service with your free trial credit (if signed up with Google). Once you top up, the limit increases to 60 requests per minute.

  • Low limit for untopped accounts
  • Increases to 60 rpm after top-up
  • Top-up via USDT on TRON network

Queue processing under load

Requests are processed sequentially. Under high load, a request may wait in a queue. Typical speed is roughly real time (25 characters per second). Short phrases may take a few seconds to generate.

Voice and language selection

Sound wave illustration for: Voice and language selection

Choose from eight distinct preset voices, ranging from warm narrators to energetic promoters. Each voice supports all 23 languages, including Hindi, without needing separate models. Select the tone that fits your community updates or service announcements.

For Hindi content, always set the language parameter to hi. This ensures accurate pronunciation and natural rhythm, preventing the engine from defaulting to English intonations on Hindi script.

8 preset voices available

The API offers eight voice presets, including female options like Aria and Nova, and male options like Felix and Milo. These are based on licensed recordings and work across all supported languages. There is no custom voice cloning; you select from these fixed presets for consistent, clear audio output in every language you support.

  • 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

ISO language code for Hindi

Send the ISO code hi in the request body to ensure the engine applies the correct phonetic rules for Hindi. This is critical because the default behavior assumes English for Latin script text. Explicitly setting the language prevents mispronunciation and maintains the natural flow of speech for your Hindi-speaking audiences.

Auto-detection fallback

If you omit the language field, the system guesses the language based on the script. Latin text defaults to English, which may cause errors for Hindi written in Latin script (Hinglish). For mixed scripts or to ensure accuracy, always specify the language code explicitly rather than relying on auto-detection.

Long text processing

Sound wave illustration for: Long text processing

For texts exceeding 4,096 characters, the API requires splitting the input into smaller chunks. You must divide your content into segments of up to 4,096 characters each, ensuring no single request exceeds this limit. Spaces and punctuation count toward this total.

Split into 4096 character parts

Prepare your text client-side before sending requests. Ensure each segment contains no more than 4,096 characters. This limit applies per request, so longer documents require multiple calls.

  • Count spaces and punctuation as characters
  • Split text at natural boundaries like sentences or paragraphs

Join audio files client-side

The API returns separate audio files for each segment. Your application must concatenate these files in order to reconstruct the full audio. This keeps request sizes manageable.

  • Download each audio response sequentially
  • Concatenate files in the original order

Consistent voice across parts

Use the same voice parameter for all segments of a single document. This ensures the synthesized speech maintains a consistent tone and character throughout the entire text, providing a seamless listening experience for your audience.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. His bright delivery encourages immediate action or interest.

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. TRON developer hub: TRC-20
  3. Creative Commons Attribution 4.0
  4. OpenAI API reference: create speech
  5. LibriTTS-R corpus (OpenSLR 141)
  6. curl documentation
  7. Tether (USDT)
  8. LibriVox public-domain audiobooks
  9. Node.js documentation
  10. FFmpeg documentation
  11. ISO 639 language codes
  12. openai-python on GitHub

More on this site