Speech synthesis, transcription and music generation
One key and OpenAI-compatible requests: text in, an audio file out; a recording in, a transcript out; a description in, a finished track out. Parameters, examples in three languages and the billing rules are collected here.
Endpoints and authentication
Audio lives on the OpenAI-compatible entry point and uses the same key as text models: only the path changes. Text to speech (TTS) turns text into a file, speech to text (STT) turns a recording into text, and music generation creates a track from a description.
| Method | Path | Purpose |
|---|---|---|
| POST | https://api.tokenator.top/v1/audio/speech | Text to speech: JSON with text in, an audio file out. |
| POST | /v1/audio/transcriptions | Speech to text: a file in multipart/form-data, text or JSON out. |
| POST | /v1/audio/translations | Like transcription, with the transcript translated where the model supports it. |
| POST | /v1/audio/generations | Music generation: a description in, a finished track out. |
| GET | /v1/audio/models?task=tts|stt|music | The catalog of audio models available to this key, with voices, formats and pricing. |
The key goes in Authorization: Bearer sk-your-tokenator-key. Audio models are absent from /v1/models, and chat endpoints refuse them — they have a catalog of their own.
Your first request
curl https://api.tokenator.top/v1/audio/speech \ -H "Authorization: Bearer sk-your-tokenator-key" \ -H "Content-Type: application/json" \ --output speech.wav \ -d '{ "input": "Hello!", "model": "gemini-3.8-flash-tts", "response_format": "wav", "voice": "Zephyr" }'
A successful answer is the audio file itself, not JSON: --output speech.mp3 saves it to disk. The X-Tokenator-Input-Tokens, X-Tokenator-Output-Tokens and X-Tokenator-Total-Tokens headers carry the request's tokens, which token billing is based on.
Which models handle audio
| Model | API ID | Task | Voices | Formats | Billing |
|---|---|---|---|---|---|
| Gemini 3.8 Flash TTS | gemini-3.8-flash-tts | Text to speech | Zephyr, Puck, Charon, Kore, Fenrir, Leda, Orus, Aoede, Callirrhoe, Autonoe, Enceladus, Iapetus, Umbriel, Algieba, Despina, Erinome, Algenib, Rasalgethi, Laomedeia, Achernar, Alnilam, Schedar, Gacrux, Pulcherrima, Achird, Zubenelgenubi, Vindemiatrix, Sadachbia, Sadaltager, Sulafat | wav, mp3, flac, pcm | Per token |
| Gemini 3.8 Flash Lite TTS | gemini-3.8-flash-lite-tts | Text to speech | Zephyr, Puck, Charon, Kore, Fenrir, Leda, Orus, Aoede, Callirrhoe, Autonoe, Enceladus, Iapetus, Umbriel, Algieba, Despina, Erinome, Algenib, Rasalgethi, Laomedeia, Achernar, Alnilam, Schedar, Gacrux, Pulcherrima, Achird, Zubenelgenubi, Vindemiatrix, Sadachbia, Sadaltager, Sulafat. | wav, mp3, flac, pcm | Per token |
| Gemini 3.5 Transcribe | gemini-3.5-transcribe | Speech to text | — | json | Per token |
| Lyria 3 Clip Preview | lyria-3-clip-preview | Music generation | — | mp3, wav | Per generation |
| Lyria 3 Pro Preview | lyria-3-pro-preview | Music generation | — | mp3, wav | Per generation |
| Grok STT 1.0 | grok-stt-1.0 | Speech to text | — | json | Per token |
| MAI-Transcribe 2 | mai-transcribe-2 | Speech to text | — | json | Per audio second |
| Nemotron 3.5 Transcribe | nemotron-3.5-transcribe | Speech to text | — | json | Per audio second |
| Grok STT 2.0 | grok-stt-2.0 | Speech to text | — | json | Per audio second |
The API returns the same list — with the task, voices, formats and pricing of every model. That is safer than hard-coding values: the list changes together with the catalog.
curl "https://api.tokenator.top/v1/audio/models?task=tts" \ -H "Authorization: Bearer sk-your-tokenator-key"
{
"object": "list",
"data": [
{
"id": "gemini-3.8-flash-tts",
"object": "audio_model",
"audio_options": {
"task": "tts",
"voices": ["Kore", "Puck"],
"default_voice": "Kore",
"formats": ["mp3", "wav"],
"default_format": "mp3",
"billing_unit": "characters",
"tokens_per_million": 120
}
}
]
}Text to speech
| Field | Type | What it does |
|---|---|---|
model | string, required | The API ID of a TTS model from /v1/audio/models?task=tts. |
input | string, required | The text to speak. An empty string is refused with a 400. |
voice | string | A voice from voices. When omitted, default_voice is used; a model without one requires the field. A voice outside the list gets a 400 that lists the allowed ones. |
response_format | string | The file format from formats: mp3, wav or others the model declares. Defaults to default_format. |
speed, instructions, language, sample_rate | per model | Passed to the provider as they are: pace, speaking style, language, sample rate. The effect depends on the model. |
import requests response = requests.post( "https://api.tokenator.top/v1/audio/speech", headers={"Authorization": "Bearer sk-your-tokenator-key"}, json={"model": "gemini-3.8-flash-tts", "input": "Hello! This is a speech synthesis check.", "voice": "Zephyr", "response_format": "mp3"}, timeout=300, ) response.raise_for_status() with open("speech.mp3", "wb") as f: f.write(response.content)
from openai import OpenAI client = OpenAI(api_key="sk-your-tokenator-key", base_url="https://api.tokenator.top/v1", timeout=300) with client.audio.speech.with_streaming_response.create( model="gemini-3.8-flash-tts", voice="Zephyr", input="Hello! This is a speech synthesis check.", response_format="mp3", ) as response: response.stream_to_file("speech.mp3")
import { writeFile } from "node:fs/promises" const response = await fetch("https://api.tokenator.top/v1/audio/speech", { method: "POST", headers: { Authorization: "Bearer sk-your-tokenator-key", "Content-Type": "application/json", }, body: JSON.stringify({ model: "gemini-3.8-flash-tts", input: "Hello! This is a speech synthesis check.", voice: "Zephyr" }), signal: AbortSignal.timeout(300_000), }) if (!response.ok) throw new Error(await response.text()) await writeFile("speech.mp3", Buffer.from(await response.arrayBuffer()))
There is no streamed answer: the file arrives whole, and a request with stream: true or stream_format: "sse" gets a 400.
Speech to text
| Field | Type | What it does |
|---|---|---|
model | string, required | The API ID of an STT model from /v1/audio/models?task=stt. |
file | file, required | One non-empty audio file up to 25 MB — the file itself, not a link. |
response_format | string | json (default) — an object with a text field; text — plain text; verbose_json — JSON with extra fields when the model returns them. |
language, prompt, temperature | per model | The recording language, a hint with terms, the temperature — passed to the provider as they are. |
curl https://api.tokenator.top/v1/audio/transcriptions \ -H "Authorization: Bearer sk-your-tokenator-key" \ -F 'model=gemini-3.5-transcribe' \ -F 'file=@recording.wav' \ -F 'response_format=json'
{
"text": "Hello! This is a transcription check.",
"usage": { "prompt_tokens": 96, "completion_tokens": 9, "total_tokens": 105 }
}from openai import OpenAI client = OpenAI(api_key="sk-your-tokenator-key", base_url="https://api.tokenator.top/v1", timeout=300) with open("recording.wav", "rb") as audio: result = client.audio.transcriptions.create( model="gemini-3.5-transcribe", file=audio, response_format="json", ) print(result.text)
Do not set Content-Type by hand: the client adds the multipart boundary itself. The proxy adds a usage field with the request's tokens to the JSON answer. An empty transcript is a valid answer when the recording holds no speech.
Music generation
| Field | Type | What it does |
|---|---|---|
model | string, required | The API ID of a music model from /v1/audio/models?task=music. |
prompt | string, required | Genre, mood, instruments, tempo — whatever describes the track. Up to 10,000 characters. |
lyrics | string | The lyrics, when the model sings. Up to 10,000 characters; not accepted together with instrumental: true. |
instrumental | boolean | true — music without vocals. |
duration | number, seconds | The target length, above 0 and up to 600. It is a hint to the model: short-clip models always produce a clip of their own length. |
response_format | string | The file format from the model's formats. |
seed | integer | A generation seed from 0 to 2,147,483,647, when the model supports it. |
temperature, top_p | number | temperature from 0 to 2, top_p from 0 to 1. |
max_tokens | integer | From 1 to 1,000,000. |
user | string | Your end-user identifier, up to 256 characters. |
n, stream | integer, boolean | Only n: 1 and stream: false — one request makes one finished file. |
No other fields are accepted: a request with an unknown field gets a 400 listing the supported ones, before the model is called and without a charge. The Content-Type of the answer names the file's real format: if the model returned a different format from the one requested, it shows there.
curl https://api.tokenator.top/v1/audio/generations \ -H "Authorization: Bearer sk-your-tokenator-key" \ -H "Content-Type: application/json" \ --output music.mp3 \ -d '{ "model": "lyria-3-clip-preview", "prompt": "a calm piano melody with a warm mood", "instrumental": true, "duration": 30 }'
import requests response = requests.post( "https://api.tokenator.top/v1/audio/generations", headers={"Authorization": "Bearer sk-your-tokenator-key"}, json={"model": "lyria-3-clip-preview", "prompt": "a calm piano melody with a warm mood", "instrumental": True, "duration": 30}, timeout=600, ) response.raise_for_status() with open("music.mp3", "wb") as f: f.write(response.content)
One request, one track; the answer is a finished file up to 64 MB. Generation can take several minutes: keep the client timeout at 10 minutes or more and do not retry on timeout — a repeat request starts a second generation.
How audio is billed
Audio spends the key's regular token balance — there are no separate bundles. The billing method is set per provider of the model and shown in the catalog's Billing column:
- Per token — (input tokens × multiplier) + (output tokens × multiplier), like text models. When the provider reports no tokens, they are estimated from the text and audio length.
- Per character or per UTF-8 byte — characters (bytes) of text × price per million / 1,000,000 × multiplier. Spaces count.
- Per audio second — for transcription: recording length × price per second × multiplier.
- Per generation — for music: a fixed price per successful track × multiplier.
The total is rounded up to a whole token, at least 1. A failed request costs nothing. When a request falls over to a backup provider, that provider's method applies.
curl https://api.tokenator.top/v1/tokens \ -H "Authorization: Bearer sk-your-tokenator-key"
Limits
- Transcription: one non-empty file up to 25 MB per request.
- Music: one track per request, a file up to 64 MB.
- Synthesis and music answer with a finished file — there is no SSE stream.
- The voice and format must be in the model's lists; otherwise a 400 before the provider is contacted.
- Each model does one task: TTS, STT or music. A request to the wrong endpoint gets a 400.
Errors
| Symptom | Cause | Fix |
|---|---|---|
400 model and non-empty input are required | The synthesis request has no model or text, or the body is not JSON. | Send Content-Type: application/json, model and a non-empty input. |
400 This model is not a TTS model / not an STT model | A model of another task, for example an STT model sent to synthesis. | Pick a model with the right task from /v1/audio/models?task=…. |
400 Unsupported voice / Unsupported response_format | The voice or format is not in the model's list. | The message lists the allowed values; the catalog's audio_options returns the same. |
400 SSE is not supported | A streamed synthesis response was requested. | Drop stream and stream_format: the answer is one file. |
400 one non-empty audio file is required | Transcription got no file, several files or an empty one. | Send exactly one file in the file field of a multipart/form-data form. |
400 Cannot determine the uploaded audio duration | The model is billed per audio second and the file's duration cannot be read. | Send WAV, MP3, FLAC, OGG or WebM with valid duration metadata. |
413 Audio file is larger than 25 MB | The file for transcription is over 25 MB. | Split the recording and send the parts as separate requests. |
429 | The key has run out of its limit, or the request rate is exceeded. | The balance is in /v1/tokens; top up in your account. |
400 Unsupported field … for music generation | The music request carries a field the endpoint does not know, or lyrics together with instrumental: true. | Keep only the fields from the parameter table; drop instrumental for a song and lyrics for an instrumental. |
400 Sensitive words detected | The model refused the request because of its content. Nothing is charged. | Rephrase the description: for example, do not name real artists or protected works. |
503 Provider error | The provider failed or returned a broken file. Its text is not passed to the client, and nothing is charged. | Retry — Tokenator fails over to the model's next provider on its own. If it persists, contact support. |
FAQ
Do I need a separate key for audio?
No. The same key as for chat works, with access to the chosen audio model. Only the request path changes.
What is the difference between TTS and STT?
TTS speaks text: JSON to /v1/audio/speech, an audio file back. STT transcribes a recording: a file to /v1/audio/transcriptions, text back.
Why is the model absent from /v1/models?
Audio models have a separate catalog: GET /v1/audio/models. ?task=tts selects synthesis, ?task=stt transcription, ?task=music music.
How do I choose a voice and format?
Check the model's audio_options: voices, formats, default_voice and default_format. Pass the voice in voice and the format in response_format.
Why can't I read a synthesis answer as JSON?
A successful answer is a binary file. Use --output speech.mp3 with curl, or write response.content to a file in wb mode in Python.
What about a recording over 25 MB?
Split it and transcribe the parts as separate requests — say, ten minutes each.
Are tokens charged when a request fails?
No. A provider error, a refused parameter or a timeout costs nothing.
Why did transcription return empty text?
It happens when the model finds no speech in the recording. Check that the voice is audible, the language is right and the model supports the file format.