Home / Docs / API reference
/v1/credits
GET /v1/credits
Authentication relay key (bearer)
Example request
curl
curl https://api.massrelay.ai/v1/credits \
-H "Authorization: Bearer $RELAY_KEY"Python
import os, requests
r = requests.get(
"https://api.massrelay.ai/v1/credits",
headers={"Authorization": f"Bearer {os.environ['RELAY_KEY']}"},
)
r.raise_for_status()
print(r.json())TypeScript
const r = await fetch("https://api.massrelay.ai/v1/credits", {
method: "GET",
headers: { Authorization: `Bearer ${process.env.RELAY_KEY}` },
});
if (!r.ok) throw new Error(`${r.status} ${await r.text()}`);
console.log(await r.json());Response
| Field | Type | Description |
|---|---|---|
object required | string | The kind of object returned, for example chat.completion. Always "credits". |
unit required | string | Always "mu". |
displayCurrency required | string or null | |
totalBalanceMu required | integer | micro-dollars, the unit of account |
totalAvailableMu required | integer | micro-dollars, the unit of account |
wallets required | array of object | |
wallets[].id required | string | The answer's id. |
wallets[].kind required | object | One of: prepaid, allowance, grant, pool, sponsor. |
wallets[].balanceMu required | integer | micro-dollars, the unit of account |
wallets[].heldMu required | integer | micro-dollars, the unit of account |
wallets[].availableMu required | integer | micro-dollars, the unit of account |
wallets[].currency required | string or null | |
wallets[].expiresAt required | string or null | |
freeAllowanceLeft required | integer or null | requests left in this month's free allowance; null when the plan has none |
freeAllowance required | object or null | |
freeAllowance.meter | string | |
freeAllowance.plan | string or null | |
freeAllowance.allowance | integer | |
freeAllowance.used | integer | |
freeAllowance.resetsAt | string |
Example response (shape)
{
"object": "credits",
"unit": "mu",
"displayCurrency": "<displayCurrency>",
"totalBalanceMu": 0,
"totalAvailableMu": 0,
"wallets": [
{
"id": "<id>",
"kind": "prepaid",
"balanceMu": 0,
"heldMu": 0,
"availableMu": 0,
"currency": "<currency>",
"expiresAt": "<expiresAt>"
}
],
"freeAllowanceLeft": "<freeAllowanceLeft>",
"freeAllowance": {
"meter": "<meter>",
"plan": "<plan>",
"allowance": 0,
"used": 0,
"resetsAt": "<resetsAt>"
}
}Common errors
401invalid_api_key403insufficient_scope429over the request rate; read Retry-After
Every error has the same JSON shape; see Errors and Limits.
Full schema (JSON)
Response schema
{
"description": "The wallets are the key's workspace's own (owner kind workspace).",
"type": "object",
"required": [
"object",
"unit",
"displayCurrency",
"totalBalanceMu",
"totalAvailableMu",
"wallets",
"freeAllowanceLeft",
"freeAllowance"
],
"properties": {
"object": {
"const": "credits"
},
"unit": {
"const": "mu"
},
"displayCurrency": {
"type": [
"string",
"null"
]
},
"totalBalanceMu": {
"type": "integer",
"description": "micro-dollars, the unit of account"
},
"totalAvailableMu": {
"type": "integer",
"description": "micro-dollars, the unit of account"
},
"wallets": {
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"kind",
"balanceMu",
"heldMu",
"availableMu",
"currency",
"expiresAt"
],
"properties": {
"id": {
"type": "string"
},
"kind": {
"enum": [
"prepaid",
"allowance",
"grant",
"pool",
"sponsor"
]
},
"balanceMu": {
"type": "integer",
"description": "micro-dollars, the unit of account"
},
"heldMu": {
"type": "integer",
"description": "micro-dollars, the unit of account"
},
"availableMu": {
"type": "integer",
"description": "micro-dollars, the unit of account"
},
"currency": {
"type": [
"string",
"null"
]
},
"expiresAt": {
"type": [
"string",
"null"
]
}
}
}
},
"freeAllowanceLeft": {
"type": [
"integer",
"null"
],
"description": "requests left in this month's free allowance; null when the plan has none"
},
"freeAllowance": {
"type": [
"object",
"null"
],
"properties": {
"meter": {
"type": "string"
},
"plan": {
"type": [
"string",
"null"
]
},
"allowance": {
"type": "integer"
},
"used": {
"type": "integer"
},
"resetsAt": {
"type": "string"
}
}
}
}
}