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.
- 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.
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. - 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.
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.