列出模型
查詢當前 API Key 可用的模型列表,兼容 OpenAI Models API
中國大陸用戶請注意: 中國大陸用戶請使用 https://toapis.cn 作為接口地址(Base URL)。文檔示例中的 https://toapis.com 請替換為 https://toapis.cn。
- 兼容 OpenAI Models API 格式
- 返回當前 API Key 與用戶組可用的模型
- 默認返回文字模型,可通過
type=all獲取全部類型模型 - 可按模型類型篩選文字、圖片、視頻或音頻模型
獲取當前 API Key 可訪問的模型列表。返回結果會根據令牌模型限制、用戶組、可用渠道和模型計費配置動態過濾。
Authorizations
Authorizationstring請求頭必填所有接口均需要使用 Bearer Token 進行認證
獲取 API Key:訪問 API Key 管理頁面 獲取您的 API Key
使用時在請求頭中添加:
Authorization: Bearer YOUR_API_KEYQuery Parameters
typestring查詢預設值: text模型類型篩選。
可選值:
text或chat:僅返回文字對話模型image:僅返回圖片模型video:僅返回視頻模型audio:僅返回音頻模型all:返回全部可用模型
不傳時默認只返回文字模型。
Response
successboolean請求是否成功。
objectstring列表對象類型,固定爲 list。
dataobject[]模型列表。
data[n]
idstring模型 ID,用於請求其他接口時的 model 參數。
objectstring對象類型,固定爲 model。
createdinteger模型創建時間戳。部分自定義模型會返回平臺默認時間戳。
owned_bystring模型所屬供應商或渠道名稱。
supported_endpoint_typesstring[]模型支持的接口類型。不同模型可能支持 Chat Completions、Responses、圖片、視頻等不同端點。
請求示例
curl --request GET \
--url 'https://toapis.com/v1/models' \
--header 'Authorization: Bearer <token>'curl --request GET \
--url 'https://toapis.com/v1/models?type=all' \
--header 'Authorization: Bearer <token>'import requests
API_BASE = 'https://toapis.com'
API_KEY = 'sk-xxxxxxxxxxxxxxxxxxxxxx'
headers = {
'Authorization': f'Bearer {API_KEY}'
}
response = requests.get(f'{API_BASE}/v1/models', headers=headers)
data = response.json()
if data.get('success'):
for model in data.get('data', []):
print(model['id'])
else:
print(data)const API_BASE = 'https://toapis.com';
const API_KEY = 'sk-xxxxxxxxxxxxxxxxxxxxxx';
async function listModels(type = 'text') {
const url = new URL('/v1/models', API_BASE);
if (type) url.searchParams.set('type', type);
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${API_KEY}`,
},
});
const data = await response.json();
console.log(data.data?.map((model) => model.id));
return data;
}
listModels('all');響應示例
{
"success": true,
"object": "list",
"data": [
{
"id": "claude-sonnet-4-6",
"object": "model",
"created": 1626777600,
"owned_by": "anthropic",
"supported_endpoint_types": ["chat_completions", "responses"]
},
{
"id": "gpt-5",
"object": "model",
"created": 1626777600,
"owned_by": "openai",
"supported_endpoint_types": ["chat_completions"]
}
]
}說明
- 如果 API Key 配置了模型限制,只會返回該令牌允許訪問的模型。
- 如果不傳
type,視頻和音頻等異步任務模型不會出現在默認結果中。 - 如果需要獲取圖片、視頻、音頻等全部可用模型,請使用
GET /v1/models?type=all。