EN ▾
Get API key

OpenAI TTS API: What an Alternative Text API Covers

If you searched for the openai tts api, you want speech from text. This site does not return audio: it is an OpenAI-compatible text LLM API that writes the scripts your own TTS engine then reads aloud.

Updated

A terminal feeding blocks of text into a microphone, showing a text API upstream of speech synthesis

Key points

  • This API is text only: no audio, image or video output, no embeddings.
  • It uses the same chat completions format as the OpenAI SDKs, so a base URL and key change is enough.
  • Use it upstream of any TTS engine, F5 TTS included, to write scripts, dialogue and pronunciation hints.
  • Pay as you go at $0.15 per 1M input and $0.50 per 1M output tokens.

The short answer

OpenAI's speech feature is a separate endpoint that takes text and returns an audio file. Our API does not have that endpoint. It exposes POST /v1/chat/completions and GET /v1/models, and the only model ID is uncensored. It generates text, nothing else.

That still matters for voice work, because most TTS pipelines start with a text problem. Someone has to write the narration, split it into sentences a voice can handle, fix numbers and abbreviations, and keep a dialogue consistent between speakers. A language model does that well, and you can run it on a different provider than the one that does the speaking.

If you need the audio file itself, pair this API with a speech engine of your choice. Our text layer for voice generation page shows how the two halves fit together.

Where text generation fits in a TTS pipeline

A typical voice pipeline has four steps. The language model sits in the first two.

  1. Draft. The model writes the script: a narration, an ad read, a character monologue, a dialogue between two speakers.
  2. Normalize. The model rewrites the draft so a speech engine reads it cleanly: numbers spelled out, abbreviations expanded, long sentences split.
  3. Synthesize. Your TTS engine turns each line into audio. This step is not part of our API.
  4. Assemble. You join clips, add pauses, export.

The normalize step is where many projects lose time. Engines trip on things like "Dr.", "3/4" or a long chain of subordinate clauses. Asking the model to rewrite for the ear, with a clear system prompt, removes most of that without hand editing.

Call the API with the OpenAI SDK

Any OpenAI client works once you change two values: the base URL and the key. Everything else, including message format and parameters, stays as you know it.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.f5tts.cc/v1",
    api_key="YOUR_KEY",
)

resp = client.chat.completions.create(
    model="uncensored",
    messages=[
        {"role": "system", "content": "You write short narration scripts meant to be read aloud. Plain sentences, no stage directions, no markdown."},
        {"role": "user", "content": "Write a 90-second intro for a podcast about night trains."},
    ],
    temperature=0.8,
)
print(resp.choices[0].message.content)

The base URL is https://api.f5tts.cc/v1 and the model is uncensored. Authentication is a standard Authorization: Bearer header, which the SDK adds for you. You can check the connection with a plain curl call:

curl https://api.f5tts.cc/v1/chat/completions \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Say hello in one sentence."}]
  }'

A GET /v1/models request returns the model list if you want to confirm the key works before building anything.

Prompts that produce speakable text

Chat models write for the eye by default: markdown, bullet points, parentheses. A speech engine reads those symbols aloud or stumbles on them. Put the rules in the system message.

A system prompt that works as a starting point

  • Write only plain sentences. No markdown, no lists, no emoji.
  • Spell out numbers, dates and symbols the way a person would say them.
  • Keep sentences under 25 words.
  • Do not add stage directions or speaker names unless asked.

Structured output for multi-speaker scripts

When you voice a dialogue, you want each line tagged with a speaker so you can send it to the right voice. JSON mode helps here, because you get a parseable list instead of text you must split yourself.

resp = client.chat.completions.create(
    model="uncensored",  # base_url: https://api.f5tts.cc/v1
    response_format={"type": "json_object"},
    messages=[
        {"role": "system", "content": "Return JSON with a key 'lines': a list of objects with 'speaker' and 'text'."},
        {"role": "user", "content": "Two-person dialogue, six lines, about missing a train."},
    ],
)

Parse resp.choices[0].message.content with json.loads and loop over the lines. Validate the keys anyway; JSON mode guarantees valid JSON, not your schema.

Streaming, tools and long scripts

Streaming works over SSE with stream: true, and the final chunk carries usage. For a live preview of a script as it is written, or to start synthesizing the first sentences while the rest is still coming, streaming cuts the wait.

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.f5tts.cc/v1",
  apiKey: process.env.F5_KEY,
});

const stream = await client.chat.completions.create({
  model: "uncensored",
  stream: true,
  messages: [{ role: "user", content: "Write three short lines of narration about a harbour at dawn." }],
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Tool calling is supported too, with tools, tool_choice and results sent back as role: "tool". A practical use is a tool that looks up a pronunciation dictionary for brand names before the model finalizes a line.

The context window is 100,000 tokens, prompt plus completion, so a long chapter plus your style guide fits in one request. Requests over 8 MB are rejected, which you will only hit if you paste huge files.

Limits and cost for voice workloads

A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 and 60. If you script a whole audiobook in parallel, cap your worker pool at 8. Over a limit you get HTTP 429 with the code rate_limited or concurrency; a streamed request holds its slot until the stream ends.

Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, from prepaid credit, with no subscription. Failed or refused requests are not charged. A 1,000-token script costs 1,000 x $0.50 / 1,000,000 = $0.0005 in output, plus the input you sent. The pricing page has the top-up amounts and bonuses.

New users can claim $0.50 of trial credit with one click on the key page after signing up, valid for 7 days, no card needed. Prompts are not used for training.

When this is not what you need

Be clear about the fit before you integrate. If your product needs a ready audio file from a single API call, a speech endpoint from a dedicated provider is the direct route, and you should check their current pricing and terms. If you already run a speech engine yourself, or plan to, the script-writing half is where this API helps.

The model is one open-weight model run by an independent provider, tuned to answer without content refusals for lawful adult use. It is not the official API of any vendor. One hard limit applies: no sexual content involving minors. To start, read the quickstart and create a key from the API key page.

Questions and answers

Does this API return audio?

No. It is a text-only chat completions API. You get text back, and you pass it to your own speech engine.

Can I use the OpenAI Python or Node SDK?

Yes. Set the base URL to https://api.f5tts.cc/v1, use your key, and set the model to uncensored. Chat completions, streaming, tools and JSON mode work as in the OpenAI SDKs.

Is there a free way to test it?

New users can claim $0.50 of trial credit on the API key page after sign-up. It lasts 7 days and needs no card.

Is this the official API of F5 TTS or OpenAI?

No. It is an independent hosted text API using an open-weight model, with no affiliation to either.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.