Cloud TTS API: Generate Speech with OpenAI SDK Compatibility

By Fintech Voice editorial team · Updated 2026-11-19

This guide explains how to integrate Fintech Voice into your mobile and web applications using the familiar OpenAI SDK. By simply adjusting the base URL, you can convert transaction alerts and account updates into clear audio files without learning a new library. We cover the essential endpoints, request parameters, and authentication methods needed to start generating speech immediately.

You will find concrete examples for curl, Python, and direct SDK usage, along with details on rate limits, supported languages, and error handling. This page is designed for product teams who need a reliable, multi-language voice notification system that fits seamlessly into their existing fintech infrastructure.

Cloud TTS API: Generate Speech with OpenAI SDK Compatibility

Frequently asked questions

How do I get an API key?

Sign up at /get-api-key/ using Google or email plus password. The dashboard displays your active key, balance, and usage. You can issue a new key at any time; the old one stops immediately. Accounts are specific to this site, so ensure you are on leongto.net when registering.

What is the base_url for the OpenAI SDK?

Set your base_url to https://api.leongto.net/v1. This allows you to use the official OpenAI SDKs by pointing them to our endpoint. Ensure you use your Fintech Voice API key for authentication.

Which audio formats are supported?

We support mp3, wav, opus, flac, and pcm. Select your preferred format using the response_format parameter in your request body. Each format serves different use cases, from web playback to high-fidelity storage. The API returns the audio file directly in the response based on your selection.

How many characters can I send?

Each request supports up to 4096 characters of input text. If your text exceeds this limit, split it into smaller parts and join the resulting audio files. Spaces and punctuation count toward the character total. This limit ensures efficient processing and predictable billing for your integration.

What happens if I exceed the rate limit?

The limit is 60 requests per minute per key. If you exceed this, requests may queue or fail. New accounts start with a 10 requests per minute limit until the first top-up. Monitor your usage via the dashboard to avoid interruptions during high-volume notification bursts.

Can I change the voice mid-request?

No, you cannot change the voice mid-request. Each request generates audio for a single voice preset. To use multiple voices, send separate requests for each segment. You can specify the voice parameter for each individual request to tailor the tone of different notification types.

How do I specify a language?

Use the optional language parameter with an ISO code. If omitted, the system guesses the language from the script, defaulting to English for Latin text. For non-English Latin-script text, explicitly set the language to ensure accurate synthesis. Supported languages include English, Spanish, German, and French.

Is the API compatible with OpenAI SDKs?

Yes, the request shape matches the OpenAI speech endpoint. You can use official OpenAI SDKs by changing the base_url to https://api.leongto.net/v1. Ensure you use your Fintech Voice API key for authentication. This compatibility simplifies integration for teams already familiar with OpenAI’s developer tools.

What is the response format?

The API returns the audio file directly in the response body. The format matches your requested response_format (mp3, wav, opus, flac, or pcm). Failed requests return an error status but do not charge your balance. You can process the audio file immediately upon receiving the response.

How do I handle errors?

Check the HTTP status code in the response. Failed requests are free, and charges are returned in full if synthesis fails. Use the dashboard to monitor usage and balance. If errors persist, verify your API key and request parameters. Support is available via email for assistance.

Can I use the API for bulk generation?

Yes, but requests are processed sequentially. Longer texts take time, roughly real-time speed. Split texts into 4096-character chunks and join the audio files. Under load, requests may queue. Monitor your rate limit to ensure smooth processing during bulk notification campaigns for your fintech products.

Is there a webhook for completion?

No, there is no webhook for completion. The API is synchronous; you receive the audio file directly in the response. We do not offer WebSocket or real-time partial audio delivery.

How do I rotate my API key?

Issue a new key from your dashboard at any time. The new key becomes active immediately, and the old one stops at once. This ensures secure access without downtime. You can manage keys directly through the account interface, allowing easy rotation for security or team changes.

What is the model parameter?

The model parameter accepts 'tts-1' or 'tts-1-hd'. Both use the same engine and price. Currently, both models offer identical quality and cost.

First request

