API Documentation for Text-to-Speech Integration

By Paston editorial team · Updated 2026-11-19

This documentation provides the technical reference for integrating CliniVoice’s text-to-speech API into medical applications. It covers the standard POST /v1/audio/speech endpoint, compatible with OpenAI SDKs, allowing developers to generate consistent audio files for patient guides and educational content using licensed synthetic voices.

Readers will find specific details on authentication, request parameters, and rate limits. The guide explains how to handle character splitting for longer texts, manage speed and language settings for clarity, and interpret error responses. Use this page to implement reliable, character-based TTS infrastructure for large medical teams.

API Documentation for Text-to-Speech Integration

Frequently asked questions

How do I get my API key?

Sign up on /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. Each account holds one active key.

Can I use the OpenAI Python SDK?

Yes. The API accepts the same request shape as the OpenAI speech endpoint. Change the SDK's base_url to https://api.paston.cc/v1 and use your CliniVoice key. The official OpenAI SDKs work directly without modification for standard text-to-speech requests.

What is the base URL?

The base URL is https://api.paston.cc/v1. Use POST https://api.paston.cc/v1/audio/speech for synthesis. Other endpoints include GET /v1/voices and GET /v1/models. Authentication requires an Authorization header with your Bearer token.

Does the API support SSML?

No. The API does not support SSML, phoneme dictionaries, or custom pronunciation lexicons. You must provide plain text input. The engine processes the text directly without markup interpretation for pauses or emphasis beyond standard natural language processing.

How do I handle long texts?

Split texts into parts of up to 4096 characters per request. Send each part via POST /v1/audio/speech. Join the resulting audio files on your end. This ensures compliance with the single-request character limit while allowing full document synthesis.

Is the response format JSON or audio?

The response is the audio file itself, not JSON. The body contains the binary audio data in your chosen format (mp3, wav, opus, flac, or pcm). Headers include content-type and content-length for proper handling by your client.

Can I change the voice mid-sentence?

No. Each request generates audio for a single voice preset. To change voices, you must send separate requests for each segment and join the audio files. The API does not support dynamic voice switching within a single audio stream.

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. Failed requests are free, and the charge is returned in full. Monitor your usage via the dashboard to stay within limits.

Is the API compatible with cURL?

Yes. The endpoint accepts standard HTTP POST requests. You can use cURL to send JSON bodies with model, input, voice, and response_format fields. The dashboard provides a ready cURL example for immediate testing and integration into your scripts.

Do I need to install a specific library?

No. You can use plain HTTP or any library that supports JSON POST requests. The official OpenAI SDKs work by adjusting the base URL. No proprietary CliniVoice library is required for integration into your existing applications or workflows.

Can I use the API in a browser?

Yes. Since it is a standard REST API, you can call it directly from browser JavaScript. Ensure you handle CORS and secure your API key appropriately. The API returns audio files that can be played via HTML5 audio elements.

Is the audio returned immediately?

Not always. Requests are processed sequentially, so under load, a request may wait in a queue. Typical speed is roughly real-time, but short phrases may take a few seconds. The response contains the audio once synthesis is complete.

Can I specify a language for English text?

Yes. Set the optional language parameter to an ISO code. If unset, the engine guesses the language, defaulting to English for Latin script. For non-English Latin text, explicitly set the language to ensure accurate pronunciation and voice selection.

Does the API support WebSocket?

No. The API is synchronous HTTP. It does not support WebSocket, streaming, or real-time partial audio. You receive the complete audio file after the request is processed. Use standard HTTP POST for all interactions with the speech endpoint.

First request

curl

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

CliniVoice uses standard Bearer token authentication. Include your API key in the HTTP header as Authorization: Bearer <key>. This key grants access to all endpoints for your account.

Bearer Token in Header

Bearer Token in Header

Pass your key as a Bearer token in the Authorization header of every request. This is the only authentication method supported.

Single Active Key Per Account

Single Active Key Per Account

Each account maintains one active API key. This simplifies key management for medical teams integrating into their existing workflows.

Rotate Key Any Time

Issue a new key at any time via the dashboard. The previous key becomes invalid immediately, ensuring secure access control without downtime.

Endpoints

