API Documentation for Medical App Developers

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

This guide helps indie developers building health apps integrate our text-to-speech API quickly. We provide clear, medically appropriate voices without hidden fees. You will find concrete examples for generating audio from text, covering all essential endpoints and parameters needed for a smooth integration.

Learn how to generate audio using cURL or the OpenAI SDK by simply changing the base URL. We cover request limits, error handling, and supported formats like MP3 and WAV. This documentation is designed for developers who need a transparent, character-based API that fits seamlessly into patient guide workflows.

API Documentation for Medical App Developers

Frequently asked questions

What is the base URL?

The API base URL is https://api.p3pet.info/v1. You send POST requests to /v1/audio/speech for synthesis. Other endpoints like /v1/voices and /v1/models are also available under this base path. This structure mirrors the OpenAI API, allowing you to use familiar request shapes and standard HTTP methods for all interactions.

Which SDKs can I use?

You can use the official OpenAI SDKs by changing the base_url to https://api.p3pet.info/v1. Since our request shape matches the OpenAI speech endpoint, standard libraries work seamlessly. We do not provide a proprietary SDK, so you rely on these established tools or plain HTTP requests for integration.

How do I authenticate?

Include your API key in the Authorization header as Bearer tts-... . Each account has one active key. If you issue a new key, the old one stops immediately. You can find your key and manage it on the /get-api-key/ page after signing up with Google or email.

What is the character limit?

Each request supports up to 4096 characters of input text. Spaces and punctuation count toward this limit. For longer texts, split them into parts of 4096 characters and join the resulting audio files. This ensures consistent processing and avoids exceeding the per-request constraint defined in our API specification.

Can I change voice speed?

Yes, you can adjust the speed between 0.25 and 4.0 using the speed parameter. This allows you to customize the pacing for medical instructions or patient guides. Adjusting speed does not affect the voice model or language detection, only the playback rate of the generated audio.

Do you support SSML?

No, we do not support SSML. Our API accepts plain text input only. If you need specific pronunciation or pauses, you must include them directly in the text string. We do not offer phoneme dictionaries or custom pronunciation lexicons, keeping the integration simple for indie developers building health apps.

How do I get voices list?

Send a GET request to /v1/voices to retrieve available voices, languages, formats, and pricing. This endpoint lists all 8 voice presets like aria, nova, and felix. You can also check /v1/models for model details. This information helps you select the appropriate voice for your specific medical application needs.

What happens on rate limit?

You are limited to 60 requests per minute per key, or 10 per minute before the first top-up. If you exceed this, requests may queue or fail. Failed requests are free, so you are not charged for timeouts. Monitor your usage on the dashboard to avoid interruptions during peak generation times.

Is streaming supported?

No, streaming is not supported. We do not offer WebSocket or real-time partial audio delivery. You receive the complete audio file in the response after synthesis finishes. This synchronous approach simplifies integration for indie developers who prefer standard HTTP responses over managing complex streaming connections for their health app audio features.

Can I use custom models?

No, you cannot use custom models. We offer two models: tts-1 and tts-1-hd. Both use the same engine and price. You cannot upload your own voice or design custom voices. The available voices are fixed presets based on licensed recordings, ensuring consistent quality without the complexity of model management.

How do I handle errors?

If synthesis fails, the charge is returned in full. Check the response status code and error message for details. Common issues include rate limits or invalid parameters. Failed requests do not consume your character balance. Use the /v1/voices endpoint to verify voice names and languages before sending your synthesis requests.

Do I need to split long texts?

Yes, if your text exceeds 4096 characters, you must split it into parts. Generate audio for each part and join the files. This ensures each request stays within the character limit. Our typical speed is roughly real-time, so splitting helps manage processing time and prevents timeouts during synthesis for longer medical guides.

What is the response format?

You can specify the response format as mp3, wav, opus, flac, or pcm. The audio is returned directly in the response body. Each generated file carries an inaudible watermark marking it as synthetic speech. Choose the format that best fits your health app’s playback requirements and storage constraints.