curl

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

To access the Cloud TTS API, generate a unique API key on your dashboard. Each account holds one active key that authenticates your requests via the Authorization header.

API Key Generation

API Key Generation

Create a key directly from your account settings. The system issues a token prefixed with tts-. This key is the sole credential required for all API interactions.

Bearer Token Usage

Bearer Token Usage

Include the token in every request using the header: Authorization: Bearer tts-.... Ensure no extra spaces precede the token value to avoid authentication errors.

Key Rotation

Issue a new key at any time. The old key stops working immediately upon the new key's creation, ensuring secure access management without downtime.

Endpoints

Sound wave illustration for: Endpoints

The API exposes three primary endpoints for integration. The speech endpoint handles audio synthesis, while the voices and models endpoints provide metadata for configuration. All requests use standard JSON bodies and Bearer token authentication.

These endpoints enable fintech teams to retrieve available voice presets and model details before generating transaction alerts. The structure mirrors OpenAI’s speech endpoint, allowing direct compatibility with existing SDKs.

Speech Endpoint

Send text to receive an audio file via POST /v1/audio/speech. The endpoint accepts a JSON body containing model, input, voice, response_format, and optional speed or language fields. Text input is limited to 4096 characters per request.

Failed synthesis requests incur no charge. Audio is returned directly in the response body, allowing immediate playback in mobile or web applications without intermediate storage.

  • Endpoint: POST https://api.leongto.net/v1/audio/speech
  • Accepts JSON body with text and voice parameters
  • Returns audio file directly in response

Voices List

Retrieve all available voice presets and their details via GET /v1/voices. This endpoint returns metadata for the eight available voices, including their names, gender, and supported languages.

Use this endpoint to dynamically populate voice selection menus in your fintech dashboard. Each voice can speak any of the 23 supported languages, ensuring consistent tone across global transaction notifications.

  • Endpoint: GET https://api.leongto.net/v1/voices
  • Returns 8 voice presets with metadata
  • Covers 23 languages

Models List

Fetch available models via GET /v1/models. Currently, only tts-1 and tts-1-hd are available, both using the same engine and pricing structure.

This endpoint helps verify model availability before integration. Both models support the same input formats and speed ranges, allowing easy upgrades without code changes.

  • Endpoint: GET https://api.leongto.net/v1/models
  • Returns tts-1 and tts-1-hd models
  • Same pricing and engine for both

Request Parameters

Sound wave illustration for: Request Parameters

Configure the generation engine and input constraints to ensure your fintech alerts are processed correctly. The API accepts standard model identifiers and enforces strict character limits to maintain consistent audio quality and latency for mobile notifications.

Model Selection

Specify the model as either "tts-1" or "tts-1-hd". Both utilize the same underlying engine and pricing tier, so either identifier produces identical audio results and costs.

Input Text Limits

Each request supports up to 4,000 characters, including spaces and punctuation. For longer transaction summaries, split the text into chunks, generate each part, and join the resulting audio files sequentially.

Voice Selection

Choose from eight preset voices optimized for clarity. Select "atlas" for neutral news-style updates, "sage" for instructional guidance, or "aria" for clear narration. All voices support all 23 supported languages.

  • 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

The API returns audio data in the response_format you specify: mp3, wav, opus, flac, or pcm. For fintech notifications, mp3 offers a balance of quality and file size, while wav provides uncompressed clarity for local processing.

Audio Formats

Choose formats based on your mobile or web app’s requirements. All generated files include an inaudible watermark identifying them as synthetic speech.

Status Codes

A 200 OK response contains the audio binary. Use 400 for invalid parameters and 401 for authentication failures. Failed synthesis requests are free and return a 400 or 422 status with details.

Error Messages

Errors include a code and message field. Common issues include exceeding the 4096 character limit or using an invalid voice ID. Check the response body to adjust your request parameters immediately.

Rate Limits

Sound wave illustration for: Rate Limits

Each API key allows 60 requests per minute. New accounts start with a lower limit of 10 requests per minute until the first top-up is processed.

Requests Per Minute

