API Documentation: Integrate Text-to-Speech with Your Application

By MedTTS Guide editorial team · Updated 2026-11-19

This documentation provides a practical, step-by-step guide for large medical teams integrating text-to-speech into their clinical workflows. It covers essential integration steps, from obtaining your API key to handling long patient guides and training materials. You will learn how to switch from legacy providers like Amazon Polly by leveraging our API for generating audio from clinical documentation.

We explain how to use the official OpenAI SDK or plain cURL requests to convert text into natural-sounding speech. The guide details voice selection, speed adjustments, and supported formats like MP3 and WAV. It also covers rate limits, error handling, and text splitting to ensure reliable audio generation for your team’s specific needs.

API Documentation: Integrate Text-to-Speech with Your Application

Frequently asked questions

What is the endpoint URL for the API?

The endpoint is POST https://api.bf77.info/v1/audio/speech. You send a JSON body containing the text, voice, model, and format parameters. This endpoint handles all text-to-speech synthesis requests for your medical documentation or patient guides efficiently.

How do I authenticate with the API?

Include your API key in the request header as Authorization: Bearer tts-... . Each account has one active key. If you need a new key, you can issue one at any time, and the old key stops immediately.

Can I use the OpenAI SDK with this API?

Yes. The request shape matches the OpenAI speech endpoint. You can use official OpenAI SDKs by changing the base_url to https://api.bf77.info/v1 and providing your site-specific API key for authentication.

What is the maximum character limit per request?

The input text is limited to 4096 characters per request. For longer texts, you must split the content into parts of up to 4096 characters and join the resulting audio files afterward.

How do I handle rate limits in my app?

The limit is 60 requests per minute per key (10 per minute before the first top-up). Process requests sequentially or implement retry logic with exponential backoff to handle queueing during high load.

What audio formats are supported?

You can request mp3, wav, opus, flac, or pcm formats by setting the response_format field. Choose the format that best fits your clinical documentation delivery method or storage requirements.

How do I split long texts for synthesis?

Split your text into chunks of up to 4096 characters. Send each chunk as a separate request to the API, then programmatically join the returned audio files into a single file.

What happens if I exceed the rate limit?

Requests are processed one after another, so under load a request may wait in a queue. If the queue fills or the limit is strictly enforced, you may receive a 429 error. Implement retry logic.

Can I adjust the speed of the speech?

Yes, set the speed parameter between 0.25 and 4.0. This allows you to adjust the playback rate of the generated audio to suit different listening preferences or training material pacing.

How do I select a specific voice?

Specify one of the 8 preset voices in the voice field. Options include aria, nova, luna, sage, felix, milo, atlas, or orion, each offering distinct tonal qualities for medical narration.

Is there a way to detect the language?

If the language field is not set, the system guesses it from the script (Latin defaults to English). For non-English Latin-script text, explicitly set the language using the ISO code.

What is the difference between tts-1 and tts-1-hd?

Both models use the same engine and have the same price. The model field accepts either 'tts-1' or 'tts-1-hd' without any difference in cost.

How do I handle failed requests?

Failed requests are free; the charge is returned in full if synthesis fails. You can retry the request or adjust parameters like text length or voice based on the error response.

Can I use multiple API keys for higher limits?

Each key has a limit of 60 requests per minute. You can issue a new key at any time, but the old one stops immediately.

First request

curl

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

Start by creating an account on the /get-api-key/ page to access the API key required for all requests. You can sign up using either Google authentication or a standard email and password combination. This account is specific to bf77.info and will hold your unique Bearer token and usage balance.

Sign up on the get-api-key page

Sign up on the get-api-key page

Navigate to the get-api-key page to initiate the registration process. The dashboard will display your current balance, trial status, characters left, and a ready-to-use cURL example once you are logged in.

Choose Google or email authentication

Choose Google or email authentication

You may authenticate via Google for immediate access or use an email and password setup. Note that Google sign-ups include a $0.50 free trial credit valid for 7 days, while email accounts start without trial credit.

