Fish Audio Docs
API 參考文字轉語音文字轉語音(同步)
返回主站

文字轉語音(同步)v2

既有客戶端使用的 HTTP v2 相容合約。

V2 僅供既有客戶端維護,新接入使用 v3。

Endpoint

POST /api/open/v2/speech/tts

完整網址:

https://fishaudio.org/api/open/v2/speech/tts

驗證與請求標頭

Authorization: Bearer FISHAUDIO_API_KEY
Content-Type: application/json
X-Request-Id: YOUR_STABLE_REQUEST_ID

請求欄位

fieldtyperequiredconstraints
textstringyes1–10,000
voiceIdstringyesmust support modelId
modelIdstringnopublic model ID
formatstringnomp3, wav, ogg; default mp3
speednumberno0.5–2; default 1
volumenumberno-20–20; default 0
pitchnumberno-12–12
stabilitynumberno0.5–1.5
similaritynumberno0.5–1.5
languagestringno1–64 characters in v3
emotionstringno1–64 characters in v3
instructionstringnoup to 1,600 characters
textNormalizationbooleannostructured-text normalization

V2 also accepts legacy engineModelId, version, qwenModel, and minimaxEmotion fields. Do not use them in new clients.

curl

curl "https://fishaudio.org/api/open/v2/speech/tts" \
  -H "Authorization: Bearer $FISHAUDIO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Request-Id: legacy-tts-001" \
  -d '{"text":"Hello","voiceId":"00a1b221-6137-4b73-ad62-b0cbce134167","modelId":"fishaudio-s21pro-flash","format":"mp3"}' --output speech.mp3

成功回應

成功時回傳音訊二進位。先檢查 HTTP 狀態與 Content-Type;錯誤為 JSON。

錯誤與重試

400 請求無效;401 金鑰無效;402 額度不足;404 不存在;409 冪等衝突;413 過大;429 限流;500 產生失敗。

Migration

既有 v1/v2 客戶端保持相容,新接入使用 v3。 Migration guide.