Fish TTS API Integration Guide

This API provides text-to-speech, saved voice usage, and one-time instant voice cloning at POST https://api.acedata.cloud/fish/tts.

Application Process

To use the Fish TTS API, first obtain your API Token from the Ace Data Cloud Console and keep it for later use.

If you have not yet logged in or registered, you will be automatically redirected to the login page to register and log in. Once completed, you will automatically return to the current page.

A general application's API Key can be used for services enabled for the account; a dedicated application's Key can be used within that application's service scope. Please check the Key's permissions, validity period, and limits, and confirm that the application balance is sufficient to pay for this request. Available trial credits are subject to what is displayed in the account; if the balance is insufficient, click the “Recharge” button.

📘 Full documentation: Fish TTS API →

Request Headers

Header Required Description
authorization Yes Bearer {token}, where {token} is the key obtained on this platform.
content-type Yes application/json.
accept No application/json.
model No TTS model: s1, s2-pro, or s2.1-pro; defaults to s2-pro. s2.1-pro is the latest generation, and s2-pro is highly expressive; s1 is more stable and less likely to go off track with long text. All three are priced the same.

Request Body Fields

Field Type Required Description
text string Yes Text to synthesize, a non-empty string.
format string No Output audio format: mp3 (default), wav, or pcm. Both wav and pcm return a WAV container. opus is not supported and will directly return 400 if provided.
reference_id string | string[] No Model ID of a saved or public voice, which can be created through the Fish Model API or retrieved through Fish Model Query. Cannot be used together with references.
references object[] No One-time instant voice cloning; only one {audio, text} sample is supported: audio is a public HTTPS MP3/WAV URL, and text is an accurate verbatim transcript of the audio. Cannot be used together with reference_id.
sample_rate integer No Sample rate, commonly 16000, 22050, or 44100. Defaults to 44100 for format=mp3.
mp3_bitrate integer No MP3 bitrate: 64, 128, or 192. Takes effect only with format=mp3.
prosody object No Prosody override, supporting speed (speaking rate, with 1.0 being the original speed) and volume (volume gain in dB). For example, {"speed":1.2,"volume":0}.
chunk_length integer No Audio chunk length; the default value is used when omitted.
temperature number No Sampling temperature, approximately 0.0–1.0.
top_p number No Top-p sampling parameter.
latency string No normal or balanced, defaults to normal; an empty string is not accepted.
normalize boolean No Whether to normalize the text.
callback_url string No Asynchronous callback URL; see “Asynchronous Callback” below for details. This is an extension to the official API.

One-time cloning accepts only HTTPS audio URLs and does not accept MessagePack, Base64, data URIs, or URLs with credentials. A reference audio length of 10–270 seconds is recommended; Studio uses a more conservative range of 10–60 seconds.

Example 1: Minimal Request (text + format=mp3)

curl -X POST 'https://api.acedata.cloud/fish/tts' \
  -H 'authorization: Bearer {token}' \
  -H 'content-type: application/json' \
  -d '{
    "text": "Hello world.",
    "format": "mp3"
  }'

Response (tested):

{
  "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/e2ffcc06-18da-4a8c-b9aa-9337d0f9ec1d-230825dfc559.mp3"
}

audio_url points to this platform's CDN and can be downloaded directly with GET or played in <audio>. The final successful response also returns a top-level cost, where amount is the Credits actually deducted for this request; if there is an account discount, list_amount indicates the amount before the discount. The link remains available long-term, but it is still recommended that you keep a copy in your own storage.

Example 2: Using a Cloned Voice reference_id

The following uses a public Spanish voice on the Fish platform (the _id can be retrieved through Fish Model Query):

curl -X POST 'https://api.acedata.cloud/fish/tts' \
  -H 'authorization: Bearer {token}' \
  -H 'content-type: application/json' \
  -d '{
    "text": "Hermanos míos, hoy es un buen día.",
    "reference_id": "8d2c17a9b26d4d83888ea67a1ee565b2",
    "format": "mp3"
  }'

Response (tested):

{
  "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/b6f161f2-a100-4818-add2-47694f234659-6532864739de.mp3"
}

Example 3: One-Time Instant Voice Cloning (references)

Place the reference audio at a public HTTPS address and provide the exact original text actually spoken in it. The voice is used only for this synthesis and will not create a long-term model:

curl -X POST 'https://api.acedata.cloud/fish/tts' \
  -H 'authorization: Bearer {token}' \
  -H 'content-type: application/json' \
  -H 'model: s2-pro' \
  -d '{
    "text": "新的旅程从这一刻开始,让我们一起向前。",
    "format": "mp3",
    "references": [{
      "audio": "https://cdn.acedata.cloud/assets/examples/fish/6220d605-39d0-4d43-9e58-0f12949dc9b9-570cfdf96ad9.mp3",
      "text": "春天的清晨,阳光穿过树叶,落在安静的小路上。"
    }]
  }'

