API reference
Balance and usage
GET https://api.flyrouter.ai/v1/dashboard/billing/subscription
GET https://api.flyrouter.ai/v1/dashboard/billing/usage
Query this key's budget and spend using the key itself. The format matches OpenAI's legacy billing endpoints, so many clients (such as CC-Switch and balance-monitoring scripts) can use it as is. Amounts are in USD.
Get the budget
Terminal
curl https://api.flyrouter.ai/v1/dashboard/billing/subscription \
-H "Authorization: Bearer $FLYROUTER_API_KEY"json
{
"object": "billing_subscription",
"has_payment_method": true,
"soft_limit_usd": 20,
"hard_limit_usd": 20,
"system_hard_limit_usd": 20,
"access_until": -1
}| Field | Description |
|---|---|
hard_limit_usd | The key's total budget (remaining + spent), in USD. Keys without a spending limit always return 100000000 |
access_until | The key's expiry as a Unix timestamp; -1 means it never expires |
Get the spend
Terminal
curl https://api.flyrouter.ai/v1/dashboard/billing/usage \
-H "Authorization: Bearer $FLYROUTER_API_KEY"json
{
"object": "list",
"total_usage": 512.5
}total_usage is the total this key has spent, in cents (so the example above is $5.125).
Work out the remaining budget
balance.py
import os, requests
base = "https://api.flyrouter.ai"
headers = {"Authorization": f"Bearer {os.environ['FLYROUTER_API_KEY']}"}
total = requests.get(f"{base}/v1/dashboard/billing/subscription", headers=headers).json()["hard_limit_usd"]
used = requests.get(f"{base}/v1/dashboard/billing/usage", headers=headers).json()["total_usage"] / 100
if total >= 100000000:
print(f"This key has no spending limit; spent ${used:.2f}")
else:
print(f"Spent ${used:.2f}, remaining ${total - used:.2f}")Both endpoints report a single key. Check your account's total balance in the console. To monitor the balance from a script, give the key a spending limit and use the method above to compute what's left.