メインコンテンツへスキップ
更新日: 2026-07-20

Use Cases

If a customer needs monitoring per API key, use the Crazyrouter management APIs instead of trying to query with a business sk-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.
All account and management endpoints on this page, including /api/token/*, /api/log/*, and /api/user/self, must use https://crazyrouter.com. https://api.crazyrouter.com is reserved for model and media APIs and returns 404 api_only_endpoint for management routes.

Authentication

Management APIs require both headers:
  • access_token: user access token used for dashboard or management API authentication
  • New-Api-User: current user ID, and it must match the user bound to the access_token
  • sk-xxx: business token for model calls only, not for /api/token/* or /api/log/* management APIs
Recommended sequence:
  1. Call /api/token/ to get the current account’s API key list
  2. Call /api/log/self with token_name to fetch detailed logs for one key
  3. Call /api/log/self/stat to fetch the summarized quota for the same filter
  4. Call /api/status to get quota_per_unit
  5. Convert quota into USD with quota / quota_per_unit

1. List API Keys

cURL
Example response:
Recommended fields to persist for monitoring:
  • id
  • name
  • status
  • used_quota
  • model_limits_enabled
  • model_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:
  • type
  • token_name
  • start_timestamp
  • end_timestamp
  • p
  • page_size
Example:
cURL
Example response:

Key Fields

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
Example response:
Where:
  • quota: total consumed quota under the current filter
  • rpm and tpm: reserved fields for extended monitoring

4. Query Current Account Balance

If the customer does not only want per-key monitoring, but also wants to display the current Crazyrouter account balance directly in their own admin panel, call /api/user/self. Use the same management-auth headers:
cURL
Example response:
Key fields: Conversion:
Example:
So the example above means:
/api/user/self is better for displaying the current total account balance. /api/log/self and /api/log/self/stat are better for analyzing usage by time range, business key, or model.

5. Convert Quota to USD Cost

System conversion metadata is available from the public /api/status endpoint:
cURL
Relevant fields:
Formula:
Example:

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/completions and /v1/responses
  • Track success and failure rates by other.http_status
  • Keep other.request_id for 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 exposes cost_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.