Cloud Text-to-Speech API: Generate Audio with OpenAI SDK

By SayGov editorial team · Updated 2026-11-19

This guide explains how to integrate SayGov’s text-to-speech API into your accessibility tools and public information systems. You will learn to generate human-like audio from text using the standard OpenAI SDK, making it easy to support visually impaired users and non-native speakers without managing complex infrastructure.

We cover authentication, request parameters, and supported formats with concrete examples. The API uses a straightforward JSON structure, so you can start sending requests immediately. Whether you are building a screen reader or a multilingual news feed, this page provides the practical steps to get your first audio file generated.

Cloud Text-to-Speech API: Generate Audio with OpenAI SDK

Frequently asked questions

How do I get an API key?

Sign up on /get-api-key/ using Google or email plus password. Google sign-ins receive a $0.50 trial credit valid for 7 days. Email accounts start without trial credit. You receive one active key per account, which you can replace at any time if needed.

What is the base URL for the API?

The API base URL is https://api.b777x.info/v1. Use this URL when configuring your client. The speech endpoint is POST https://api.b777x.info/v1/audio/speech. Other endpoints like voices and models are also available under this base path.

Does the OpenAI SDK work directly?

Yes, the official OpenAI SDKs work by changing the base_url to https://api.b777x.info/v1. Use the standard speech endpoint and your API key. The request shape matches the OpenAI speech endpoint exactly, allowing seamless integration with existing codebases.

What is the character limit per request?

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 less and join the resulting audio files after generation.

Can I use SSML in the input text?

No, the API does not support SSML. Input is plain text only. You cannot use SSML tags for pronunciation or prosody control. The system guesses language from the script if not specified, but SSML formatting is not available.

What happens if the API is slow?

Requests are processed sequentially, so under load, a request may wait in a queue. Typical speed is roughly real-time, but short phrases take a few seconds. Failures result in a full refund of the charge for that request.

Are responses stored on the server?

Generated audio is returned in the response and not stored. Input text is used only to produce the audio and is not used for training. Request metadata, such as time and status, is kept for billing purposes.

How do I handle rate limits?

The limit is 60 requests per minute per key, or 10 per minute before the first top-up. Exceeding this may cause delays as requests queue. Monitor your usage via the dashboard to stay within limits and avoid processing delays.

Can I stream the audio response?

No, there is no streaming or WebSocket support. The API returns the complete audio file after synthesis is finished. You must wait for the full response before processing or playing the audio. No real-time partial audio is available.

What formats are best for web?

MP3 is widely supported for web playback. Other options include WAV, OPUS, FLAC, and PCM. Choose MP3 for broad compatibility or OPUS for efficient compression. The format is specified in the response_format field of your request.

How do I split long texts?

Split input text into parts of up to 4096 characters each. Send each part as a separate request to the speech endpoint. Join the resulting audio files programmatically after receiving all responses. This ensures compliance with the character limit.

Is the API endpoint stable?

No SLA or uptime guarantee is provided. Requests are processed sequentially, which may cause delays under load. The base URL and structure remain consistent for reliable integration.

Can I use the same key on multiple sites?

Yes, you can use the same API key across multiple sites or applications. Each account has one active key. Issuing a new key immediately invalidates the old one, so ensure all integrations switch to the new key simultaneously.

Do I need to specify a language?

It is optional but recommended. If not set, the language is guessed from the script, defaulting to English for Latin text. For non-English Latin-script text, explicitly set the language parameter to ensure accurate synthesis and avoid misidentification.

First request

curl

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

Authentication and keys

Sound wave illustration for: Authentication and keys

Access the API by creating an account at /get-api-key/. You can sign up using Google or an email address. The dashboard displays your active API key, current balance, and usage statistics immediately after login.

Generating your API key

Generating your API key

Your API key is generated upon account creation. It appears on the dashboard alongside your balance and character count. Keep this key secure, as it provides direct access to your account and billing.

Bearer token authorization

Bearer token authorization

Include your key in the request header using the standard Bearer scheme. Use the format Authorization: Bearer tts-your-api-key-here. This authenticates every request to the API endpoint.

Only one key is active per account at any time. Ensure you store the current key securely in your application's environment variables or configuration files.

