跳轉到主要內容

Documentation Index

Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt

Use this file to discover all available pages before exploring further.

透過選擇您的應用程式需要語音輸出、轉錄或翻譯,來使用 CometAPI 音訊模型文件。音訊端點使用與其他 OpenAI 相容端點相同的 CometAPI API 金鑰模式。

選擇音訊 API

建立語音

將文字轉換為語音。

建立轉錄

將音訊轉錄為文字。

建立翻譯

將音訊翻譯成英文文字。

建立語音

使用來自 Models pagemodel directory 的支援音訊 model ID。以下範例會呼叫語音端點。
這些範例使用預留位置 your-audio-model-id。在您執行請求之前,請將其替換為來自 Models pagemodel directory 的可用音訊 model ID。
開啟 Create Speech 以使用 playground 和端點 schema。
import os
import requests

response = requests.post(
    "https://api.cometapi.com/v1/audio/speech",
    headers={
        "Authorization": "Bearer " + os.environ["COMETAPI_KEY"],
        "Content-Type": "application/json",
    },
    json={
        "model": "your-audio-model-id",
        "input": "Welcome to CometAPI.",
        "voice": "alloy",
        "response_format": "mp3",
    },
    timeout=60,
)

response.raise_for_status()

with open("speech.mp3", "wb") as audio_file:
    audio_file.write(response.content)

回應範例

成功的語音回應是二進位音訊。HTTP 回應可能如下所示:
HTTP/1.1 200 OK
Content-Type: audio/mpeg

speech.mp3

範例 model 記錄

此範例 model 目錄回應顯示 /api/models 的外框以及一筆音訊 model 記錄的結構。這不是完整的 model 清單。
cURL
curl https://api.cometapi.com/api/models
{
  "success": true,
  "page": 1,
  "page_size": 20,
  "total": 302,
  "data": [
    {
      "created": 0,
      "id": "your-audio-model-id",
      "code": "your-audio-model-id",
      "provider": "ExampleProvider",
      "provider_code": "example",
      "name": "Example audio model",
      "model_type": "audio",
      "features": [
        "text-to-speech"
      ],
      "endpoints": [
        "openai"
      ],
      "pricing": {
        "currency": "USD / M Tokens",
        "input": 12,
        "output": 12,
        "per_request": null,
        "per_second": null
      }
    }
  ]
}

常見錯誤

請使用端點頁面中記載的格式。
請壓縮音訊檔案,或將工作拆分成較小的檔案。
請確認檔案包含語音,且欄位名稱與文件相符。
使用 https://api.cometapi.com/v1

錯誤代碼與重試策略

在文字、檔案、model ID、voice 或 format 修正之前,不要重試。
在 API key 存在且有效之前,不要重試。
重試前請檢查 base URL、路徑和 model ID。
重試前請減少上傳大小。
以指數退避重試,並降低並行度。
對暫時性的提供者或服務錯誤,請以退避方式重試。
如需實作模式,請參閱 Error codes and retry strategyRate limits and concurrency

定價與 model 目錄

Models page

了解 CometAPI 如何在文件中公開 model ID。

Model directory

瀏覽 model 可用性與功能。

Pricing

在呼叫 model 之前先查看定價。
Last modified on May 28, 2026