> ## 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 模型

> 使用模型目錄端點列出可用的 CometAPI 模型，並透過模型目錄確認能力與定價。

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

## 呼叫模型目錄

以下請求會列出可用模型：

```bash theme={null}
curl https://api.cometapi.com/api/models
```

回應包含模型記錄：

```json theme={null}
{
  "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：

```python theme={null}
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 清單：

```text theme={null}
your-model-id
another-model-id
```

## 使用 model ID

以下範例使用目錄中的其中一個 model ID 傳送請求：

```bash theme={null}
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：

```json theme={null}
{
  "model": "your-model-id",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hello."
      }
    }
  ]
}
```

## 常見錯誤

| Error                           | Fix                                                                 |
| ------------------------------- | ------------------------------------------------------------------- |
| 將目錄誤當成定價資料                      | 請使用模型目錄查看定價與能力細節。                                                   |
| 重複使用過時的 model ID                | 在部署或啟動期間重新擷取目錄。                                                     |
| 混淆 `/api/models` 與 `/v1/models` | 公開目錄請使用 `/api/models`。只有在需要 OpenAI 相容的模型清單格式時，才使用需驗證的 `/v1/models`。 |
| 模型類型使用了錯誤的端點                    | 將模型能力對應到 API 參考頁面。                                                  |

## 相關連結

* [模型頁面](/zh-Hant/overview/models)
* [模型目錄](https://www.cometapi.com/models/)
* [價格](https://www.cometapi.com/pricing/)
* [文字模型](/api/text)
* [圖片模型](/api/image)
* [影片模型](/api/video)
* [音訊模型](/api/audio)

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "TechArticle",
        "@id": "https://apidoc.cometapi.com/guides/how-to-list-available-models",
        "headline": "如何列出可用模型？",
        "description": "使用公開模型目錄端點列出可用的 CometAPI 模型，並使用模型目錄確認功能與價格。",
        "url": "https://apidoc.cometapi.com/guides/how-to-list-available-models",
        "author": {
          "@type": "Organization",
          "name": "CometAPI"
        },
        "publisher": {
          "@type": "Organization",
          "name": "CometAPI",
          "url": "https://www.cometapi.com"
        }
      },
      {
        "@type": "BreadcrumbList",
        "itemListElement": [
          {
            "@type": "ListItem",
            "position": 1,
            "name": "CometAPI 文件",
            "item": "https://apidoc.cometapi.com/"
          },
          {
            "@type": "ListItem",
            "position": 2,
            "name": "指南",
            "item": "https://apidoc.cometapi.com/guides/use-cometapi-with-openai-sdk"
          },
          {
            "@type": "ListItem",
            "position": 3,
            "name": "如何列出可用模型？",
            "item": "https://apidoc.cometapi.com/guides/how-to-list-available-models"
          }
        ]
      }
    ]
    }
    `}
</script>