Copy your Bearer token

Once registered, locate your active API key on the dashboard. Use this key in the Authorization: Bearer <key> header for all subsequent API calls. You can generate a new key at any time, which will immediately invalidate the previous one.

  • Keys are unique per account
  • Old keys stop immediately upon new key generation
  • Keys start with tts-

First Request with cURL

Sound wave illustration for: First Request with cURL

Generate audio by sending a POST request to the speech endpoint. The API accepts JSON bodies containing your text and configuration, returning the synthesized audio file directly in the response.

POST to the speech endpoint

Send your request to https://api.bf77.info/v1/audio/speech. Use the Authorization: Bearer tts-... header with your API key.

Include model and voice parameters

Specify the model ("tts-1" or "tts-1-hd") and voice (e.g., "aria", "atlas"). Include the input text (max 4096 characters) and optional language code.

Receive audio file in response

The response contains the audio file in your chosen response_format (mp3, wav, opus, flac, or pcm). Save this binary data to your clinical documentation server.

  • Format: mp3, wav, opus, flac, pcm
  • Max input: 4096 characters
  • Auth: Bearer token

Using the OpenAI SDK

Sound wave illustration for: Using the OpenAI SDK

Leverage the official OpenAI SDKs by pointing them to the MedTTS infrastructure. This allows teams to reuse existing codebases with minimal adjustments, ensuring a smooth transition from legacy providers like Amazon Polly for clinical documentation workflows.

Set base_url to the API domain

Configure the SDK client’s base_url to https://api.bf77.info/v1. This directs requests to the correct endpoint for speech synthesis, maintaining compatibility with standard OpenAI request shapes.

Use the official OpenAI client

Instantiate the standard OpenAI client in your preferred language. Pass the base URL during initialization so all subsequent calls, including audio.speech, route through the MedTTS Guide API.

Change the key for authentication

Replace the default API key with your unique Bearer token from the dashboard. The SDK handles authentication headers automatically, securing your requests to the speech endpoint.

Supported Audio Formats

Sound wave illustration for: Supported Audio Formats

The API returns audio in five supported formats: mp3, wav, opus, flac, and pcm. Choose the format that best matches your storage and playback requirements.

MP3 for web playback

MP3 is the standard for web delivery. It offers a good balance between file size and quality, making it ideal for embedding in patient guide apps or training portals.

WAV for high-quality archives

WAV provides uncompressed audio, preserving the full fidelity of the synthesized speech. This format is suitable for archival purposes or when downstream processing requires lossless input.

FLAC for lossless storage

FLAC offers lossless compression, reducing file size without sacrificing audio quality. It is efficient for long-form clinical documentation storage where space savings are needed but quality must remain intact.

Rate Limits and Queues

Sound wave illustration for: Rate Limits and Queues

MedTTS Guide enforces strict rate limits to ensure stable synthesis for large medical teams. Each API key is capped at 60 requests per minute, allowing consistent throughput for batch processing patient guides and training materials.

60 requests per minute per key

After your first top-up, your active key supports a steady stream of 60 synthesis requests every minute. This limit applies collectively to all requests sent from your single API key, regardless of the client or script used.

10 requests before first top-up

New accounts starting with the free trial credit ($0.50) are restricted to 10 requests per minute.

Queue processing under load

Requests are processed sequentially. If you exceed the per-minute limit or send a burst of requests, additional requests enter a queue. Processing typically takes roughly 25 characters of text per second of generated audio, so long documents may experience slight delays during high-volume periods.

  • Requests are processed one after another.
  • Short phrases take a few seconds to synthesize.
  • Longer texts are split into 4096-character parts.
Rate Limits and Queues

Error Handling and Status Codes

Sound wave illustration for: Error Handling and Status Codes

MedTTS Guide returns standard HTTP status codes to help you troubleshoot integration issues quickly. Understanding these responses ensures your clinical documentation pipeline handles errors gracefully.

We recommend implementing retry logic for transient errors and logging detailed error messages for your development team to review during large-scale audio generation batches.