Issuing a new key

You can issue a new key at any time from your dashboard. When you generate a new key, the previous one becomes invalid immediately. This is useful if you suspect a key has been compromised or want to rotate credentials regularly.

After issuing a new key, update your application's configuration to use the new value. Requests sent with the old key will be rejected instantly.

Endpoint: Speech generation

Sound wave illustration for: Endpoint: Speech generation

The primary endpoint for generating audio is POST https://api.b777x.info/v1/audio/speech. Send your text payload to this URL using the Bearer token from your API key. The service processes the input and returns the synthesized audio file directly in the response body.

POST /v1/audio/speech

Send a JSON object containing the model, input text, voice selection, and desired audio format. The endpoint accepts standard HTTP POST requests with the Authorization: Bearer <key> header. Ensure your key is active; failed requests do not consume balance.

Request body structure

The JSON body requires model ("tts-1" or "tts-1-hd"), input (string up to 4096 characters), and voice (one of the 8 presets). Optional fields include response_format, speed (0.25–4.0), and language (ISO code). Spaces and punctuation count toward the character limit.

  • model: "tts-1" or "tts-1-hd"
  • input: max 4096 characters
  • voice: e.g., "aria", "nova"
  • response_format: mp3, wav, opus, flac, pcm

Response format and audio file

The API returns the audio file directly in the response body, not as a URL. The format matches the response_format parameter. If synthesis fails, you receive an error JSON object, and the request is free. No data is stored after generation.

  • Returns raw audio bytes
  • Matches requested format
  • Errors return JSON, no charge

Request parameters

Sound wave illustration for: Request parameters

Configure the speech synthesis request with precise parameters to control audio output. The API accepts standard JSON bodies, allowing you to specify the engine, text content, and voice characteristics in a single call.

Ensure your input text respects the character limit and selects an appropriate voice. The language parameter is optional but recommended for non-English Latin text to prevent incorrect voice selection.

Model selection (tts-1, tts-1-hd)

Choose between "tts-1" and "tts-1-hd". Both use the same underlying engine and price, so selection depends on your quality preference rather than cost or capability differences.

Input text limit (4096 chars)

Each request supports up to 4096 characters, including spaces and punctuation. For longer texts, split the input into chunks, generate audio for each, and join the files.

Short phrases may take a few seconds to process, while longer texts generate at roughly real-time speed (25 characters per second).

Voice and language settings

Select one of eight voice presets, such as "aria" for clear narration or "atlas" for neutral news delivery. Any voice can speak any of the 23 supported languages.

If the language field is omitted, the system guesses the language from the script, defaulting to English for Latin text. Explicitly set the ISO code for non-English Latin scripts to ensure accurate pronunciation.

  • Aria: warm, clear narrator
  • Nova: bright, upbeat
  • Luna: soft, storytelling
  • Sage: calm, instructional
  • Felix: energetic, promo
  • Milo: friendly, conversational

Audio formats supported

Sound wave illustration for: Audio formats supported

Selecting the right audio format is essential for your accessibility tools and public information systems. Our API allows you to choose between compressed and lossless options depending on your bandwidth and quality requirements.

MP3 and WAV compatibility

MP3 offers efficient compression for web delivery, while WAV provides uncompressed audio for high-fidelity playback. Both formats are widely supported by screen readers and media players.

FLAC and PCM options

FLAC provides lossless compression. PCM delivers raw audio data, ideal for direct processing or archival storage.

Opus format support

Opus is a supported format. The API does not support streaming or real-time partial audio, so Opus is suitable for efficient storage and playback of complete files rather than low-latency transmission.

Rate limits and performance

Sound wave illustration for: Rate limits and performance

The API enforces a hard limit of 60 requests per minute per key. New accounts start with a lower threshold of 10 requests per minute until the first top-up is processed. This constraint ensures stable service for indie developers building accessibility tools without enterprise overhead.

60 requests per minute

Each API key is limited to 60 requests per minute. Before the first top-up, this limit drops to 10 requests per minute to prevent abuse during the free trial period. The limit resets every minute, allowing for burst usage if you manage your queue effectively.

  • Standard limit: 60 requests/minute per key
  • Trial limit: 10 requests/minute before first top-up
  • Limit resets every 60 seconds

