Skip to content

Credit usage & balance

Retrieves your account’s credit information, including remaining credits, total usage, and total deposits.

Terminal window
curl "https://api.imagerouter.io/v1/credits" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"remaining_credits": "25.5000",
"credit_usage": "4.5000",
"total_deposits": "30.0000"
}

You can retrieve a breakdown of usage for each of your API keys by adding the by_api_key=true query parameter.

Terminal window
curl "https://api.imagerouter.io/v1/credits?by_api_key=true" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"remaining_credits": "25.5000",
"credit_usage": "4.5000",
"total_deposits": "30.0000",
"usage_by_api_key": [
{
"api_key_id": "d9eb93dc-56b1-4216-91b5-a44944508bbc",
"api_key_name": "Production Key",
"credit_usage": "4.2000",
"total_requests": 150,
"created_at": "2023-10-01T12:00:00.000Z",
"is_active": true,
"spend_limit": "5.0000",
"spend_limit_period": "month",
"period_spend": "1.2000",
"period_start": "2026-05-01T00:00:00.000Z",
"expires_at": "2027-01-01T00:00:00.000Z"
},
{
"api_key_id": "temp_jwt",
"api_key_name": "Temporary web token (imagerouter.io)",
"credit_usage": "0.0300",
"total_requests": 45,
"created_at": null,
"is_active": false,
"spend_limit": null,
"spend_limit_period": null,
"period_spend": "0.0300",
"period_start": null,
"expires_at": null
}
]
}

Per-key fields:

  • spend_limit — USD cap for the key’s current window, or null when no cap is set.
  • spend_limit_period"day" / "week" / "month" reset window, or null for a lifetime cap. See the management keys docs for boundary semantics.
  • period_spend — USD spent in the current window. Equals credit_usage when spend_limit_period is null.
  • period_start — UTC timestamp marking the start of the current window. null when no period is set or the key has not been used in the current window scheme.
  • expires_at — UTC timestamp at which the key is automatically rejected, or null when the key never expires.

If the request fails, you will receive an error response:

{
"error": {
"message": "Failed to fetch credit information",
"type": "internal_error"
}
}
  • The endpoint only counts deposits with status COMPLETED.
  • Credit usage is calculated as: total_deposits - remaining_credits.