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.

Liệt kê các model khả dụng bằng cách gọi endpoint danh mục công khai GET /api/models. Sử dụng các model ID được trả về cho các yêu cầu API, sau đó xác nhận chi tiết về khả năng và giá trong thư mục model.

Gọi danh mục model

Yêu cầu sau liệt kê các model khả dụng:
curl https://api.cometapi.com/api/models
Phản hồi chứa các bản ghi model:
{
  "success": true,
  "page": 0,
  "page_size": 0,
  "total": 301,
  "data": [
    {
      "id": "gpt-image-2",
      "provider": "OpenAI",
      "model_type": "image",
      "features": [
        "text-to-image"
      ],
      "pricing": {
        "currency": "USD / M Tokens",
        "input": 4,
        "output": 24,
        "per_request": null,
        "per_second": null
      },
      "api_doc_url": "https://apidoc.cometapi.com/api/image/openai/images"
    }
  ]
}

Danh sách model Python

Ví dụ Python sau in ra các model ID từ danh mục:
import requests

response = requests.get("https://api.cometapi.com/api/models", timeout=30)
response.raise_for_status()

models = response.json()["data"]
for model in models:
    print(model["id"])
Đầu ra là danh sách các model ID:
your-model-id
another-model-id

Sử dụng một model ID

Ví dụ sau gửi một yêu cầu với một model ID từ danh mục:
curl https://api.cometapi.com/v1/chat/completions \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [
      {
        "role": "user",
        "content": "Say hello."
      }
    ]
  }'
Phản hồi sử dụng model ID đã chọn:
{
  "model": "your-model-id",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hello."
      }
    }
  ]
}

Các lỗi thường gặp

LỗiCách sửa
Nhầm danh mục là dữ liệu giáSử dụng thư mục model để xem chi tiết về giá và khả năng.
Tái sử dụng model ID đã cũLấy lại danh mục trong quá trình triển khai hoặc khi khởi động.
Nhầm lẫn giữa /api/models/v1/modelsSử dụng /api/models cho danh mục công khai. Chỉ sử dụng /v1/models có xác thực khi bạn cần định dạng danh sách model tương thích OpenAI.
Sai endpoint cho loại modelĐối chiếu khả năng của model với trang tham chiếu API.

Liên kết liên quan

Last modified on May 28, 2026