取得 API Key 詳情
讀取自有一般模型 Key 的中繼資料
中國大陸用戶請注意: 中國大陸用戶請使用 https://api.toapis.cn 作為接口地址 (Base URL). 文檔示例中的 https://api.toapis.com 請替換為 https://api.toapis.cn.
驗證, 分頁及錯誤處理請參閱接入方式.
使用說明
回傳指定 Key 的元資料, 用於查看名稱, 狀態, 額度, 到期時間和模型限制等設定. 已軟刪除的 Key 也可以讀取, 此時 status=deleted. 完整密鑰只在建立和輪換回應中回傳, 本介面不回傳 key 欄位. 屬於他人或不存在的 Key 統一回傳 404.
驗證
Authorizationstring請求頭必填使用系統存取權杖, 格式為 Bearer YOUR_SYSTEM_ACCESS_TOKEN. 此介面不接受模型 API Key, 不需要 X-User-Id.
請求參數
api_key_idstring路徑必填自身模型 API Key 的十進位 ID 字串. 不屬於自己時回傳 404, 已刪除 Key 仍可篩選自身歷史用量.
限制: pattern=^[1-9][0-9]*$.
請求範例
請求示例
curl --request GET \
--url 'https://api.toapis.com/api/v1/api-keys/42' \
--header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'import requests
response = requests.get(
"https://api.toapis.com/api/v1/api-keys/42",
headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
timeout=30,
)
response.raise_for_status()
print(response.json())const url = new URL("https://api.toapis.com/api/v1/api-keys/42");
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". 實際換算請以回應為準.
codeinteger業務狀態碼, 成功時為 0.
messagestring回應訊息, 成功時為空字串. 錯誤訊息依請求語言回傳.
dataobject本次查詢的結果物件.
data.idstring模型 API Key 的 ID, 並非 Key 原文. 以十進位 ID 字串回傳.
data.namestringAPI Key 的名稱.
data.key_hintstring | null固定遮罩及 Key 末 4 位, 不回傳完整密鑰. 過短時為 null.
data.statusstringAPI Key 目前狀態. 詳情可包含自有軟刪除 Key. 可選值: enabled, disabled, expired, exhausted, deleted, unknown.
data.created_atstring | null建立時間. 時間格式為含時區的 RFC 3339. 無法確認或不適用時為 null.
data.expires_atstring | nullKey 到期時間, 未設定時為 null. 時間格式為含時區的 RFC 3339.
data.unlimitedbooleanKey 是否無限額度. 為 true 時 remaining_credits=null.
data.remaining_creditsstring | null剩餘額度, 單位為 credits. API Key 無限額時為 null. 以十進位字串回傳以保留精度.
data.daily_limit_creditsstring | null每日額度上限, 單位為 credits, 無限制時為 null. 以十進位字串回傳以保留精度.
data.monthly_limit_creditsstring | null每月額度上限, 單位為 credits, 無限制時為 null. 以十進位字串回傳以保留精度.
data.model_limitsstring[]模型白名單字串陣列, 無限制為 [], 不回傳 null.
data.allow_ipsstring[]此 Key 的有效 IP 白名單, 按字典序回傳字串陣列; [] 表示不限制. 不影響同帳戶其他 Key 或系統存取權杖. 來源 IP 不符時模型呼叫回傳 403. 設定修改沿用既有快取及處理中請求的生效邊界.
回應範例
響應示例
{
"code": 0,
"message": "",
"data": {
"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": []
}
}