Content updated: 2026-07-20
Applicable Scenarios
When customers need to monitor each API Key, using Crazyrouter’s set of management interfaces is recommended, instead of querying business-sidesk-xxx directly:
- Obtain the list of API Keys under the current account
- Query call logs by time range, Key name, model name
- Summarize the total consumption quota of a specific Key
- Convert USD expenses based on system exchange rate parameters
Management interfaces use user authentication, not the business Token used in model calls.
Authentication Method
The management interfaces must carry the following two request headers:access_token: Access token generated after user login, used for console/management interface authenticationNew-Api-User: Current user ID, which must be consistent with the user corresponding toaccess_tokensk-xxx: Business call Token, only used for model calls, not for management interfaces like/api/token/*and/api/log/*
Recommended Access Process
It is recommended to access in the following order:- Call
/api/token/to get the list of Keys under the current account - Use
token_nameto call/api/log/selfto fetch detailed logs for a certain Key - Call
/api/log/self/statto get a summary quota under the same condition - Call
/api/statusto getquota_per_unit - Use
quota / quota_per_unitto convert to USD expenses
1. Get API Key List
cURL
idnamestatusused_quotamodel_limits_enabledmodel_limits
2. Query Call Logs for a Specific Key
Use/api/log/self to retrieve the consumption logs for the current user. It is recommended to include at least:
typetoken_namestart_timestampend_timestampppage_size
cURL
Explanation of Key Fields
cost_usd returns the USD expense calculated by the system’s conversion. The calculation method is quota / quota_per_unit. If your production environment hasn’t upgraded to the version containing this field, you can temporarily convert it yourself using the summary quota.3. Query Summary Consumption
If you do not need detailed logs and only want a monitoring dashboard or daily report, it is recommended to call the summary interface:cURL
quota: total consumption quota under these filter conditionsrpm,tpm: reserved fields for the current interface, can be used for extended monitoring
4. Query Current Account Balance
If customers not only want to monitor by business Key, but also want to display the current Crazyrouter account balance directly on their own backend, they can call/api/user/self.
Request headers are consistent with other management interfaces:
cURL
Conversion Method:
/api/user/self is more suitable for “displaying the current account total balance”; /api/log/self and /api/log/self/stat are more suitable for “consumption analysis by time range, Key, and model.”5. Convert USD Expenses
System conversion parameters can be obtained through the public interface/api/status:
cURL
Python Integration Example
Monitoring Suggestions
For customer-side monitoring, it is recommended to include at least the following dimensions:- Count the number of calls, total quota, and total expenses by
token_name - Count model consumption distribution by
model_name - Distinguish
/v1/chat/completions,/v1/responses, and other interfaces byother.request_path - Calculate success and failure rates by
other.http_status - Keep issue tracking links by
other.request_id
Frequently Asked Questions
Why can’t the management interface use sk-xxx directly?
Because sk-xxx is a business call credential, verified by TokenAuth middleware; whereas management interfaces like /api/token/* and /api/log/self* use user authentication, which requires access_token and New-Api-User.
Can you query your logs by a specific Key?
Yes. It is recommended to filter/api/log/self and /api/log/self/stat through token_name.
Can you get the expense amount directly through the API?
If the server version already supports thecost_usd field, you can obtain the USD expense for a single request directly from the log details. For the summary, it is recommended to use quota / quota_per_unit for conversion, which matches the console display.