API guide

Speech API

Capability catalogue · ASR contract · TTS contract

Available to invited organizations · 2 November 2026

Use your existing tokenflow API key for transcription and speech synthesis. Check GET /v1/models for the models currently available to your organization.

Speech to text

sensevoice-small accepts WAV audio up to 30 seconds: 16-bit PCM or 32-bit float, one or two channels, 8–48 kHz. Convert MP3 or other formats to WAV first.

curl --fail-with-body https://api.tokenflow.dev/v1/audio/transcriptions \
  -H "Authorization: Bearer $TOKENFLOW_API_KEY" \
  -F model=sensevoice-small \
  -F file=@sample.wav \
  -F response_format=verbose_json

Response formats: json, verbose_json or text. Successful requests use at least 10 billed seconds. Reference price: $0.054 per billed audio hour; customer agreements govern payment.

To try it without code, open the transcription playground in the console: record from your microphone or choose a file; it uses your organization’s quota.

Text to speech

tokenflow-tts-1 accepts up to 4,000 characters per request and returns an MP3 file by default. Long text is split into sentences and spoken in one consistent voice; the file starts arriving within seconds and finishes as it is made, so for more than a minute of audio we suggest stream: true. speed takes 0.75 to 1.5 (default 1) for every voice and format; the pitch stays the same, and a clip is billed by its length before the speed change. Choose a preset voice or use instructions to describe a voice; do not supply both. Cloning from your own recordings is not available.

curl --fail-with-body https://api.tokenflow.dev/v1/audio/speech \
  -H "Authorization: Bearer $TOKENFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"tokenflow-tts-1","input":"你好,欢迎使用语音服务。","voice":"zh-female-calm"}' \
  --output speech.mp3

Besides the presets, zh-sunwukong is a Sun Wukong voice made from a licensed recording, and ten English female voices are designed from text descriptions (no human recording):

These shared voices are served by one node, so they can answer 503 voice_unavailable while that node is busy or under maintenance; retry, or fall back to a preset. The first request after a few idle hours may take a few seconds longer.

Set response_format to mp3 (default), opus, aac, flac, wav or pcm, as in OpenAI's speech API; the OpenAI SDKs work with the TokenFlow base URL and key. pcm is raw 24 kHz 16-bit little-endian mono audio.

To hear the voices without writing code, open the speech playground in the console; it uses your organization’s quota.

Streaming uses stream: true with response_format: "pcm" (default) or "opus". Streamed PCM is the same 24 kHz 16-bit audio; the x-sample-rate and x-sample-format response headers say so. Reference price: $1.00 per hour of audio sent to you, billed by the 0.1 s with at least 1 second per request, and held between two-thirds and twice what the text should take to say. A stream you stop is billed for the audio already sent; failed requests and empty audio are free; voice instructions cost nothing.

Quotas and retries

Long-form speaker-separated transcription and the slow batch TTS model are not offered externally in this release.

Disclosure and data

Tell listeners the voice is AI-generated and preserve the origin metadata: every audio response carries it in the x-aigc-label header, and MP3, AAC, Opus, FLAC and WAV files carry it inside the file. Raw PCM has no file metadata: keep the header’s label and add it when saving or distributing the audio. See the speech terms and speech data policy for use restrictions, voice-description retention and logging.