Processing queue behavior

Requests are processed sequentially. If you exceed the rate limit or if the server is under load, your request may wait in a queue. This means short phrases might take a few seconds to generate, even if the limit is not technically exceeded.

Character per second speed

Generation speed is approximately 25 characters of text per second of audio output. For long texts, this results in roughly real-time generation. Shorter phrases may take slightly longer due to initialization overhead, so plan your integration accordingly for responsive user experiences.

  • Approx. 25 characters generated per second of audio
  • Long texts generate at roughly real-time speed
  • Short phrases may have higher per-request latency
Rate limits and performance

Error handling

Sound wave illustration for: Error handling

Understanding error responses helps you build robust integration. The API returns standard HTTP status codes to indicate success or failure, ensuring your application can react appropriately without guessing.

Common HTTP status codes

Use 200 for successful synthesis. Expect 400 for bad requests, 401 for invalid API keys, and 429 when you exceed the 60 requests per minute limit. These codes allow precise error handling in your workflow.

Failed request refunds

If synthesis fails due to server errors or invalid parameters, the charge is returned in full. You are only billed for successfully generated audio files, ensuring transparent pricing for your accessibility tools.

Validation errors

Requests exceeding 4096 characters or using unsupported voices return a 400 error. Ensure your input text fits the character limit and that you specify a valid voice preset from the list.

Code examples

Sound wave illustration for: Code examples

Accessing the API is straightforward using standard HTTP tools. The following examples demonstrate how to generate audio files for accessibility features in public information systems.

Each snippet uses the tts-1 model with the nova voice in English. Replace YOUR_API_KEY with your key from the dashboard.

cURL command example

Send a POST request with your text and receive an audio file.

The command outputs the audio directly to a file named output.mp3.

  • Authorization: Bearer YOUR_API_KEY
  • Content-Type: application/json

OpenAI SDK integration

Use the official OpenAI SDK by changing the base URL.

Install the SDK via pip or npm, then point it to https://api.b777x.info/v1.

Python request snippet

Use the requests library for a simple HTTP POST.

Parse the binary response to save the audio file locally.

Voices and models

Sound wave illustration for: Voices and models

The API supports two model variants, tts-1 and tts-1-hd, which use the same underlying engine and pricing. You select the desired quality level in your request body via the model field. Both models deliver consistent audio quality suitable for accessibility applications.

Voice selection is handled by passing a specific voice ID to the API. You can retrieve the full list of available presets and their associated metadata using the GET /v1/voices endpoint, which also provides details on supported languages and formats.

Listing available voices

All eight voice presets are accessible via the API. The /v1/voices endpoint returns the complete list of available voices, allowing you to dynamically select the most appropriate tone for your content. Each voice is designed to handle all 23 supported languages natively.

  • GET /v1/voices returns all preset IDs
  • All voices support all 23 languages
  • No voice cloning required

Model differences

The tts-1 and tts-1-hd models operate on the same engine with identical pricing. The primary difference lies in the audio processing pipeline, but for most use cases, the output quality is comparable. Choose tts-1-hd if your application requires higher fidelity, though both meet standard accessibility needs.

Voice preset descriptions

Voices are categorized by gender and tone. Female presets include aria (warm narrator), nova (upbeat), luna (storytelling), and sage (instructional). Male presets include felix (energetic), milo (conversational), atlas (neutral news), and orion (deep documentary).

Voices are based on licensed recordings: LibriTTS-R (CC BY 4.0), from LibriVox public-domain audiobook readings. Each generated audio file contains an inaudible synthetic watermark. Select a voice based on the context of your text, such as using atlas for public information or luna for narrative content.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Allow users to choose their preferred voice or disable audio entirely.

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. LibriVox public-domain audiobooks
  4. curl documentation
  5. openai-node on GitHub
  6. OpenAI API reference: create speech
  7. MDN: Web Speech API
  8. LibriTTS-R corpus (OpenSLR 141)
  9. ISO 639 language codes
  10. Node.js documentation
  11. openai-python on GitHub
  12. Tether (USDT)

More on this site