API Reference
Legacy usage lookup by key
Legacy usage lookup by key; the contract below follows this gateway implementation.
Preview guide
Paste into an AI assistant to help with integration. Documentation and examples only; no real credentials.
Updated · Reviewed
Endpoint and authentication
GET https://api.tu-zi.com/api/token/key/{key}
Transport: json
- Legacy lookup: put the inference API key in the path and its owner's account ID in New-Api-User (Rix-Api-User is also accepted).
- No additional Authorization is required. Key and owner must match.
- URLs contain credentials; redact access logs. Prefer Bearer-authenticated /api/usage/token/ for new integrations.
New-Api-User: YOUR_USER_ID
Before calling
- Examples use this site's address. For another gateway, replace only the site address and keep the full endpoint path.
- Set
API_KEYandUSER_IDin the environment. In cURL, replaceYOUR_USER_IDwith the key owner's account ID.
Constraints
- Values are raw quota; use site conversion settings instead of hard-coded currency/rates.
- Missing/mismatched owner or invalid key returns 401; empty input can return success=false.
- This lookup does not create or recover keys.
Confirming success
Check HTTP status, the business status in the body and the required result fields. Do not rely only on HTTP 200 or the script exit code.
Path parameters
| Field | Type | Required | Description / constraints |
|---|---|---|---|
| key | string | Yes | Inference API key, optionally prefixed with sk-. Example: YOUR_KEY |
Response fields
| Field | Type | Description / constraints |
|---|---|---|
| code | boolean | True on success. |
| data.object | string | Always token_usage. |
| data.name | string | Token name. |
| data.total_granted | integer | remain_quota + used_quota in raw quota units. |
| data.total_used | integer | Used quota. |
| data.total_available | integer | Remaining quota. |
| data.unlimited_quota | boolean | Whether quota is unlimited. |
| data.expires_at | integer | Unix seconds; 0 means no expiry. |
| data.model_limits | object | Model restriction set. |
| data.model_limits_enabled | boolean | Whether model restrictions are enabled. |
Illustrative response; some endpoints show essential fields only. Optional fields may be absent.
{
"code": true,
"message": "ok",
"data": {
"object": "token_usage",
"total_granted": 1000000,
"total_used": 500000,
"total_available": 500000,
"unlimited_quota": false,
"expires_at": 0,
"name": "Example token",
"model_limits": {},
"model_limits_enabled": false
}
}
Errors and retries
Check HTTP status and protocol-specific errors; do not mix error formats across protocols.
- 401/403: check credentials and permissions.
- 429: classify temporary throttling, exhausted quota, or service capacity failure; only transient failures merit bounded backoff.
- 5xx: inspect the gateway, upstream, and model/channel configuration.
Error bodies may contain error/message/code depending on the protocol.
- Use bounded exponential backoff for reads encountering transient errors; fix parameter, authentication, quota, or configuration failures first.
- Do not blindly retry task creation, generation, or key mutations, to avoid duplicate billing or execution.
兔子API