Skip to content
Docs

API reference

Credits

Two endpoints read what your account and your key have spent, as OpenRouter's do. They cost nothing and only need your key. Use them to warn yourself before a request fails with 402 insufficient_balance.

Balance: GET /v1/credits

What the account of the key has loaded and spent, in dollars. Your balance is total_credits minus total_usage. Try it in the Playground.

curl https://api.libremodel.ai/v1/credits \
  -H "Authorization: Bearer $LIBREMODEL_API_KEY"
JSON
{ "data": { "total_credits": 25, "total_usage": 3.4182 } }
FieldDescription
data.total_creditsEverything loaded: top-ups and adjustments.
data.total_usageEverything spent, by every key of the account.

Your key: GET /v1/key

The key you call with, its spending limit and what it spent. Try it in the Playground.

curl https://api.libremodel.ai/v1/key \
  -H "Authorization: Bearer $LIBREMODEL_API_KEY"
JSON
{
  "data": {
    "label": "sk-libremodel-...a3f9",
    "limit": 50,
    "limit_remaining": 41.25,
    "limit_reset": "monthly",
    "usage": 112.4,
    "usage_daily": 1.1,
    "usage_weekly": 4.35,
    "usage_monthly": 8.75,
    "is_free_tier": false
  }
}
FieldDescription
labelThe key, masked.
limitIts spending limit, in dollars, per window. null when it has none.
limit_remainingWhat is left of the limit in the current window. null when it has no limit.
limit_resetWhen the limit starts over: daily, weekly, monthly, or null if never.
usageSpent by this key, in total.
usage_daily, usage_weekly, usage_monthlySpent today, since Monday and since the 1st.
is_free_tiertrue if the account has never loaded credits.

Amounts are in dollars and windows are in UTC. Spending limits are set per key in API keys.

Errors

Without a valid key both return 401 invalid_api_key. If the totals can't be read for a moment they return 503 upstream_unavailable with Retry-After: retry after that wait.