Sound wave illustration for: Endpoints

The API provides three primary endpoints for synthesizing audio and managing resources. All requests use JSON bodies and require a Bearer token for authentication against the base URL https://api.paston.cc/v1.

POST /v1/audio/speech

This endpoint accepts text input and returns an audio file. It mirrors the OpenAI speech endpoint structure, allowing standard SDKs to work by adjusting the base URL.

  • Accepts model, input, voice, response_format, and speed.
  • Text is limited to 4096 characters per request.
  • Returns audio directly in the response body.

GET /v1/voices

Returns a list of available voices, supported languages, and formats. Use this to identify the correct voice ID for your synthesis requests.

  • Lists 8 voice presets (e.g., aria, nova, atlas).
  • Shows supported languages and audio formats.
  • Includes pricing details per character.

GET /v1/models

Returns the available model identifiers. Currently supports tts-1 and tts-1-hd, which use the same engine and pricing.

  • Returns tts-1 and tts-1-hd.

Request Parameters

Sound wave illustration for: Request Parameters

The API accepts text input and converts it into audio using one of two model versions. The tts-1 and tts-1-hd models share the same engine and pricing structure, allowing you to choose based on quality preferences without cost differentiation.

model: tts-1 or tts-1-hd

Both models utilize the same underlying synthesis engine. Select tts-1 for standard generation or tts-1-hd for higher fidelity output. Pricing remains identical at $0.01 per 1,000 characters regardless of the model chosen.

input: text up to 4096 chars

Pass your patient guide text or educational content in the input field. The maximum limit is 4,096 characters per request. For longer documents, split the text into chunks of this size and join the resulting audio files sequentially.

  • Count spaces and punctuation as characters.
  • Split long texts into 4,096-character segments.
  • Join resulting audio files for final playback.

voice: one of 8 presets

Select from eight licensed voices optimized for clarity and consistency. Each voice supports all 23 available languages, ensuring uniform tone across diverse patient demographics. Choose based on the desired tone for your medical content.

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

Response Formats

Sound wave illustration for: Response Formats

The API returns synthesized audio directly in the response body as a binary file. You can select the output format via the response_format parameter: mp3, wav, opus, flac, or pcm. This allows medical teams to choose the appropriate balance between file size and quality for their specific patient guide distribution channels.

mp3, wav, opus, flac, pcm

Choose mp3 for standard web delivery or wav for uncompressed archival needs. opus offers high efficiency for web delivery, while flac provides lossless compression. pcm delivers raw linear audio data for specialized processing pipelines.

  • mp3: Universal compatibility, smaller file size
  • wav: Uncompressed, high fidelity
  • opus: Efficient compression, web-ready
  • flac: Lossless compression
  • pcm: Raw binary audio

Audio File in Response Body

The generated audio file is included directly in the HTTP response body. No additional download steps are required. The response headers indicate the content type matching your selected format, ensuring straightforward integration into existing audio players or storage systems used by medical teams.

No Streaming Support

The API does not support WebSocket or real-time partial audio streaming. Audio is generated and returned as a complete file after synthesis finishes. For long patient guides, ensure your implementation handles the full binary payload appropriately, as partial chunks are not available during generation.

Speed Control

Sound wave illustration for: Speed Control

The speed parameter accepts values between 0.25 and 4.0, allowing precise control over the voice’s pace. , providing a natural baseline for most clinical content. Adjusting this value directly impacts the duration of the generated audio file.

Range: 0.25 to 4.0

Values outside this range are rejected. Slower speeds (e.g., 0.5) extend playback time, useful for complex medical terminology. Faster speeds (e.g., 2.0) compress delivery, suitable for routine informational updates.

Default Speed

The API defaults to 1.0 if no speed value is provided. This ensures consistent output without requiring explicit configuration for standard patient guides.

Adjust for Patient Comprehension

Tuning speed is critical for accessibility. Reducing speed to 0.75–0.8 can aid patients with cognitive impairments or non-native speakers. Test audio clips with target user groups to determine the optimal balance between clarity and engagement.

  • 0.5: Very slow, high clarity
  • 0.75: Slow, enhanced comprehension
  • 1.0: Natural, standard pace
  • 1.5: Fast, efficient updates
  • 2.0: Very fast, concise info
