Get credit balance
const url = 'https://api.saygm.com/v1/credits';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://api.saygm.com/v1/credits \ --header 'Authorization: Bearer <token>'Returns the current spendable prepaid balance for the authenticated SayGM API key. This is a SayGM endpoint, not part of the OpenAI API. The read is authoritative rather than TTL-cached, so external top-ups are visible immediately.
Authorizations
Section titled “Authorizations”Responses
Section titled “Responses”The API key’s current spendable balance. The response is never cacheable.
object
object
Exact decimal USD with nine fractional digits. Keep this as a decimal string when exact accounting matters.
The same balance in SayGM’s native integer accounting unit: one nano-USD is 10^-9 USD.
This key’s consumption in the current billing period (period-to-date, not lifetime spend). The field is omitted when no per-key consumption figure is available; absence means unknown, never zero.
object
Exact decimal USD with nine fractional digits, same convention as CreditBalance.usd.
The same spent figure in SayGM’s native integer accounting unit: one nano-USD is 10^-9 USD.
Example
{ "object": "credit_balance", "balance": { "usd": "12.345678901", "nano_usd": 12345678901 }, "spent": { "usd": "1.200000000", "nano_usd": 1200000000 }}Headers
Section titled “Headers”Always no-store.
Missing, malformed, revoked, or unknown SayGM API key.
OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.
object
object
Machine-readable error code. Account request limits use rate_limit_exceeded.
Gateway request identifier.
Settled charge in nano-dollars; present when billing_status is settled.
Example
{ "billing_status": "settled"}Headers
Section titled “Headers”Always no-store.
The authoritative credit service is unavailable; no stale balance is returned.
OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.
object
object
Machine-readable error code. Account request limits use rate_limit_exceeded.
Gateway request identifier.
Settled charge in nano-dollars; present when billing_status is settled.
Example
{ "billing_status": "settled"}Headers
Section titled “Headers”Always no-store.
Seconds to wait before retrying; present when the credit service supplies a delay.