Inference APIs

Voices

Kokoro voice ids encode language and gender in the prefix (zf_, zm_). Click to copy.

Quickstart

cURL
curl https://api.inferenceapis.com/v1/audio/speech \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "hexgrad/Kokoro-82M", "voice": "zf_xiaobei", "input": "你好,这是一个语音示例。", "response_format": "mp3"}' \
  --output chinese.mp3
Python · openai SDK
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.inferenceapis.com/v1", api_key=os.environ["INFERENCE_API_KEY"])
audio = client.audio.speech.create(model="hexgrad/Kokoro-82M", voice="zf_xiaobei", input="你好,这是一个语音示例。")
audio.write_to_file("chinese.mp3")

Notes

  • Pass language: "zh" to make pronunciation of ambiguous tokens follow Chinese rules when mixing scripts.
  • Numbers, dates and abbreviations are read as written; spell out anything that must be pronounced a specific way.
  • Billing is per input character; the X-Usage-Characters header shows the metered count.

Cost and speed for Chinese

Kokoro is billed at $5.20 per million characters, so a 1,000-word Chinese article of roughly 6,000 characters costs about $0.03 and an hour-long audiobook chapter of 60,000 characters about $0.31. In our measurement a 300-character request returned in 0.84 s, fast enough to generate sentence by sentence in an interactive app. Orpheus is English-only, so Chinese output always uses Kokoro. Requests up to 4,096 characters are accepted; split longer text on sentence boundaries and concatenate the audio.

Other languages with voices: English, Japanese, Spanish, French, Hindi, Italian, Portuguese.

Speech-to-text in Chinese

The reverse direction: transcribe Chinese audio with Whisper on the Chinese speech-to-text page.