Speed Control

Language Handling

Sound wave illustration for: Language Handling

The API accepts an optional language parameter to specify the target language using an ISO code. This ensures precise voice synthesis when the input text language is ambiguous or when multiple languages are mixed within a single request body.

Optional ISO Code

You can pass a standard ISO 639-1 code (e.g., de, fr, es) to constrain the synthesis engine. This is useful when your medical content includes multilingual sections or when you need to enforce a specific language regardless of the input text's primary script.

  • Supported codes include: ar, zh, da, nl, en, fi, fr, de, el, he, hi, it, ja, ko, ms, no, pl, pt, ru, es, sw, sv, tr

Auto-Detection for Latin Script

If the language field is omitted, the system guesses the language based on the text's script. For Latin-script text, English is the default assumption. This works well for standard English medical guides but may fail for other Latin-based languages like Spanish or German without explicit specification.

Explicit Language Recommended

For consistent clinical audio, we recommend explicitly setting the language parameter. Auto-detection may misidentify similar Latin scripts, leading to unnatural pronunciation in patient instructions. Explicit language codes guarantee the correct voice preset applies to the intended linguistic context.

Rate Limits

Sound wave illustration for: Rate Limits

CliniVoice enforces strict rate limits to ensure stable generation for medical teams. Each API key allows 60 requests per minute, providing sufficient throughput for batch-processing patient guides or educational audio scripts.

60 Requests per Minute

The standard limit applies once your account is active. This capacity supports regular production workflows, allowing teams to generate multiple audio files concurrently without immediate throttling.

10 Requests per Minute Initial

New accounts start with a lower limit of 10 requests per minute. This ensures system stability during the initial phase. The limit increases to the standard 60 RPM after the first top-up is credited.

  • Initial limit: 10 RPM
  • Increase: After first top-up
  • Standard limit: 60 RPM

Queue Under Load

Requests are processed sequentially. Under high load, a request may wait in a queue before synthesis begins. This ensures consistent audio quality but may increase latency during peak usage periods.

Error Handling

Sound wave illustration for: Error Handling

The API returns standard HTTP status codes to indicate the request result. A 200 OK confirms successful audio generation. Use 400 Bad Request to correct malformed JSON or invalid parameters. A 429 Too Many Requests indicates you have exceeded the 60 requests per minute limit. Use 401 Unauthorized if your Bearer token is missing or invalid. A 500 Internal Server Error indicates a transient issue on our end, which may require a brief retry.

HTTP Status Codes

The API uses standard HTTP status codes to indicate the result of your request. A 200 OK status confirms successful audio generation. Use 400 Bad Request to correct malformed JSON or invalid parameters. A 429 Too Many Requests indicates you have exceeded the 60 requests per minute limit. Use 401 Unauthorized if your Bearer token is missing or invalid. A 500 Internal Server Error indicates a transient issue on our end, which may require a brief retry.

  • 200: Success
  • 400: Invalid parameters or JSON
  • 401: Authentication failure
  • 429: Rate limit exceeded
  • 500: Internal server error

Free Refund on Failure

If a request fails due to a server error or invalid input, the character count is not deducted from your balance. This ensures you only pay for successfully generated audio. Failed requests are processed instantly, and the refund is applied to your account immediately. Check the error message to determine if a retry is appropriate or if you need to correct the input parameters.

JSON Error Response

All error responses are returned in JSON format. The body includes an error object with a code and a message field. The code provides a machine-readable identifier for the error type, while the message offers a human-readable explanation. Example error response: `{"error": {"code": "invalid_request", "message": "Input text exceeds 4096 characters."}}`. Use this structure to programmatically handle errors in your application logic.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. This range allows teams to cover more ground in less time, which is useful for daily briefings.

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. OpenAI API reference: create speech
  4. curl documentation
  5. TRON developer hub: TRC-20
  6. LibriTTS-R corpus (OpenSLR 141)
  7. openai-node on GitHub
  8. FFmpeg documentation
  9. Tether (USDT)
  10. Python documentation
  11. IETF RFC 7845: Ogg Opus
  12. W3C WAI: making audio and video accessible

More on this site