Public API

查詢 API Key 用量

Management key required. 查詢 Key 請求數與已結算美元費用,包含已刪除的 Key。

URL 中的 api_key_id 就是建立模型 API Key(POST /public/v1/api-keys)回應中的 id,格式為 ak_...。 請儲存此值,以便停用、刪除、設定額度及查詢用量。回應中的 key(apikey-...)用於模型呼叫;管理操作的驗證標頭仍使用 mgmt-...。

GET
/public/v1/api-keys/{api_key_id}/usage

Management key required. Use a Management API Key (mgmt-...) for your Team, created by a Team Owner. Requests use the Team associated with that key.

Includes disabled, expired and deleted keys and keys in archived projects. Only API-key-based sources are counted; a user with the same internal ID is excluded. See ResourceUsage for accounting semantics. Unknown or repeated query parameters are rejected.

Authorization

ManagementKeyBearer
AuthorizationBearer <token>

Management key required. Send Authorization: Bearer mgmt-....

In: header

Path Parameters

api_key_id*string

The id returned by Create a model API key (POST /public/v1/api-keys). Copy the complete ak_... value into this path parameter. Use the mgmt-... management key in the authorization header; the returned key (apikey-...) is for model calls.

Match^ak_[0-9A-Za-z]{22}$

Query Parameters

from*string

Inclusive RFC 3339 start after the Unix epoch, aligned to a UTC hour boundary. Maximum window is 31 days.

Formatdate-time
to*string

Exclusive RFC 3339 end, aligned to a UTC hour boundary and strictly after from.

Formatdate-time

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "https://example.com/public/v1/api-keys/ak_0123456789ABCDEFGHIJKL/usage?from=2026-11-01T00%3A00%3A00Z&to=2026-11-02T00%3A00%3A00Z"
{  "object": "api_key_usage",  "api_key_id": "ak_0123456789ABCDEFGHIJKL",  "from": "2026-11-01T00:00:00Z",  "to": "2026-11-02T00:00:00Z",  "requests": 12,  "successes": 10,  "failures": 2,  "amount": {    "value": "1.230000",    "currency": "usd"  },  "request_id": "req_example"}

Last updated on