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請求欄位
| field | type | required | constraints |
|---|---|---|---|
text | string | yes | 1–10,000 |
voiceId | string | yes | must support modelId |
modelId | string | no | public model ID |
format | string | no | mp3, wav, ogg; default mp3 |
speed | number | no | 0.5–2; default 1 |
volume | number | no | -20–20; default 0 |
pitch | number | no | -12–12 |
stability | number | no | 0.5–1.5 |
similarity | number | no | 0.5–1.5 |
language | string | no | 1–64 characters in v3 |
emotion | string | no | 1–64 characters in v3 |
instruction | string | no | up to 1,600 characters |
textNormalization | boolean | no | structured-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.