Get credit balance
GET
/credits
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 GM API key. This is a GM-native 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.
Media typeapplication/json
object
object
required
string
balance
required
object
usd
required
Exact decimal USD with nine fractional digits. Keep this as a decimal string when exact accounting matters.
string
nano_usd
required
The same balance in GM’s native integer accounting unit: one nano-USD is 10^-9 USD.
integer
Example
{ "object": "credit_balance", "balance": { "usd": "12.345678901", "nano_usd": 12345678901 }}Headers
Section titled “Headers”Cache-Control
string
Always no-store.
Missing, malformed, revoked, or unknown GM API key.
Media typeapplication/json
object
error
object
message
string
type
string
code
string | null
Examplegenerated
{ "error": { "message": "example", "type": "example", "code": "example" }}Headers
Section titled “Headers”Cache-Control
string
Always no-store.
The authoritative credit service is unavailable; no stale balance is returned.
Media typeapplication/json
object
error
object
message
string
type
string
code
string | null
Examplegenerated
{ "error": { "message": "example", "type": "example", "code": "example" }}Headers
Section titled “Headers”Cache-Control
string
Always no-store.