獲取可用模型列表(Model)
說明
介面字首統一為 http(s)://<your-domain>
生產環境應使用 HTTPS 以保證認證令牌。 HTTP 僅建議用於開發環境。
- 介面名稱:獲取前端可用模型列表
- HTTP 方法:GET
- 路徑:
/api/models - 鑑權要求:使用者
- 功能簡介:獲取當前使用者可訪問的 AI 模型列表,用於前端 Dashboard 展示
💡 請求示例:
const response = await fetch('/api/models', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_user_token',
'New-Api-User': 'your_user_id'
}
});
const data = await response.json();✅ 成功響應示例:
{
"success": true,
"data": {
"1": ["gpt-3.5-turbo", "gpt-4"],
"2": ["claude-3-sonnet", "claude-3-haiku"]
}
}❗ 失敗響應示例:
{
"success": false,
"message": "未授權訪問"
}🧾 欄位說明:
data(物件): 渠道 ID 到模型列表的對映- 鍵 (字串): 渠道 ID
- 值 (陣列): 該渠道支援的模型名稱列表