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:
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
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 athttps://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 (405method_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 inx-hopper-request-cost-usd.