Audio Speech API
Turns text into speech. Compatible with OpenAI’s POST /v1/audio/speech; the response body is the audio file itself (binary), not JSON.
Accepted values for voice, response_format and other parameters vary by model; the family pages are authoritative.
Quickstart
https://api.ofox.io/v1https://api.ofox.io/v1/audio/speechgoogle/gemini-3.8-flash-ttsPython
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"])
with client.audio.speech.with_streaming_response.create(
model="google/gemini-3.8-flash-tts",
voice="Kore",
input="Hello, and welcome to OfoxAI text to speech.",
response_format="wav",
) as resp:
resp.stream_to_file("speech.wav")Request parameters
Model ID; see the table above.
The text to synthesize. An empty value returns 400.
The voice. Required for Gemini TTS, where it takes a Google voice name (e.g. Kore); for ElevenLabs it takes a voice ID (e.g. 21m00Tcm4TlvDq8ikWAM). OpenAI voice names (e.g. alloy) do not work with either family.
Audio format. Accepted values vary by model: Gemini TTS supports wav and pcm; ElevenLabs supports mp3, opus, wav and pcm. An unsupported format returns 400.
Tone and style instructions, such as “read this in a cheerful tone”. Applies to Gemini TTS.
Language code, such as cmn-CN (Gemini TTS) or zh (ElevenLabs). If omitted, the model infers the language from the text.
With sse, audio chunks are streamed as Server-Sent Events. Applies to Gemini TTS.
Provider-specific parameters, passed through to the provider, e.g. ElevenLabs’ {"elevenlabs": {"voice_settings": {...}}}. See each family page.
Response
On success, HTTP 200 with the audio file as the response body; Content-Type matches the format:
Write the response body straight to a file. Errors are returned as JSON with Content-Type application/json, so check the status code first to avoid saving an error message as an audio file.
Common errors
For the full list of error codes, see Error handling.