Is there a WebSocket endpoint?

No, there is no WebSocket endpoint. We do not support streaming or real-time audio delivery. All interactions are standard HTTP requests. You send text and receive the complete audio file. This design keeps the integration straightforward for indie developers who do not need complex real-time audio pipelines for their applications.

First request

curl

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

Sign up at /get-api-key/ using Google or email to receive your unique API key. The dashboard displays your key, current balance, and a ready-to-use cURL example tailored for medical app integration.

Sign up on the site

Sign up on the site

Create an account to access your credentials. Google sign-ups include a $0.50 trial credit valid for 7 days, giving you immediate capacity to test voice synthesis without upfront payment.

View key on dashboard

View key on dashboard

Your active key appears on the dashboard alongside usage metrics. You can see your remaining balance and character counts directly, ensuring transparent billing as you build your health app.

Issue new key anytime

Generate a new key instantly from the dashboard. The previous key stops working immediately, allowing you to revoke access securely without waiting for email confirmations or manual approvals.

First request with cURL

Sound wave illustration for: First request with cURL

Send a POST request to https://api.p3pet.info/v1/audio/speech with your Bearer token. The API expects a JSON body containing the text, model, voice, and format. This straightforward structure mirrors standard TTS endpoints, making it easy to integrate into your health app’s backend.

POST to /v1/audio/speech

Directly target the speech endpoint with your authentication header. Ensure your request includes the Authorization: Bearer header with your unique key. This single point of contact handles all synthesis tasks for your patient guides.

JSON body with input

Construct a JSON object with input (max 4096 characters), model (e.g., "tts-1"), voice (e.g., "sage"), and response_format (e.g., "mp3"). Include an optional language code for non-English Latin text to ensure accurate pronunciation in medical contexts.

  • Model: "tts-1" or "tts-1-hd"
  • Voice: "sage" for instructional tone
  • Input: Plain text up to 4096 chars
  • Format: mp3, wav, opus, flac, or pcm

Receive audio file

The response returns the raw audio binary data. Save this directly to your app’s media library. Failed requests incur no charge, ensuring you only pay for successfully generated medical audio files.

Using the OpenAI SDK

Sound wave illustration for: Using the OpenAI SDK

The MedTTS Switch API mirrors the OpenAI speech endpoint structure, allowing you to use existing client libraries with minimal configuration. Simply update the base URL in your SDK client to point to our API endpoint. This compatibility means you can reuse your current integration code, reducing the learning curve for your development team.

Change base_url

Update your SDK configuration to use https://api.p3pet.info/v1 as the base URL. This directs all requests to our infrastructure while maintaining the standard request format.

Use official SDKs

You can use the official OpenAI SDKs for Python, Node.js, and other languages. Since the request shape is identical, no custom client code is required.

Same request shape

The JSON body structure remains consistent with OpenAI standards. Pass your text, voice, and model parameters just as you would for OpenAI, but with our API key.

Available endpoints

Sound wave illustration for: Available endpoints

MedTTS Switch exposes three core endpoints to streamline your integration. The primary speech endpoint handles generation, while the auxiliary endpoints provide essential metadata for building a polished medical app interface.

All requests use standard JSON bodies and require your API key in the Authorization header. The base URL is https://api.p3pet.info/v1.

POST /v1/audio/speech

This is your main endpoint for converting text into audio. Send a POST request with your input text (up to 4096 characters) and desired parameters like voice or response_format. The API returns the generated audio file directly in the response.

GET /v1/voices

Retrieve a list of all available voices, their associated languages, supported audio formats, and current pricing. This endpoint helps you dynamically populate your app’s voice selector without hardcoding options.

GET /v1/models

Fetch the list of available models, such as tts-1 and tts-1-hd. Use this to verify model availability or update your integration when new models are added.

Request parameters

Sound wave illustration for: Request parameters

