Audio & embeddings
Text-to-speech (TTS), speech recognition (ASR) and text embeddings.
Text-to-speech (TTS)
POST https://api.onefast.ai/v1/audio/speech
Returns the audio as a binary stream.
cURL
curl https://api.onefast.ai/v1/audio/speech \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "speech-2.8-turbo",
"input": "Hello, and welcome to our service.",
"voice": "male-qn-qingse",
"response_format": "mp3"
}' --output speech.mp3
Python
from openai import OpenAI
client = OpenAI(api_key="sk-xxx", base_url="https://api.onefast.ai/v1")
with client.audio.speech.with_streaming_response.create(
model="speech-2.8-turbo",
input="Hello, and welcome to our service.",
voice="male-qn-qingse",
response_format="mp3",
) as resp:
resp.stream_to_file("speech.mp3")
| Parameter | Description |
|---|---|
model |
speech-2.8-hd, speech-2.8-turbo, speech-2.6-hd, etc. See the model catalog. tts-1 / tts-1-hd / gpt-4o-mini-tts also work (see below) |
input |
Text to read aloud, up to 10,000 characters |
voice |
Voice ID, e.g. male-qn-qingse, female-shaonv, English_expressive_narrator |
response_format |
mp3 (default) / wav / flac / pcm. wav / flac / pcm accept at most 2,000 characters per request |
speed |
Speaking speed, 0.5–2.0 |
- Billed by character count; each Chinese, Japanese or Korean character counts as 2 characters. The model catalog lists prices per 10K characters.
- If you pass an OpenAI voice name (such as
alloy), the default English voice is used. - OpenAI model names work as-is:
tts-1andgpt-4o-mini-ttsmap tospeech-2.8-turbo, andtts-1-hdmaps tospeech-2.8-hd. Existing OpenAI SDK code only needs a newbase_urland key. - Unsupported formats such as
opus/aacare returned asmp3.
Gemini text-to-speech
gemini-3.8-flash-tts and gemini-3.8-flash-lite-tts can be called through either of two endpoints.
Option 1: OpenAI-compatible endpoint (existing OpenAI SDK code only needs the model name changed)
cURL
curl https://api.onefast.ai/v1/audio/speech \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash-tts",
"input": "Have a wonderful day!",
"voice": "Kore",
"instructions": "Say cheerfully",
"response_format": "wav"
}' --output speech.wav
| Parameter | Description |
|---|---|
voice |
A Gemini prebuilt voice name, e.g. Kore, Puck, Charon, Zephyr, Fenrir, Leda, Aoede (30 voices, case-insensitive). OpenAI voice names (e.g. alloy) or an omitted voice fall back to Kore |
instructions |
Optional. Describe tone, emotion or pace in natural language, e.g. Say cheerfully, Speak slowly in a whisper |
response_format |
Only wav (default) and pcm (raw 24 kHz, 16-bit, mono) are supported. mp3 / opus / aac / flac are returned as wav with Content-Type: audio/wav |
speed |
Not supported and ignored; describe the pace in instructions instead |
speechConfig |
Optional. Native Gemini voice config, applied as-is and taking precedence over voice; use multiSpeakerVoiceConfig for multiple speakers (see the example below) |
Option 2: Gemini native endpoint (request and response match the official Google API; the audio is base64-encoded in candidates[0].content.parts[0].inlineData)
cURL
curl "https://api.onefast.ai/v1beta/models/gemini-3.8-flash-tts:generateContent" \
-H "x-goog-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "Joe: How is it going today, Jane?\nJane: Not too bad, how about you?"}]}],
"generationConfig": {
"responseModalities": ["AUDIO"],
"speechConfig": {
"multiSpeakerVoiceConfig": {
"speakerVoiceConfigs": [
{"speaker": "Joe", "voiceConfig": {"prebuiltVoiceConfig": {"voiceName": "Kore"}}},
{"speaker": "Jane", "voiceConfig": {"prebuiltVoiceConfig": {"voiceName": "Puck"}}}
]
}
}
}
}'
- On the native endpoint,
inlineData.mimeTypemay beaudio/wav(WAV header included) oraudio/L16;codec=pcm;rate=24000(raw PCM; add a WAV header yourself or convert withffmpeg -f s16le -ar 24000 -ac 1 -i out.pcm out.wav). The OpenAI-compatible endpoint handles both and always returns playablewav. - Billed by tokens: input text at the input price, generated audio at the output price (about 25 tokens per second of audio), based on the usage reported upstream. The per-minute price in the model catalog is an estimate based on 25 tokens of audio output per second, excludes input text, and is for reference only.
- Requests blocked by the content safety policy return 400 and are not billed.
Doubao speech synthesis (Seed TTS 2.0)Beta
Beta: ready for production calls; parameters and default voices may still be fine-tuned.
Model doubao-seed-tts-2-0, called through the same /v1/audio/speech endpoint; existing OpenAI SDK code only needs the model name changed.
cURL
curl https://api.onefast.ai/v1/audio/speech \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seed-tts-2-0",
"input": "Добрый день! Рады видеть вас снова.",
"response_format": "mp3"
}' --output speech.mp3
| Parameter | Description |
|---|---|
voice |
A Doubao Speech 2.0 voice ID. If omitted, or if an OpenAI voice name (e.g. alloy) is passed, a default voice is chosen from the text: ru_female_sophie_uranus_bigtts for Russian, zh_female_vv_uranus_bigtts for Chinese, en_female_allison_uranus_bigtts otherwise |
response_format |
mp3 (default) / opus (Ogg container) / wav / pcm; aac, flac and others are returned as mp3 |
speed |
Speed multiplier, effective range about 0.5–2.0; values outside are clamped |
instructions |
Optional. Describe tone and emotion in natural language, e.g. Speak warmly and slowly |
audio_params |
Optional, e.g. {"sample_rate": 48000}; sample rate can be 8000 / 16000 / 22050 / 24000 (default) / 32000 / 44100 / 48000 |
- Billed by character count: spaces and punctuation count, and every Chinese, English or Russian character counts as 1 (unlike the
speech-*models above, where each CJK character counts as 2). The model catalog lists prices per 10K characters. - An
inputthat is empty or contains only punctuation and symbols returns 400 and is not billed.
Speech recognition (ASR)
POST https://api.onefast.ai/v1/audio/transcriptions
Compatible with the OpenAI transcription API. Upload an audio file (multipart/form-data) and get the recognized text back.
cURL
curl https://api.onefast.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $API_KEY" \
-F model="asr-1.0" \
-F file="@meeting.mp3" \
-F response_format="json"
Python
from openai import OpenAI
client = OpenAI(api_key="sk-xxx", base_url="https://api.onefast.ai/v1")
result = client.audio.transcriptions.create(
model="asr-1.0",
file=open("meeting.mp3", "rb"),
)
print(result.text)
| Parameter | Description |
|---|---|
model |
asr-1.0. whisper-1 also works (maps to asr-1.0) |
file |
Audio file: wav / aiff / flac / m4a / mp3 / aac / opus / ogg. Each file must be at most 500 seconds and 50 MB. Raw PCM without a container is not supported |
response_format |
json (default) / verbose_json / srt / vtt / text |
language |
Optional. Hint for the main spoken language, such as zh, en, ja or yue. Omit it for automatic detection, including mixed Chinese-English speech |
timestamp_granularities[] |
Optional. Pass word to get per-character (Chinese) / per-word (English) timestamps in verbose_json / srt / vtt |
stream |
Optional. true returns results as an SSE stream; only json / text are supported |
What each response_format returns:
| Value | Returns |
|---|---|
json |
{"text": "...", "duration": 26.3} |
verbose_json |
Also includes segments (start/end times and speaker S1 / S2…) and n_speakers, with speaker diarization built in |
srt / vtt |
Subtitle text |
text |
Plain text |
Streaming events use the same format as OpenAI:
data: {"type":"transcript.text.delta","delta":"Hello"}
data: {"type":"transcript.text.done","text":"Hello everyone","usage":{"type":"duration","seconds":7,"input_tokens":117}}
- Billed by audio duration (seconds, rounded up), based on the
durationin the result. The model catalog lists prices per minute. - Split audio longer than 500 seconds before uploading. Speech recognition does not need high sample rates: 16 kHz mono or a compressed format gives the same accuracy.
/v1/audio/translations(speech translation) is not supported.
Doubao speech recognition (Seed ASR 2.0)Beta
Beta: ready for production calls; parameters may still be fine-tuned.
Model doubao-seed-asr-2-0, also via /v1/audio/transcriptions:
cURL
curl https://api.onefast.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $API_KEY" \
-F model="doubao-seed-asr-2-0" \
-F file="@meeting.mp3" \
-F language="ru" \
-F response_format="verbose_json"
| Parameter | Description |
|---|---|
file |
wav / mp3 / ogg / opus / pcm, up to 25 MB per file |
language |
Without it, only Chinese, English and Chinese dialects are recognized; other languages must be specified, e.g. ru, ja, ko, de, fr, es, pt, it, ar, tr, vi, th, id, ms, uk, pl, nl, yue |
response_format |
json (default) / verbose_json (with sentence segments and per-word words timestamps) / srt / vtt / text |
- Billed by audio duration (seconds, rounded up). The model catalog lists prices per minute.
- Streaming (
stream) and/v1/audio/translationsare not supported.
MiniMax-compatible endpoints
Code already written against the official MiniMax documentation works by changing only the domain and key. Request and response formats are unchanged.
Text-to-speech (sync)
POST https://api.onefast.ai/v1/t2a_v2
cURL
curl https://api.onefast.ai/v1/t2a_v2 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "speech-2.8-hd",
"text": "Hello, welcome to our service.",
"stream": false,
"voice_setting": {"voice_id": "English_expressive_narrator", "speed": 1, "emotion": "happy"},
"audio_setting": {"format": "mp3", "sample_rate": 32000}
}'
- Returns JSON. The audio is in
data.audio, hex-encoded; usage is inextra_info.usage_characters. stream: trueis supported (SSE chunks of hex audio; the last frame hasdata.status = 2and the full usage).- Fields such as
voice_setting,audio_setting,pronunciation_dict,language_boostandvoice_modifywork as documented. output_formatis alwayshex(no audio download URLs) andsubtitle_enableis not available.wav/flac/pcmaccept at most 2,000 characters per request.
Speech recognition
POST https://api.onefast.ai/v1/speech_to_text
cURL
curl https://api.onefast.ai/v1/speech_to_text \
-H "Authorization: Bearer $API_KEY" \
-H "language: en" \
-F model="asr-1.0" \
-F file="@meeting.mp3" \
-F response_format="verbose_json" \
-F timestamp_level="word"
- The language hint goes in the
languagerequest header (optional; detected automatically if omitted). response_formatsupportsjson/verbose_json/srt/vtt;timestamp_levelsupportssentence(default) /word. Withstream: true, results come back as SSE events{"index","delta","finish","duration"}.- File limits and billing are the same as in Speech recognition (ASR) above.
Text embeddings
POST https://api.onefast.ai/v1/embeddings
cURL
curl https://api.onefast.ai/v1/embeddings \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "text-embedding-3-small", "input": "The food was delicious."}'
Python
emb = client.embeddings.create(model="text-embedding-3-small", input=["First passage", "Second passage"])
print(len(emb.data), len(emb.data[0].embedding))
| Parameter | Description |
|---|---|
model |
text-embedding-3-small, text-embedding-3-large, etc. |
input |
A string or an array of strings (batch) |
dimensions |
Optional. Output dimensions (the text-embedding-3 family supports reducing dimensions) |
Billed by input tokens.