Generate

Account and Billing

Check your balance and what you've spent.

Balance

GET /api/v0/billing/account returns your balance and how many of your tasks are queued and running right now, so you can pace submissions against your account's concurrency limit.

Request

curl -H "Authorization: Bearer $MACHGEN_API_KEY" \
  https://api.machgen.ai/api/v0/billing/account

It takes no parameters.

Response

{
  "account_id": "acct-abc123",
  "balance_micros": 12500000,
  "autoreload_enabled": false,
  "pending_tasks": 2,
  "running_tasks": 1
}
FieldTypeRequiredDefaultDescription
account_idstrYes-ID of this account
balance_microsintYes-Balance of this account (in microdollars)
autoreload_enabledbool-FalseIf auto-reload is enabled on this account
pending_tasksint | None-NoneCurrent number of scheduled but not running tasks under this account
running_tasksint | None-NoneCurrent number of running tasks under this account

Usage

GET /api/v0/billing/usage shows how many tasks you ran, how they went, and what they cost, by day or by hour.

Request

curl -H "Authorization: Bearer $MACHGEN_API_KEY" \
  "https://api.machgen.ai/api/v0/billing/usage?since=2026-10-01&until=2026-10-08"

Parameters

ParameterDefaultDescription
since7 days before untilStart date or time. UTC unless you add an offset.
untilNowEnd date or time, not included.
granularitydayday or hour.
api_keyAll keys combinedOne key's ID, as shown on your API keys page.

since and until round out to whole days or hours in UTC, and one request covers up to 31 days.

Response

{
  "api_key": null,
  "granularity": "day",
  "since": "2026-10-01T00:00:00Z",
  "until": "2026-10-08T00:00:00Z",
  "as_of": "2026-10-08T04:00:12Z",
  "tracked_since": null,
  "rows": [
    {
      "time": "2026-10-01T00:00:00Z",
      "model": "MiniMax-H3",
      "task_type": "T2V",
      "tasks": 12,
      "succeeded": 11,
      "failed": 1,
      "cost_micros": 3850000
    }
  ]
}
FieldTypeDescription
api_keystring or nullThe key you asked about, or null for all keys combined.
granularitystringday or hour.
sincestringStart of the period covered, UTC.
untilstringEnd of the period covered, UTC, not included.
as_ofstring or nullWhen usage was last updated. It updates hourly. null until the first update.
tracked_sincestring or nullWith api_key, when we started recording usage per key. Earlier tasks only count toward all keys.
rowsarrayOne row per model and task type in each day or hour. Periods with nothing to report are left out.
rows[].timestringStart of the day or hour, UTC.
rows[].modelstringModel ID.
rows[].task_typestringTask type, like T2V. Live sessions show as LIVE, in the all-keys report only.
rows[].tasksintegerTasks you submitted, including ones still running.
rows[].succeededintegerTasks that finished successfully.
rows[].failedintegerTasks that failed.
rows[].cost_microsintegerCost in millionths of a dollar, after refunds. A task counts when you submitted it, even if it was refunded later.

Error Codes

StatusWhenExample detail
400 Bad RequestUsage range is over 31 days, or until isn't after since.The range can be at most 31 days
401 UnauthorizedMissing, malformed, or unknown API key.Invalid API key
404 Not Foundapi_key isn't one of your keys.API key not found
422 Unprocessable EntityA usage parameter can't be read, like granularity=week or a bad date.A list naming each bad parameter
429 Too Many RequestsToo many requests. Slow down and retry.Rate limit exceeded; please slow down and retry.
503 Service UnavailableUsage data is briefly unavailable. Retry after Retry-After seconds.Usage data is temporarily unavailable. Please try again later.