Configure your synthesis requests using specific parameters to match the clinical tone of your health app. You control the engine quality, vocal identity, and playback speed to ensure the output fits your patient guide workflow perfectly.

Model selection

Choose between tts-1 for standard quality or tts-1-hd for higher fidelity. Both use the same engine and pricing, so pick based on your audio clarity needs.

Voice preset

Select from eight distinct voices, such as sage for instructional content or luna for soft storytelling. Every voice supports all 23 languages, allowing you to maintain consistent character identity across diverse patient guides.

  • Female: aria, nova, luna, sage
  • Male: felix, milo, atlas, orion

Speed adjustment

Adjust playback speed between 0.25x and 4.0x. This lets you slow down complex medical instructions for clarity or speed up routine updates. Remember to split input text into parts of up to 4096 characters and join the audio files yourself, as the API does not handle this automatically.

Request parameters

Response formats

Sound wave illustration for: Response formats

Choose the audio format that best balances quality and bandwidth for your medical app. MP3 offers high compression for standard playback, while WAV provides uncompressed lossless audio for archival or high-fidelity requirements.

MP3 output

MP3 is the default and most common format. It provides a good balance between file size and audio quality, making it ideal for streaming or downloading patient guides over mobile networks.

WAV output

WAV delivers uncompressed audio. Use this format when you need to preserve every detail of the synthesized voice for professional medical narration or archival purposes.

OPUS and FLAC

OPUS offers superior compression at low bitrates, perfect for data-constrained environments. FLAC provides lossless compression, reducing file size without any quality loss, suitable for storing large volumes of audio content.

Rate limits

Sound wave illustration for: Rate limits

MedTTS Switch enforces a rate limit of 60 requests per minute per API key. This ensures stable performance for your health app’s patient guides. Requests are processed sequentially, so high demand may introduce slight queue delays.

60 requests per minute

Standard accounts can send up to 60 synthesis requests each minute. This limit applies per key, so ensure you manage your tokens efficiently. Longer texts split into chunks count as separate requests.

10 requests initially

New accounts start with a lower limit of 10 requests per minute. This helps maintain system stability during the initial trial period. You can verify your current status on the dashboard.

Limit increase after top-up

Sending your first top-up via USDT (TRC-20) increases your limit to the full 60 requests per minute. Credits are added automatically within minutes of transfer. Your previous key stops working immediately when you issue a new one.

Error handling

Sound wave illustration for: Error handling

Synthesis failures are handled transparently. If a request fails, the charge is returned in full, so you are never billed for audio you did not receive. This applies to server-side errors or invalid parameters.

Use the standard HTTP status codes to determine next steps. Most errors are immediate and indicate a clear issue with the request structure or account status.

Failed request refund

Any synthesis error triggers an automatic refund. The API returns a 4xx or 5xx status code without deducting from your character balance. You can safely retry the same text without risking double charges.

Common error codes

400 Bad Request: Check your JSON body, especially voice IDs or character limits. 401 Unauthorized: Verify your Bearer token is active. 429 Too Many Requests: You have exceeded the 60 requests per minute limit.

  • 400: Invalid voice or format
  • 401: Expired or wrong key
  • 429: Rate limit exceeded

Retry logic

For rate limits (429), wait briefly before retrying. The limit resets every minute. For temporary server errors (5xx), implement exponential backoff. Since requests are processed sequentially, short delays help avoid queue congestion.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. This simplicity reduces integration time for indie developers building health apps.

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. LibriVox public-domain audiobooks
  3. IETF RFC 7845: Ogg Opus
  4. LibriTTS-R corpus (OpenSLR 141)
  5. openai-node on GitHub
  6. MDN: Web Speech API
  7. curl documentation
  8. LibriTTS-R paper (arXiv 2305.18802)
  9. FFmpeg documentation
  10. W3C WAI: making audio and video accessible
  11. Tether (USDT)
  12. TRON developer hub: TRC-20

More on this site