Skip to main content
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-side sk-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.
All accounts and management interfaces on this page (including /api/token/*, /api/log/*, and /api/user/self) must request https://crazyrouter.com. https://api.crazyrouter.com only carries Model/Media APIs, and misuse will return 404 api_only_endpoint.

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 authentication
  • New-Api-User: Current user ID, which must be consistent with the user corresponding to access_token
  • sk-xxx: Business call Token, only used for model calls, not for management interfaces like /api/token/* and /api/log/*
It is recommended to access in the following order:
  1. Call /api/token/ to get the list of Keys under the current account
  2. Use token_name to call /api/log/self to fetch detailed logs for a certain Key
  3. Call /api/log/self/stat to get a summary quota under the same condition
  4. Call /api/status to get quota_per_unit
  5. Use quota / quota_per_unit to convert to USD expenses

1. Get API Key List

cURL
Response Example:
It is recommended that customers save the following fields for subsequent monitoring:
  • id
  • name
  • status
  • used_quota
  • model_limits_enabled
  • model_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:
  • type
  • token_name
  • start_timestamp
  • end_timestamp
  • p
  • page_size
Example:
cURL
Response Example:

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.
Single failed requests will not incur charges; quota / cost_usd in the logs should be 0. However, in Agent mode, workflows, chain calls, or IDE auto-programming, a single user operation may break into multiple model requests: if previous requests have succeeded and only a subsequent step fails, the previously successful requests will still be charged according to actual token consumption. When investigating abnormal consumption, please check each request in the log one by one instead of only reviewing if the final task failed.

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
Response Example:
Among them:
  • quota: total consumption quota under these filter conditions
  • rpm, 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
Response Example:
Key Fields: Conversion Method:
Example:
That is, the above sample balance is:
/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
Focus on in the response:
Conversion Formula:
Example:

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 by other.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 the cost_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.