Successful response (tested):

{
  "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/995dfe37-b187-474d-8323-b08d6678ed8f-6359be9f8873.mp3",
  "cost": {"amount": 0.007609319999999999, "currency": "credit"}
}
Method Lifecycle Use case
references Current TTS request only Temporary use or a different voice for each request
reference_id Reusable Public voices or long-term voices created via /fish/model

Example 3: Adjusting speech speed / volume (prosody)

curl -X POST 'https://api.acedata.cloud/fish/tts' \
  -H 'authorization: Bearer {token}' \
  -H 'content-type: application/json' \
  -d '{
    "text": "Faster speech with prosody overrides.",
    "prosody": { "speed": 1.2, "volume": 0 },
    "format": "mp3"
  }'

Response (tested):

{
  "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/5ade0339-5f11-487e-aacc-06a908271706-8e3fcb0e5547.mp3"
}

A speed greater than 1 speeds up speech, and less than 1 slows it down; volume is measured in dB, where 0 means no change, positive values increase gain, and negative values attenuate it.

Example 5: Switching models + controlling bitrate

Switch to the stable model using the HTTP header model: s1, and add mp3_bitrate: 128 to the request body to control the MP3 bitrate:

curl -X POST 'https://api.acedata.cloud/fish/tts' \
  -H 'authorization: Bearer {token}' \
  -H 'content-type: application/json' \
  -H 'model: s1' \
  -d '{
    "text": "high bitrate mp3",
    "format": "mp3",
    "mp3_bitrate": 128
  }'

Response (tested):

{
  "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/7e7abf3d-3d72-4c9f-8eb6-8af932d7c96e-6f11bf2f30e9.mp3"
}

Example 6: Raw PCM waveform

For scenarios that require real-time concatenation in the browser or subsequent processing on the client (mixing, speed adjustment), pcm is recommended:

curl -X POST 'https://api.acedata.cloud/fish/tts' \
  -H 'authorization: Bearer {token}' \
  -H 'content-type: application/json' \
  -d '{
    "text": "hi",
    "format": "pcm",
    "sample_rate": 16000
  }'

Response (tested):

{
  "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/64adc04b-c196-4a0f-9070-222ba101ce6c-fc50de38c165.wav"
}

The link's extension follows the format in the request: mp3 produces .mp3, while wav and pcm produce .wav (WAV container, 16-bit PCM).

Asynchronous callbacks (callback_url)

Synthesizing long text in one request may take anywhere from ten to several dozen seconds, and a retry is needed if the connection is interrupted. After callback_url is passed in the request body, the API immediately returns {task_id, started_at} and, when synthesis is complete, sends the full result to that URL as a POST JSON callback, with the same task_id and the top-level cost for the final charge in the request body. Synthesis has not yet been completed at the initial task confirmation, so it does not include cost.

curl -X POST 'https://api.acedata.cloud/fish/tts' \
  -H 'authorization: Bearer {token}' \
  -H 'content-type: application/json' \
  -d '{
    "text": "今天天气真好,我们一起出去散散步吧。",
    "format": "mp3",
    "callback_url": "https://webhook.site/4815f79f-a40f-4078-ac85-1cc126b6bb34"
  }'

Immediate response (tested):

{
  "task_id": "79d82713-2897-4eeb-9934-e7544d471aa7",
  "started_at": 1778462584.742
}

Later, callback_url will receive something like:

{
  "task_id": "79d82713-2897-4eeb-9934-e7544d471aa7",
  "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/bd66b8c5-7543-4557-b684-baa72407e336-52f2e79732f2.mp3"
}

You can also use the Fish Tasks API to actively retrieve the result by task_id; response.cost in the terminal-state record is consistent with cost in the callback. See that documentation for details.

Error handling

  • 400 token_mismatched: Request parameters are missing or invalid (most commonly, text is empty, or format is set to a value other than mp3/wav/pcm).
  • 401 invalid_token: The authentication token does not exist or is invalid.
  • 429 too_many_requests: The account rate limit has been triggered.
  • 500 api_error: Internal server error.

Example error response:

{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}

Parameter validation errors indicate the invalid field in the message field, for example:

{
  "status": 400,
  "message": "[{\"type\":\"literal_error\",\"loc\":[\"format\"],\"msg\":\"Input should be 'pcm' or 'mp3'\",\"input\":\"wav\"}]"
}

Conclusion

The minimum effort required to integrate Fish TTS is to replace the authentication in existing code that calls api.fish.audio/v1/tts with this platform's token, and explicitly include format: "mp3" in the request body. Asynchronous callbacks using callback_url are recommended for long-text scenarios; to discover cloned voice reference_id values, use Fish Model Query and Fish Model Get.