The standard limit is 60 requests per minute per key. This applies to all synthesis endpoints. If you exceed this, requests are rejected with a 429 status code.

  • Standard limit: 60 requests/minute
  • New account limit: 10 requests/minute
  • Limit resets every 60 seconds

Queue Behavior

Requests are processed sequentially. If the queue is full, new requests may wait briefly before processing. Long texts are split into chunks, which are generated one after another.

Throttling

Exceeding the rate limit results in a 429 Too Many Requests error. No additional charge is applied for rejected requests. Reduce your request frequency if needed.

Rate Limits

Code Examples

Sound wave illustration for: Code Examples

To integrate speech generation into your fintech workflow, you can use standard HTTP requests or the OpenAI Python SDK. Both methods support the same parameter structure.

Curl Command

Use this command to generate audio directly from your terminal. Replace YOUR_API_KEY with your secret key from the dashboard.

  • ```bash curl https://api.leongto.net/v1/audio/speech \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{"model": "tts-1", "input": "Payment received", "voice": "nova", "response_format": "mp3"}' \ -o audio.mp3 ```

OpenAI SDK

Configure the SDK by pointing the base_url to our API endpoint. This allows you to use familiar OpenAI methods for speech synthesis.

  • ```python from openai import OpenAI client = OpenAI(base_url="https://api.leongto.net/v1", api_key="YOUR_API_KEY") speech = client.audio.speech.create( model="tts-1", voice="nova", input="Transaction approved." ) speech.write_to_file("output.mp3") ```

Python Script

A complete script example demonstrates handling the response and saving the file. Ensure you handle exceptions for rate limits or invalid inputs.

Language Support

Sound wave illustration for: Language Support

The API supports 23 specific languages, including English, Spanish, French, German, Arabic, Chinese, Japanese, and Hindi. Each voice can speak any of these languages, allowing you to generate localized notifications without managing multiple voice models.

You can explicitly set the language using an ISO 639-1 code in the request body. This ensures consistent pronunciation.

ISO Codes

Specify the language field with standard ISO codes like en, es, fr, de, ar, zh, ja, or hi. This applies to all 23 supported languages, ensuring the synthetic voice uses the correct phonetic rules for your target market.

  • 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 you omit the language field, the system guesses the language from the text script. Latin script defaults to English. For non-English text using Latin characters (e.g., German or Spanish), explicit language setting is recommended to avoid mispronunciation.

Manual Override

Always set the language parameter for Latin-script non-English texts to ensure accurate delivery. For example, German text sent without a language tag might be processed as English, altering the voice's cadence and intelligibility for German-speaking users.

Troubleshooting

Sound wave illustration for: Troubleshooting

Troubleshooting focuses on common API behaviors and known constraints. Most issues stem from character limits, voice selection, or transient network delays during high load.

Common Errors

A 401 Unauthorized error indicates an invalid or expired API key. Ensure your Authorization: Bearer header matches the key from your dashboard. If you rotated your key, the old one stops immediately.

  • Check key format: tts-...
  • Verify no trailing spaces
  • Confirm key is active in dashboard

Audio Generation Issues

Requests may queue under load, causing delays. Typical generation is near real-time, but short phrases take a few seconds. Failed requests are free.

  • Check queue status in logs
  • Verify network stability
  • Retry failed requests for refund

Character Limits

Each request supports up to 4096 characters. For longer texts, split input and join audio files. Spaces and punctuation count toward this limit.

  • Limit: 4096 chars/request
  • Include spaces/punctuation
  • Split and join manually

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. User testing reveals how different voices affect engagement and clarity in banking contexts, allowing you to select the tone that best fits your brand identity.

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. IETF RFC 7845: Ogg Opus
  3. FFmpeg documentation
  4. LibriTTS-R corpus (OpenSLR 141)
  5. Python documentation
  6. openai-node on GitHub
  7. Creative Commons Attribution 4.0
  8. ISO 639 language codes
  9. MDN: Web Speech API
  10. OpenAI API reference: create speech
  11. Tether (USDT)
  12. openai-python on GitHub

More on this site