Chuyển đến nội dung chính

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.

Hãy dùng tài liệu audio model của CometAPI bằng cách chọn xem ứng dụng của bạn cần đầu ra speech, transcription hay translation. Các audio endpoint dùng cùng mẫu CometAPI API key như các endpoint tương thích OpenAI khác.

Chọn một audio API

Create Speech

Chuyển văn bản thành speech.

Create Transcription

Chuyển âm thanh thành văn bản.

Create Translation

Dịch âm thanh sang văn bản tiếng Anh.

Create speech

Dùng một model ID có hỗ trợ âm thanh từ Models page hoặc model directory. Các ví dụ bên dưới gọi speech endpoint.
Các ví dụ này dùng placeholder your-audio-model-id. Hãy thay nó bằng một model ID âm thanh khả dụng từ Models page hoặc model directory trước khi bạn chạy request.
Mở Create Speech để dùng playground và endpoint 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)

Ví dụ phản hồi

Một phản hồi speech thành công là audio nhị phân. Phản hồi HTTP có thể trông như sau:
HTTP/1.1 200 OK
Content-Type: audio/mpeg

speech.mp3

Ví dụ bản ghi model

Ví dụ phản hồi danh mục model này cho thấy envelope /api/models và một dạng bản ghi audio model. Đây không phải là danh sách model đầy đủ.
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
      }
    }
  ]
}

Lỗi thường gặp

Hãy dùng các định dạng được tài liệu hóa trên trang endpoint.
Nén file audio hoặc chia công việc thành các file nhỏ hơn.
Xác nhận rằng file có chứa speech và tên field khớp với tài liệu.
Dùng https://api.cometapi.com/v1.

Mã lỗi và chiến lược retry

Không retry cho đến khi text, file, model ID, voice hoặc format được sửa.
Không retry cho đến khi API key có mặt và hợp lệ.
Kiểm tra base URL, path và model ID trước khi retry.
Giảm kích thước upload trước khi retry.
Retry với exponential backoff và giảm concurrency.
Retry với backoff cho các lỗi tạm thời từ provider hoặc service.
Để xem các pattern triển khai, tham khảo Error codes and retry strategyRate limits and concurrency.

Pricing và model directory

Models page

Đọc cách CometAPI hiển thị model IDs trong tài liệu.

Model directory

Duyệt khả dụng và năng lực của các model.

Pricing

Kiểm tra pricing trước khi bạn gọi một model.
Last modified on May 28, 2026