Fish Audio: S2.1 Pro Free (Text to Audio) API Reference

About

Fish Audio S2.1 Pro Free is the same model as S2.1 Pro (83 languages, bracket directions, multi-speaker dialogue), offered by Fish Audio for development and testing under fair-use limits and without latency guarantees. Infron serves it through the OpenAI-compatible POST /v1/audio/speech endpoint with any Fish Audio voice model ID, mp3, wav, pcm or opus output and optional streaming, billed per UTF-8 byte of input text. Infron bills it at the S2.1 Pro list price.

1. Calling the API

Setup your API Key

To begin using Infron, create an account and generate your API Key.

export INFRON_KEY="YOUR_API_KEY"

Submit a request

Send JSON to POST https://llm.onerouter.pro/v1/audio/speech with your Infron API key. The request and response follow the OpenAI speech API, so the OpenAI SDKs work with the base URL https://llm.onerouter.pro/v1. The examples use the Fish Audio voice 933563129e564b19a115bedd57b7406a. Replace YOUR_API_KEY with your key.

curl

curl https://llm.onerouter.pro/v1/audio/speech \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "fish-audio/s2.1-pro-free/text-to-audio",
    "voice": "933563129e564b19a115bedd57b7406a",
    "input": "Hello! Welcome to Infron.",
    "response_format": "mp3"
  }' \
  --output speech.mp3

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    base_url="https://llm.onerouter.pro/v1",
    api_key="YOUR_API_KEY",
)

with client.audio.speech.with_streaming_response.create(
    model="fish-audio/s2.1-pro-free/text-to-audio",
    voice="933563129e564b19a115bedd57b7406a",
    input="Hello! Welcome to Infron.",
    response_format="mp3",
) as response:
    response.stream_to_file("speech.mp3")

TypeScript (OpenAI SDK)

import fs from "node:fs";
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://llm.onerouter.pro/v1",
  apiKey: "YOUR_API_KEY",
});

const response = await client.audio.speech.create({
  model: "fish-audio/s2.1-pro-free/text-to-audio",
  voice: "933563129e564b19a115bedd57b7406a",
  input: "Hello! Welcome to Infron.",
  response_format: "mp3",
});
fs.writeFileSync("speech.mp3", Buffer.from(await response.arrayBuffer()));

Response

A successful request returns HTTP 200 with the audio file as the body, not JSON. Content-Type follows response_format: audio/mpeg for mp3, audio/wav for wav, audio/pcm for pcm, audio/opus for opus. The examples above save it as speech.mp3.

Streaming

Add "stream_format": "sse" to receive Server-Sent Events while the audio is generated. Each speech.audio.delta event carries the next base64 chunk of the audio in response_format; decode the chunks and append them in order. The stream ends with a speech.audio.done event that reports usage.

curl https://llm.onerouter.pro/v1/audio/speech \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "fish-audio/s2.1-pro-free/text-to-audio",
    "voice": "933563129e564b19a115bedd57b7406a",
    "input": "Hello! Welcome to Infron.",
    "response_format": "mp3",
    "stream_format": "sse"
  }' \
  --no-buffer
data: {"type":"speech.audio.delta","audio":"<base64 audio chunk>"}

data: {"type":"speech.audio.delta","audio":"<base64 audio chunk>"}

data: {"type":"speech.audio.done","usage":{"input_tokens":25,"output_tokens":0,"total_tokens":25}}

In this example input_tokens is the billable character count of the input.

Routing and usage

This model is served by fish-audio (Fish Audio). Billing uses the UTF-8 byte length of input, the same count Fish Audio bills (an ASCII character is 1 byte, a Chinese character 3 bytes). The audio response carries no usage; with streaming, speech.audio.done reports the billable count as usage.input_tokens.

Errors

Parameters this model does not accept are rejected with HTTP 400 before the request is sent to Fish Audio, and nothing is charged. error.message explains the problem and ends with the request ID:

{
  "error": {
    "message": "send either voice or reference_id, not both (request id: 20261111221810441285700pZnPkvCJ)",
    "type": "infron_ai_error",
    "param": "",
    "code": "invalid_request_error"
  }
}

Errors reported by Fish Audio, such as an unknown voice ID, are returned with Fish Audio's message. If a stream fails after it has started, an error event is sent instead of speech.audio.done.

2. Schema

Input

