API 參考
文字轉語音
呼叫 NeonAPI 所需的端點、請求參數與回應結構。
POST /v1/audio/speech
身分驗證
將 NeonAPI 金鑰放入 Authorization: Bearer YOUR_API_KEY 請求標頭,在可信應用環境中保管金鑰。
可用性與相容性
呼叫前核對模型的協定、權限、報價與支援參數。不支援的參數可能被拒絕。範例中的金鑰與模型均為佔位符。
請求參數
application/json
| 欄位 | 類型 | 必填 | 限制 | 意義 |
|---|---|---|---|---|
model | string | 是 | — | 模型廣場發布的準確 ID。 |
input | string | 是 | — | 按目前端點格式提供輸入內容。 |
voice | string | 是 | alloy, echo, fable, onyx, nova, shimmer | 所選語音模型支援的音色。 |
response_format | string | 否 | mp3, opus, aac, flac, wav, pcm; default: "mp3" | 模型支援的輸出格式。 |
speed | number | 否 | ≥ 0.25; ≤ 4; default: 1 | — |
完整欄位定義、巢狀物件和引用結構可在下載的規格中查看。
請求範例
export NEON_API_KEY="YOUR_API_KEY"
curl https://neon-api.com/v1/audio/speech \
-H "Authorization: Bearer $NEON_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"input": "Welcome to NeonAPI",
"voice": "alloy"
}'回應說明
實際欄位因模型與協定而異。下方結構描述文件中的成功回應;串流請求使用對應協定的事件。
| 狀態碼 | 意義 |
|---|---|
| 200 | 請求成功 |
回應結構
string
另見常見錯誤與串流回應和非同步任務。