取得模型列表

取得目前使用者可存取的所有 AI 模型列表,包括模型 ID、名稱、供應商與詳細資訊。

關於模型列表與權杖分組

模型列表回傳哪些模型,取決於 API KEY(API 權杖)所在的權杖分組。您可以在控制台 → API 權杖頁面,新增權杖時選擇對應的權杖分組。

API 端點

GET https://aiberm.com/v1/models

請求範例

1curl -X GET "https://aiberm.com/v1/models" \
2-H "Authorization: Bearer sk-your-api-token-here" \
3-H "Content-Type: application/json"

回應格式

成功回應 (200 OK)

1{
2"success": true,
3"data": [
4 {
5 "id": "gpt-4",
6 "object": "model",
7 "created": 1626777600,
8 "owned_by": "openai",
9 "supported_endpoint_types": [
10 "chat",
11 "completion"
12 ]
13 },
14 {
15 "id": "gpt-3.5-turbo",
16 "object": "model",
17 "created": 1626777600,
18 "owned_by": "openai",
19 "supported_endpoint_types": [
20 "chat",
21 "completion"
22 ]
23 },
24 {
25 "id": "claude-3-sonnet-20240229",
26 "object": "model",
27 "created": 1626777600,
28 "owned_by": "anthropic",
29 "supported_endpoint_types": [
30 "chat"
31 ]
32 }
33]
34}

回應欄位說明

頂層欄位:

  • success - 布林值,表示請求是否成功
  • data - 模型列表陣列(僅在成功時回傳)
  • message - 錯誤訊息(僅在失敗時回傳)

模型物件欄位:

  • id - 模型唯一識別碼
  • object - 物件類型,固定為 “model”
  • created - 模型建立時間戳記
  • owned_by - 模型所屬的服務商
  • supported_endpoint_types - 支援的 API 端點類型陣列

支援的端點類型

  • chat - 聊天完成
  • completion - 文字完成
  • embedding - 文字嵌入
  • image - 圖像產生
  • audio - 音訊處理
  • rerank - 重新排序

注意事項

驗證要求

必須提供有效的 API 權杖,權杖決定了使用者可以存取哪些模型。

權限控制

回傳的模型列表會依使用者群組與權杖群組進行過濾,只顯示使用者有權限存取的模型。

常見錯誤

  • 401 Unauthorized - API 權杖無效或已過期
  • 403 Forbidden - 使用者沒有存取權限
  • 500 Internal Server Error - 伺服器內部錯誤