API 參考

音訊

POST/v1/audio/speech
POST/v1/audio/transcriptions
POST/v1/audio/translations

語音雙向:/v1/audio/speech 把文字合成為音訊位元組;/v1/audio/transcriptions 把音訊轉成文字(Whisper 相容);/v1/audio/translations 直接轉寫成英文。

#請求參數

  • modelstring必填

    speech 用 tts-1 一類;轉寫用 whisper-1 一類。

  • inputstring必填

    僅 speech:要朗讀的文字。

  • voicestring必填

    僅 speech:音色名(alloy、nova……);可用音色見模型卡。

  • filefile (multipart)必填

    僅 transcriptions:音訊檔案(mp3、wav、m4a、webm……)。

  • languagestring選填

    僅 transcriptions:ISO-639-1 語言提示,可提高準確率。

  • response_formatstring選填

    speech:mp3 | wav | opus……;transcriptions:json | text | srt | verbose_json。

  • speednumber選填

    僅 speech:0.25–4.0 倍速。

兩種不同的 Content-Type

speech 接受 JSON、回傳音訊位元組;transcriptions/translations 接受 multipart/form-data、回傳 JSON。別混用。

#相關錯誤碼

  • 413 payload_too_large請求主體(prompt、圖片或音訊檔案)超出大小限制。
  • 401Bearer 權杖無效或缺失。這條路徑不帶 error.code,請依狀態碼判斷。
  • 402 insufficient_user_quota錢包餘額不足以覆蓋預扣估算。
  • 429金鑰級限流。回應主體為空,按 Retry-After 等待。若 429 帶有 insufficient_user_quota,那是每日消費上限,不是限流。
  • 503 model_not_found模型名稱不存在,或目前沒有健康的通道可以提供服務。

完整錯誤碼表 →

#請求範例

# text → speech (bytes saved to file)
curl https://www.aisplice.store/v1/audio/speech \
  -H "Authorization: Bearer sk-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "tts-1", "voice": "alloy", "input": "Hello from the gateway."}' \
  --output hello.mp3

# speech → text (multipart)
curl https://www.aisplice.store/v1/audio/transcriptions \
  -H "Authorization: Bearer sk-YOUR_KEY" \
  -F file=@meeting.mp3 -F model=whisper-1

#回應

response.json
// /v1/audio/speech → binary audio body (Content-Type: audio/mpeg)

// /v1/audio/transcriptions
{"text": "…transcript…"}

還是沒解決?

把請求 ID 或錯誤訊息傳給我們,我們來查。