Inference APIs

Voices

Kokoro voice ids encode language and gender in the prefix (af_, am_, bf_, bm_). Click to copy.

Orpheus 3B adds tara, leah, jess, leo, dan, mia, zac, zoe with emotion tags such as <laugh> and <sigh>. It is far slower to generate (about a minute per 300 characters in our measurement), so use it for pre-rendered narration.

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": "af_heart", "input": "Hello, and welcome. This is a sample of the voice.", "response_format": "mp3"}' \
  --output english.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="af_heart", input="Hello, and welcome. This is a sample of the voice.")
audio.write_to_file("english.mp3")

Notes

  • Pass language: "en" to make pronunciation of ambiguous tokens follow English 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 English

Kokoro is billed at $5.20 per million characters, so a 1,000-word English 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 costs $19.50 per million characters and is much slower; reserve it for narration you render ahead of time. Requests up to 4,096 characters are accepted; split longer text on sentence boundaries and concatenate the audio.

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

Speech-to-text in English

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