跳转到主要内容

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 key 模式。

选择一个音频 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

示例模型记录

此示例模型目录响应展示了 /api/models 包装结构和一种音频 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 或格式之前,不要重试。
在 API key 存在且有效之前,不要重试。
重试前检查基础 URL、路径和 model ID。
在重试前减小上传大小。
使用指数退避重试,并降低并发量。
对临时的提供商或服务错误使用退避重试。
有关实现模式,请参阅 Error codes and retry strategyRate limits and concurrency

定价和 model 目录

Models page

阅读 CometAPI 如何在文档中公开 model ID。

Model directory

浏览模型可用性和能力。

Pricing

在调用模型之前查看定价。
Last modified on May 28, 2026