Use Cases
If a customer needs monitoring per API key, use the Crazyrouter management APIs instead of trying to query with a businesssk-xxx token directly:
- List all API keys under the current account
- Query usage logs by time range, key name, or model name
- Get summarized quota consumption for a specific key
- Convert quota into USD cost using system pricing metadata
Management APIs use user-level authentication, not the business token used for model inference calls.
Authentication
Management APIs require both headers:access_token: user access token used for dashboard or management API authenticationNew-Api-User: current user ID, and it must match the user bound to theaccess_tokensk-xxx: business token for model calls only, not for/api/token/*or/api/log/*management APIs
Recommended Integration Flow
Recommended sequence:- Call
/api/token/to get the current account’s API key list - Call
/api/log/selfwithtoken_nameto fetch detailed logs for one key - Call
/api/log/self/statto fetch the summarized quota for the same filter - Call
/api/statusto getquota_per_unit - Convert quota into USD with
quota / quota_per_unit
1. List API Keys
cURL
idnamestatusused_quotamodel_limits_enabledmodel_limits
2. Query Usage Logs for a Specific Key
Use/api/log/self to query the current user’s own consumption logs. At minimum, send:
typetoken_namestart_timestampend_timestampppage_size
cURL
Key Fields
| Field | Description |
|---|---|
token_name | Which business key handled the request |
model_name | The actual billed model |
quota | System quota consumed by this request |
cost_usd | USD cost converted from quota |
prompt_tokens | Input tokens |
completion_tokens | Output tokens |
use_time | Request latency in seconds |
other.request_id | Request ID for tracing |
other.client | Client identifier |
other.request_path | Upstream endpoint path |
other.http_status | Upstream HTTP status code |
cost_usd is derived with quota / quota_per_unit. If your production environment has not yet been upgraded to a version that returns this field, you can still calculate cost from the summary quota.3. Query Summary Consumption
If you only need a dashboard, report, or alerting input, use the summary endpoint:cURL
quota: total consumed quota under the current filterrpmandtpm: reserved fields for extended monitoring
4. Convert Quota to USD Cost
System conversion metadata is available from the public/api/status endpoint:
cURL
Python Example
Monitoring Recommendations
Recommended dimensions for customer-side monitoring:- Aggregate request count, total quota, and total cost by
token_name - Aggregate consumption distribution by
model_name - Split traffic by
other.request_path, such as/v1/chat/completionsand/v1/responses - Track success and failure rates by
other.http_status - Keep
other.request_idfor incident investigation
FAQ
Why can’t management APIs use sk-xxx directly?
Because sk-xxx is validated by the token-auth flow for business requests, while /api/token/* and /api/log/self* are user-authenticated management APIs that require access_token plus New-Api-User.
Can I query my logs for a single key?
Yes. The recommended approach is filtering/api/log/self and /api/log/self/stat by token_name.
Can I get cost directly via API?
If your server version already exposescost_usd, you can read per-request USD cost directly from log items. For summary-level monitoring, use quota / quota_per_unit; this matches the dashboard calculation method.