DocsAPI Reference
Endpoints

Speech

Turn text into spoken audio with the OpenAI speech API, read by a Realtime model and billed per sentence.


POST /v1/audio/speech accepts OpenAI's speech request and returns the text read aloud. Clients written for OpenAI's speech endpoint work by pointing their base URL at Tokamak.

The text is read by an OpenAI Realtime model (by default openai/gpt-realtime-2.1-mini), not by OpenAI's TTS models, which OpenAI shuts down on 2027-01-06. A Realtime model writes a reply rather than reading text out, so Tokamak sends your text one sentence at a time with instructions to read it word for word. It then checks each sentence's transcript against your text and reads the sentence again if they differ.

Read text aloud

curl -sS https://api.tokamak.sh/v1/audio/speech \
  -H "Authorization: Bearer $TOKAMAK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "tts-1", "input": "Your order has shipped and will arrive on Friday.", "voice": "coral"}' \
  -o speech.wav

With the OpenAI SDK, only the base URL and the key change:

from openai import OpenAI

client = OpenAI(base_url="https://api.tokamak.sh/v1", api_key=TOKAMAK_API_KEY)
with client.audio.speech.with_streaming_response.create(
    model="tts-1", voice="coral", input="Your order has shipped.", response_format="wav",
) as response:
    response.stream_to_file("speech.wav")

Request

FieldServed
modelA Realtime model, such as openai/gpt-realtime-2.1-mini or openai/gpt-realtime-2.1 (voice models are not in the default Models list). OpenAI's TTS names (tts-1, tts-1-hd, gpt-4o-mini-tts), or no model, use your deployment's default.
inputUp to 4,096 characters.
voicealloy, ash, ballad, coral, echo, sage, shimmer, verse, marin (default) or cedar.
instructionsTone and pace only, such as "warm and slow". They never change what is said.
response_formatwav (default) or pcm (24 kHz, 16-bit, mono). mp3, opus, aac and flac are refused with 400 unsupported_value.
speed0.25 to 1.5 (OpenAI's speech endpoint allows up to 4.0; Realtime voices stop at 1.5).
stream_formataudio: the audio is sent sentence by sentence as it is ready. sse: OpenAI's speech.audio.delta events, ending with speech.audio.done and the usage.

How it is read

  • Numbers, emails and codes are said the way a person would say them: "48213" as "four eight two one three", "[email protected]" as "nngo at menlo dot ai".
  • Text that reads like a question or an instruction is read aloud, not answered. If the model answers it anyway, the check catches the answer, and Tokamak reads that sentence again (twice by default, then on a fallback model if your deployment sets one).
  • If a sentence still is not read back correctly, the request fails with 502 speech_unverified rather than returning wrong audio. When streaming, the stream ends early instead; with sse it ends with an error event.

Billing

  • Each sentence is billed as one Realtime turn, at the model's audio and text token rates. A sentence that had to be read again is billed for each attempt. In usage analytics, the retried attempts have finish reason retried_unverified.
  • At list prices that comes to about $0.027 per minute of speech on gpt-realtime-2.1-mini and about $0.10 per minute on gpt-realtime-2.1. Speed does not change the cost.
  • Before anything is read, Tokamak holds credit for the whole request. An organization that cannot afford it gets 402 before any audio is produced, not part-way through.
  • The settled execution ids, one per attempt, are returned in the X-Tokamak-Execution-Id header, comma-separated, also on a 502. A streamed response sends its headers with the first sentence, so there the header names that sentence's attempts; with sse, the final speech.audio.done (or error) event lists all of them in execution_ids.

Limits

  • Requests count toward your organization's limit on concurrent Realtime sessions.
  • Organizations with a guardrail policy have the text screened like any prompt: a block refuses the request, and masking or cloaking changes what is read.
  • /v1/audio/translations is not served. For live, two-way voice, use Realtime.

On this page