Balance and usage
In the console
Section titled “In the console”- Account balance: the console home page or the Wallet page.
- Charges per request: the Logs page (/console/log). You can filter by token, model and time, and export the results.
- Token usage and remaining quota: the list on the Tokens page.
With your API key
Section titled “With your API key”The gateway provides two endpoints in the format of OpenAI’s legacy billing API. They accept an ordinary sk- token:
# Quota and expirycurl https://api.openpalmlab.com/v1/dashboard/billing/subscription \ -H "Authorization: Bearer sk-xxxx"
# Usagecurl https://api.openpalmlab.com/v1/dashboard/billing/usage \ -H "Authorization: Bearer sk-xxxx"Fields
Section titled “Fields”/v1/dashboard/billing/subscription returns:
| Field | Meaning |
|---|---|
soft_limit_usd / hard_limit_usd |
For a token with a quota: that token’s total quota (used + remaining). For an unlimited token: always the placeholder 100000000, which is not a balance. |
access_until |
Token expiry as a Unix timestamp in seconds. 0 means it never expires. |
/v1/dashboard/billing/usage returns:
| Field | Meaning |
|---|---|
total_usage |
Amount used, in hundredths of a US dollar. Divide by 100 to get dollars. |
Working out what is left
Section titled “Working out what is left”Token with a quota: remaining = soft_limit_usd − total_usage / 100Unlimited token: not available from these endpoints; check your balance in the consoleExample: soft_limit_usd = 100 and total_usage = 3500 means $35 used and $65 remaining.
Script example
Section titled “Script example”const base = 'https://api.openpalmlab.com';const headers = { Authorization: `Bearer ${process.env.OPENPALMLAB_API_KEY}` };
const sub = await fetch(`${base}/v1/dashboard/billing/subscription`, { headers }).then((r) => r.json());const usage = await fetch(`${base}/v1/dashboard/billing/usage`, { headers }).then((r) => r.json());
const total = sub.soft_limit_usd ?? sub.hard_limit_usd;const used = (usage.total_usage ?? 0) / 100;const unlimited = total >= 1e8;
console.log({ used, remaining: unlimited ? null : +(total - used).toFixed(4), unlimitedToken: unlimited, expiresAt: sub.access_until ? new Date(sub.access_until * 1000).toISOString() : 'never',});Low-balance alerts
Section titled “Low-balance alerts”When your balance drops below a threshold, the gateway sends a reminder. Choose how you are notified under Personal settings in the console.