Credit usage & balance
Retrieves your account’s credit information, including remaining credits, total usage, and total deposits.
Get remaining credits
Section titled “Get remaining credits”Example
Section titled “Example”curl "https://api.imagerouter.io/v1/credits" \-H "Authorization: Bearer YOUR_API_KEY"const url = 'https://api.imagerouter.io/v1/credits'const response = await fetch(url, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' }})const data = await response.json()console.log(data)import requests
url = "https://api.imagerouter.io/v1/credits"headers = { "Authorization": "Bearer YOUR_API_KEY"}
response = requests.get(url, headers=headers)print(response.json())Response Example
Section titled “Response Example”{ "remaining_credits": "25.5000", "credit_usage": "4.5000", "total_deposits": "30.0000"}Detailed Usage by API Key
Section titled “Detailed Usage by API Key”You can retrieve a breakdown of usage for each of your API keys by adding the by_api_key=true query parameter.
Example
Section titled “Example”curl "https://api.imagerouter.io/v1/credits?by_api_key=true" \-H "Authorization: Bearer YOUR_API_KEY"const url = 'https://api.imagerouter.io/v1/credits?by_api_key=true'const response = await fetch(url, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' }})const data = await response.json()console.log(data)import requests
url = "https://api.imagerouter.io/v1/credits"params = { "by_api_key": "true"}headers = { "Authorization": "Bearer YOUR_API_KEY"}
response = requests.get(url, headers=headers, params=params)print(response.json())Response Example
Section titled “Response Example”{ "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 }, { "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 } ]}Error Response
Section titled “Error Response”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.