About
Fish Audio S2.1 Pro is Fish Audio's recommended production text-to-speech model, covering 83 languages with automatic language detection. Free-form bracket directions such as [whispers sweetly] or [laughing nervously] control delivery, and <|speaker:N|> markers produce multi-speaker dialogue. 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.
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/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/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/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/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
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
model | string | Yes | -- | fish-audio/s2.1-pro/text-to-audio | Model ID. |
input | string | Yes | -- | -- | 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. |
voice | string | No | -- | -- | 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_format | string | No | mp3 | mp3, wav, pcm, opus | Audio format. |
speed | number | No | 1 | 0.5 to 2.0 | Speaking rate. Sent as prosody.speed and merged with any prosody you send. |
sample_rate | integer | No | 44100 (pcm: 24000; opus: 48000) | wav and pcm: 8000, 16000, 24000, 32000, 44100; mp3: 32000, 44100; opus: 48000 | Output sample rate. |
language | string | No | Detected per chunk | BCP-47, e.g. en, es-MX, zh-CN | Used for text normalization only; it is not passed to the speech model. |
text_normalization | boolean | No | true | true, false | Rewrite numbers, dates, units and symbols as words. Sent as normalize. |
stream_format | string | No | audio | audio, sse | sse 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.
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
reference_id | string or array | No | -- | -- | Voice model ID, or one ID per speaker for multi-speaker text. Use instead of voice, not with it. |
temperature | number | No | 0.7 | 0 to 1 | Higher is more varied, lower is more consistent. |
top_p | number | No | 0.7 | 0 to 1 | Nucleus sampling diversity. |
prosody | object | No | -- | -- | speed (0.5 to 2.0), volume (dB, default 0) and normalize_loudness (default true). |
latency | string | No | normal | normal, balanced, low | normal gives the best quality; balanced and low reduce latency. |
chunk_length | integer | No | 300 | 100 to 300 | Text segment size for processing. |
min_chunk_length | integer | No | 50 | 0 to 100 | Minimum characters before a new chunk is split. |
condition_on_previous_chunks | boolean | No | true | true, false | Use the previous audio as context for voice consistency. |
mp3_bitrate | integer | No | 128 | 64, 128, 192 | MP3 bitrate in kbps. |
opus_bitrate | integer | No | -1000 (auto) | -1000, 24000, 32000, 48000, 64000 | Opus bitrate in bps. |
max_new_tokens | integer | No | 1024 | -- | Maximum audio tokens per text chunk. |
repetition_penalty | number | No | 1.2 | -- | Values above 1.0 reduce repeated audio patterns; no effect on S2.1 Pro. |
early_stop_threshold | number | No | 1 | 0 to 1 | Early-stop threshold for batch processing. |
features | array | No | [] | e.g. ["quality-guard"] | Request-scoped Fish Audio feature flags. |
pronunciation_dictionary | array | No | -- | Up to 3 dictionaries | Inline 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
| Field | Behavior |
|---|---|
instructions | Rejected with 400. Put bracket directions in the input instead. |
bit_rate | Ignored. Use mp3_bitrate or opus_bitrate. |
references | Not supported (inline zero-shot cloning needs MessagePack). Use a saved voice model ID. |
| Other fields | Not forwarded to Fish Audio. |
Output
| Parameter | Type | Range | Description |
|---|---|---|---|
| Response body | binary | mp3, wav, pcm, opus | The audio file in response_format (without stream_format=sse). |
Content-Type header | string | audio/mpeg, audio/wav, audio/pcm, audio/opus | MIME type of the audio. |
type | string | speech.audio.delta, speech.audio.done, error | Streaming event type. |
audio | string | Base64 | Next chunk of the audio (speech.audio.delta). |
usage.input_tokens | integer | Non-negative | Billable count of the input (speech.audio.done). |
usage.output_tokens | integer | 0 | Always 0 for this model. |
usage.total_tokens | integer | Non-negative | Sum of input and output. |
error | object | -- | message, type and code of a failure (error event). |
3. Detailed Pricing
| Model | Endpoint | Billing unit | Price |
|---|---|---|---|
| Fish Audio: S2.1 Pro | fish-audio | Per 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).
Sources: Text to speech API, Models, Drama 3, Migrate from S1, Pricing.