Skip to content
SayGMDocs
Dashboard

Get credit balance

GET
/credits
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.

The API key’s current spendable balance. The response is never cacheable.

Media typeapplication/json
object
object
required
string
Allowed value: credit_balance
balance
required
object
usd
required

Exact decimal USD with nine fractional digits. Keep this as a decimal string when exact accounting matters.

string
/^[0-9]+\.[0-9]{9}$/
nano_usd
required

The same balance in SayGM’s native integer accounting unit: one nano-USD is 10^-9 USD.

integer
spent

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
usd
required

Exact decimal USD with nine fractional digits, same convention as CreditBalance.usd.

string
/^[0-9]+\.[0-9]{9}$/
nano_usd
required

The same spent figure in SayGM’s native integer accounting unit: one nano-USD is 10^-9 USD.

integer
Example
{
"object": "credit_balance",
"balance": {
"usd": "12.345678901",
"nano_usd": 12345678901
},
"spent": {
"usd": "1.200000000",
"nano_usd": 1200000000
}
}
Cache-Control
string
Allowed value: no-store

Always no-store.

Missing, malformed, revoked, or unknown SayGM API key.

Media typeapplication/json

OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.

object
error
required
object
message
required
string
type
required
string
code
required

Machine-readable error code. Account request limits use rate_limit_exceeded.

string
param
required
string | null
request_id

Gateway request identifier.

string
charged
boolean
billing_status
string
Allowed values: settled unbilled unknown
potentially_charged
boolean
cost_ndollars

Settled charge in nano-dollars; present when billing_status is settled.

integer
Example
{
"billing_status": "settled"
}
Cache-Control
string
Allowed value: no-store

Always no-store.

The authoritative credit service is unavailable; no stale balance is returned.

Media typeapplication/json

OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.

object
error
required
object
message
required
string
type
required
string
code
required

Machine-readable error code. Account request limits use rate_limit_exceeded.

string
param
required
string | null
request_id

Gateway request identifier.

string
charged
boolean
billing_status
string
Allowed values: settled unbilled unknown
potentially_charged
boolean
cost_ndollars

Settled charge in nano-dollars; present when billing_status is settled.

integer
Example
{
"billing_status": "settled"
}
Cache-Control
string
Allowed value: no-store

Always no-store.

Retry-After
integer
>= 1

Seconds to wait before retrying; present when the credit service supplies a delay.