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 参考页面相匹配。 |
相关链接