ParameterTypeRequiredDefaultRangeDescription
modelstringYes--fish-audio/s2.1-pro-free/text-to-audioModel ID.
inputstringYes----Text to synthesize. Free-form bracket directions such as [whisper], [laugh] or [excited] can go anywhere in the text; for dialogue see Text markup below.
voicestringNo----Fish Audio voice model ID (sent as reference_id), for example 933563129e564b19a115bedd57b7406a. Omit it to use Fish Audio's default voice. Do not send it together with reference_id.
response_formatstringNomp3mp3, wav, pcm, opusAudio format.
speednumberNo10.5 to 2.0Speaking rate. Sent as prosody.speed and merged with any prosody you send.
sample_rateintegerNo44100 (pcm: 24000; opus: 48000)wav and pcm: 8000, 16000, 24000, 32000, 44100; mp3: 32000, 44100; opus: 48000Output sample rate.
languagestringNoDetected per chunkBCP-47, e.g. en, es-MX, zh-CNUsed for text normalization only; it is not passed to the speech model.
text_normalizationbooleanNotruetrue, falseRewrite numbers, dates, units and symbols as words. Sent as normalize.
stream_formatstringNoaudioaudio, ssesse streams Server-Sent Events (see Streaming).

Text markup

For dialogue, mark each turn with <|speaker:0|>, <|speaker:1|> and so on, and send reference_id as an array with one voice model ID per speaker, in the same order, for example "input": "<|speaker:0|>Hello!<|speaker:1|>Hi there!" with "reference_id": ["<voice A>", "<voice B>"] (and no voice).

Fish Audio fields

These fields are not part of the OpenAI speech API. Put them at the top level of the JSON body; with the OpenAI Python SDK pass them in extra_body.

ParameterTypeRequiredDefaultRangeDescription
reference_idstring or arrayNo----Voice model ID, or one ID per speaker for multi-speaker text. Use instead of voice, not with it.
temperaturenumberNo0.70 to 1Higher is more varied, lower is more consistent.
top_pnumberNo0.70 to 1Nucleus sampling diversity.
prosodyobjectNo----speed (0.5 to 2.0), volume (dB, default 0) and normalize_loudness (default true).
latencystringNonormalnormal, balanced, lownormal gives the best quality; balanced and low reduce latency.
chunk_lengthintegerNo300100 to 300Text segment size for processing.
min_chunk_lengthintegerNo500 to 100Minimum characters before a new chunk is split.
condition_on_previous_chunksbooleanNotruetrue, falseUse the previous audio as context for voice consistency.
mp3_bitrateintegerNo12864, 128, 192MP3 bitrate in kbps.
opus_bitrateintegerNo-1000 (auto)-1000, 24000, 32000, 48000, 64000Opus bitrate in bps.
max_new_tokensintegerNo1024--Maximum audio tokens per text chunk.
repetition_penaltynumberNo1.2--Values above 1.0 reduce repeated audio patterns; no effect on S2.1 Pro.
early_stop_thresholdnumberNo10 to 1Early-stop threshold for batch processing.
featuresarrayNo[]e.g. ["quality-guard"]Request-scoped Fish Audio feature flags.
pronunciation_dictionaryarrayNo--Up to 3 dictionariesInline dictionaries only: each {"items": [...]} entry has key, value, type: "phoneme" and optional case_sensitive. Saved dictionary references (id, version) and alias entries are rejected with 400.

Unsupported fields

FieldBehavior
instructionsRejected with 400. Put bracket directions in the input instead.
bit_rateIgnored. Use mp3_bitrate or opus_bitrate.
referencesNot supported (inline zero-shot cloning needs MessagePack). Use a saved voice model ID.
Other fieldsNot forwarded to Fish Audio.

Output

ParameterTypeRangeDescription
Response bodybinarymp3, wav, pcm, opusThe audio file in response_format (without stream_format=sse).
Content-Type headerstringaudio/mpeg, audio/wav, audio/pcm, audio/opusMIME type of the audio.
typestringspeech.audio.delta, speech.audio.done, errorStreaming event type.
audiostringBase64Next chunk of the audio (speech.audio.delta).
usage.input_tokensintegerNon-negativeBillable count of the input (speech.audio.done).
usage.output_tokensinteger0Always 0 for this model.
usage.total_tokensintegerNon-negativeSum of input and output.
errorobject--message, type and code of a failure (error event).

3. Detailed Pricing

ModelEndpointBilling unitPrice
Fish Audio: S2.1 Pro Freefish-audioPer 1M UTF-8 bytes of input$15.00

Prices are in USD. Billing uses the UTF-8 byte length of input, the same count Fish Audio bills (an ASCII character is 1 byte, a Chinese character 3 bytes). Fish Audio offers S2.1 Pro Free at no charge under fair-use limits; Infron bills it at the S2.1 Pro list price.

Sources: Text to speech API, Models, Drama 3, Migrate from S1, Pricing.