400 for invalid parameters

A 400 response indicates that the request body contains invalid data. This often occurs when the input text exceeds the 4096-character limit or when an unsupported voice name is provided. Ensure your text is properly encoded and within character limits before submission.

  • Check that input is under 4096 characters per request.
  • Verify that voice matches one of the 8 available presets.
  • Ensure model is set to "tts-1" or "tts-1-hd".

401 for unauthorized access

A 401 response means your API key is missing or invalid. Ensure you include the Authorization: Bearer tts-... header in every request. If you issued a new key, the old one stops immediately, so update your configuration to avoid service interruptions.

  • Include the correct Bearer token in the Authorization header.
  • Verify the key format starts with tts-.
  • Check that the key is active and not revoked.

429 for rate limit exceeded

A 429 response indicates you have exceeded the rate limit of 60 requests per minute per key. New accounts start with a limit of 10 requests per minute. Implement exponential backoff or queue your requests to handle bursts during large clinical document processing.

  • Limit is 60 requests per minute after top-up.
  • New accounts start with 10 requests per minute.
  • Requests are processed sequentially, so queues may form under load.

Splitting Long Texts

Sound wave illustration for: Splitting Long Texts

Long patient guides often exceed the 4096 character limit per request. You must split the source text into smaller chunks before sending them to the API.

Split text into 4096 character parts

Divide your clinical documentation into segments of no more than 4096 characters. Ensure you count spaces and punctuation as characters. This ensures every request fits the API's strict input constraints.

  • Count all characters, including spaces and punctuation
  • Keep segments under 4096 characters each
  • Preserve logical sentence boundaries where possible

Generate audio for each part

Send each text segment to the POST /v1/audio/speech endpoint. The API processes requests sequentially, so under load, you may experience slight delays. Each call returns a distinct audio file.

  • Use the same voice and speed settings for consistency
  • Handle each response individually
  • Expect processing time of roughly 25 characters per second

Join files for final output

Concatenate the returned audio files in the exact order of your original text segments. This creates a single, continuous audio file suitable for patient distribution or training modules.

  • Maintain the original sequence of segments
  • Use a standard audio library for joining
  • Verify the final file for seamless transitions

Voice Selection and Speed

Sound wave illustration for: Voice Selection and Speed

For medical teams converting patient guides or training materials, selecting the right voice ensures clarity and engagement. Our API offers eight distinct presets, ranging from the warm, clear narration of Aria to the neutral, news-style delivery of Atlas. Each voice is optimized for natural speech patterns.

Choose from 8 preset voices

Select a voice that matches your content’s tone. Use Felix for energetic promotional updates or Milo for friendly, conversational patient instructions. For formal clinical summaries, Atlas provides a neutral baseline, while Orion’s deep tone suits documentary-style training modules. All voices support our full range of 23 languages without requiring separate voice models.

  • 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

Adjust speed from 0.25 to 4.0

Adjust the speed parameter between 0.25 and 4.0 to control playback rate. Slower speeds (0.25–0.75) aid comprehension for complex medical terminology, while faster settings (1.5–2.0) help teams review large volumes of training materials efficiently. The API maintains natural intonation even at extreme speeds.

Set language for accurate synthesis

Explicitly set the language field using ISO codes for best results, especially with Latin-script text that might not be English. Without this, the system defaults to English, which may cause mispronunciation for languages like German or Dutch. Supported languages include Arabic, Chinese, French, German, Japanese, Korean, Spanish, and others listed in our documentation.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Generate personalized audio reminders for upcoming appointments or medication schedules.

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. LibriTTS-R paper (arXiv 2305.18802)
  3. MDN: Web Speech API
  4. FFmpeg documentation
  5. Creative Commons Attribution 4.0
  6. IETF RFC 7845: Ogg Opus
  7. LibriVox public-domain audiobooks
  8. Node.js documentation
  9. TRON developer hub: TRC-20
  10. curl documentation
  11. openai-node on GitHub
  12. OpenAI API reference: create speech

More on this site