跳轉到主要內容

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.

透過呼叫公開的 GET /api/models 目錄端點來列出可用模型。使用回傳的 model ID 進行 API 請求,然後在模型目錄中確認能力與定價細節。

呼叫模型目錄

以下請求會列出可用模型:
curl https://api.cometapi.com/api/models
回應包含模型記錄:
{
  "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"
    }
  ]
}

Python 模型列表

以下 Python 範例會從目錄中列印 model ID:
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"])
輸出會是一串 model ID 清單:
your-model-id
another-model-id

使用 model ID

以下範例會使用目錄中的其中一個 model ID 傳送請求:
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."
      }
    ]
  }'
回應會使用所選的 model ID:
{
  "model": "your-model-id",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hello."
      }
    }
  ]
}

常見錯誤

錯誤修正方式
將目錄當作定價資料請使用模型目錄查看定價與能力細節。
重複使用過時的 model ID在部署或啟動期間重新取得目錄。
混淆 /api/models/v1/models公開目錄請使用 /api/models。只有在需要 OpenAI 相容的模型列表格式時,才使用需驗證的 /v1/models
模型類型使用了錯誤的端點讓模型能力與 API 參考頁面相對應。

相關連結

Last modified on May 28, 2026