Billing & usage
Usage is metered by tokens and cost. This page explains how usage is calculated, where you can see it, and how it connects to your balance.Most usage is deducted from your prepaid wallet in real time. If you subscribe to a Coding Plan, requests against your plan’s included GLM models consume your request quota instead — your wallet is only charged for usage outside the plan (non-plan models, fine-tuning, embeddings). See Deposit funds and Balance and deductions.
How usage is calculated
| Workload | How it’s metered | Unit |
|---|---|---|
Inference (/v1/chat/completions) | Input + output tokens per request | tokens |
Embeddings (/v1/embeddings) | Input tokens per request (only RedPill embedding models, e.g. qwen/qwen3-embedding-8b) | tokens |
Fine-tuning (/api/training) | Billed per GPU hour while the job runs (not while queued) | GPU hours |
Agent (/api/agent/v1/...) | Per request / per step, metered like inference (input + output tokens) | tokens |
Token accounting
Inference and Agent responses report ausage object (OpenAI-compatible):
| Field | What it counts |
|---|---|
prompt_tokens (input) | Tokens in the prompt or message list. |
completion_tokens (output) | Tokens in the generated completion. |
total_tokens | Input + output. |
| Cache read/write | When supported and reported by the model; may be priced separately. |
| Reasoning | When supported (e.g. chain-of-thought); may be reported separately. |
usage object is what is metered and deducted from your balance.
Where you see usage
- Dashboard — The Usage or Billing section shows token counts, cost over time, and breakdowns by model or endpoint. Go to Account & settings → Usage in the dashboard (wallet balance and token usage over the last 30 days).
- API — Query usage programmatically:
balanceUsd and daily token counts (tokens30d). To check Coding Plan quota usage specifically, see GET /api/subscriptions/current.
A sudden cost spike usually means a loop, a runaway batch, or a misconfigured
max_tokens. Filter usage by model/endpoint in the dashboard, then check audit logs to trace the source.How usage connects to balance
- You top up your wallet via the dashboard — see Deposit funds.
- Each successful request outside your Coding Plan quota — inference on non-plan models, embeddings, fine-tuning, or the Agent — deducts from your wallet based on the usage above. Requests against your plan’s included models consume quota instead.
- If your wallet can’t cover a non-quota request, the API returns 402 Payment Required. Add funds and retry.
402 response shape and how to handle it in code.
Next
- Deposit funds — How to add funds and the deposit flow.
- Balance and deductions — Deduction model, the
402response, and handling it in code. - Usage Metering — Metrics captured across products (inference, training, deployment).
- API endpoints — The endpoints that consume balance.