ToAPIsToAPIs
API Key

列出 API Key

列出目前帳戶的一般模型 Key

GET
/api/v1/api-keys

中國大陸用戶請注意: 中國大陸用戶請使用 https://api.toapis.cn 作為接口地址 (Base URL). 文檔示例中的 https://api.toapis.com 請替換為 https://api.toapis.cn.

驗證, 分頁及錯誤處理請參閱接入方式.

使用說明

回傳當前帳戶下所有一般模型 Key 的元資料列表, 用於管理或挑選既有 Key. 列表按數字 ID 倒序排列, 預設排除已軟刪除的 Key 和 stats:read 類型的唯讀統計憑據; 單個詳情介面仍可以讀取自己已軟刪除的 Key.

key_hint 只包含固定遮罩和密鑰末 4 位, 密鑰過短時回傳 null; 完整密鑰和 Webhook 密鑰不在列表中回傳. 額度表示: 無限額度為 unlimited=true 且 remaining_credits=null, 日/月限額無限制同樣回傳 null. 屬於他人或不存在的 Key 統一回傳 404.

驗證

Authorizationstring請求頭必填

使用系統存取權杖, 格式為 Bearer YOUR_SYSTEM_ACCESS_TOKEN. 此介面不接受模型 API Key, 不需要 X-User-Id.

請求參數

limitinteger查詢預設值: 50

每頁最多回傳的項目數.

限制: minimum=1; maximum=100; 預設值: 50.

cursorstring查詢

原樣傳入上一頁的 next_cursor, 保留相同篩選條件. 變更條件後重新開始.

限制: maxLength=2048.

statusstring查詢

API Key 狀態.

限制: enabled, disabled, expired, exhausted, deleted.

請求範例

請求示例

curl --request GET \
  --url 'https://api.toapis.com/api/v1/api-keys?status=enabled&limit=20' \
  --header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'
import requests

response = requests.get(
    "https://api.toapis.com/api/v1/api-keys",
    headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
    params={
        "status": "enabled",
        "limit": "20"
    },
    timeout=30,
)
response.raise_for_status()
print(response.json())
const url = new URL("https://api.toapis.com/api/v1/api-keys");
url.search = new URLSearchParams({
  "status": "enabled",
  "limit": "20"
}).toString();

const response = await fetch(url, {
  headers: { Authorization: "Bearer YOUR_SYSTEM_ACCESS_TOKEN" },
  signal: AbortSignal.timeout(30_000),
});

if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(await response.json());

回應欄位

範例使用虛構資料, 並假設 credits_per_usd="100". 實際換算請以回應為準.

清單位於 data.items, 以 has_more 及 next_cursor 分頁. 最後一頁的游標為 null, 不回傳總數.

codeinteger

業務狀態碼, 成功時為 0.

messagestring

回應訊息, 成功時為空字串. 錯誤訊息依請求語言回傳.

dataobject

本次查詢的結果物件.

data.itemsobject[]

目前頁面的記錄清單, 空結果為 [].

data.items[].idstring

模型 API Key 的 ID, 並非 Key 原文. 以十進位 ID 字串回傳.

data.items[].namestring

API Key 的名稱.

data.items[].key_hintstring | null

固定遮罩及 Key 末 4 位, 不回傳完整密鑰. 過短時為 null.

data.items[].statusstring

API Key 目前狀態. 詳情可包含自有軟刪除 Key. 可選值: enabled, disabled, expired, exhausted, deleted, unknown.

data.items[].created_atstring | null

建立時間. 時間格式為含時區的 RFC 3339. 無法確認或不適用時為 null.

data.items[].expires_atstring | null

Key 到期時間, 未設定時為 null. 時間格式為含時區的 RFC 3339.

data.items[].unlimitedboolean

Key 是否無限額度. 為 true 時 remaining_credits=null.

data.items[].remaining_creditsstring | null

剩餘額度, 單位為 credits. API Key 無限額時為 null. 以十進位字串回傳以保留精度.

data.items[].daily_limit_creditsstring | null

每日額度上限, 單位為 credits, 無限制時為 null. 以十進位字串回傳以保留精度.

data.items[].monthly_limit_creditsstring | null

每月額度上限, 單位為 credits, 無限制時為 null. 以十進位字串回傳以保留精度.

data.items[].model_limitsstring[]

模型白名單字串陣列, 無限制為 [], 不回傳 null.

data.items[].allow_ipsstring[]

此 Key 的有效 IP 白名單, 按字典序回傳字串陣列; [] 表示不限制. 不影響同帳戶其他 Key 或系統存取權杖. 來源 IP 不符時模型呼叫回傳 403. 設定修改沿用既有快取及處理中請求的生效邊界.

data.has_moreboolean

是否還有下一頁.

data.next_cursorstring | null

下一頁游標, 原樣作為 cursor 傳入並保留篩選條件. 最後一頁為 null.

data.metaobject

資料來源, 查詢範圍及資料口徑等中繼資料.

data.meta.scopestring

查詢資料的歸屬範圍, 目前為驗證帳戶自身.

回應範例

響應示例

{
  "code": 0,
  "message": "",
  "data": {
    "items": [
      {
        "id": "42",
        "name": "Example Key",
        "key_hint": "****abcd",
        "status": "enabled",
        "created_at": "2026-10-01T00:00:00Z",
        "expires_at": null,
        "unlimited": false,
        "remaining_credits": "500",
        "daily_limit_credits": "100",
        "monthly_limit_credits": null,
        "model_limits": [],
        "allow_ips": []
      }
    ],
    "has_more": false,
    "next_cursor": null,
    "meta": {
      "scope": "self"
    }
  }
}