Skip to main content
The Text to Speech API turns text into audio with OmniVoice, k2-fsa’s open text-to-speech model, served by Hopper. OmniVoice generates English speech at 24 kHz; the default voice is sarah. Three endpoints share the same generation options: POST /tts/bytes returns raw audio bytes, POST /tts/sse streams base64 chunks over server-sent events, and POST /v1/audio/speech accepts the OpenAI request shape. All three bill at $30 per million characters of submitted transcript.

POST /tts/bytes

The native request shape. Send a JSON body; the response is raw audio. Generate speech and write it to a file:
The response Content-Type matches the container: audio/wav, audio/mpeg, or application/octet-stream. Every response carries x-hopper-request-cost-usd and x-hopper-credits-remaining-usd. TTS cost is known before generation, so both headers are exact.

Streaming restrictions

Streaming supports wav and raw only. container: "mp3" over a stream returns 400 invalid_output_format; generation_config.speed other than 1 over a stream returns 400 invalid_generation_config. This applies to /tts/bytes with stream: true, to /tts/sse always, and to /v1/audio/speech with stream: true.

POST /tts/sse

Same request body as /tts/bytes. The response always streams, regardless of the stream field: Content-Type: text/event-stream with two event shapes.
chunk repeats until the audio is complete; done is the final event. Decode each chunk and feed it to playback as it arrives:

POST /v1/audio/speech

The OpenAI-compatible endpoint. Point an existing OpenAI TTS integration at https://api.withhopper.com and it works unchanged: model maps to model_id, input to transcript, and voice (a string) to {"mode": "id", "id": voice}. speed and stream pass through. response_format selects a fixed output format: opus, aac, and flac return 400. Response bytes and spend headers are identical to /tts/bytes.

Errors

TTS endpoints are POST-only (405 method_not_allowed otherwise) and require a JSON object body (400 invalid_json). Auth, rate-limit, and credit errors match the rest of the API — see Errors.

Billing

Cost is charged per character of the submitted transcript, before any pronunciation-dictionary expansion. A 1,000-character transcript costs $0.03 at $30 per million characters. The exact charge is returned on every response in x-hopper-request-cost-usd.