API Reference

Legacy usage lookup by key

Legacy usage lookup by key; the contract below follows this gateway implementation.

GET https://api.tu-zi.com/api/token/key/{key}
Preview guide

Paste into an AI assistant to help with integration. Documentation and examples only; no real credentials.

Preview guide

Legacy usage lookup by key

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_KEY and USER_ID in the environment. In cURL, replace YOUR_USER_ID with 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

FieldTypeRequiredDescription / constraints
keystringYesInference API key, optionally prefixed with sk-. Example: YOUR_KEY

Response fields

FieldTypeDescription / constraints
codebooleanTrue on success.
data.objectstringAlways token_usage.
data.namestringToken name.
data.total_grantedintegerremain_quota + used_quota in raw quota units.
data.total_usedintegerUsed quota.
data.total_availableintegerRemaining quota.
data.unlimited_quotabooleanWhether quota is unlimited.
data.expires_atintegerUnix seconds; 0 means no expiry.
data.model_limitsobjectModel restriction set.
data.model_limits_enabledbooleanWhether 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.