Skip to main content

Balance and deductions

LLMTune uses a prepaid balance (your “wallet”), measured in USD. You add funds up front, and usage outside your Coding Plan quota — inference on non-plan models, embeddings, fine-tuning, and Agent requests — is deducted from your wallet in real time. There are no end-of-cycle invoices; you only pay for what you use.
If you subscribe to a Coding Plan, requests against your plan’s included GLM models consume your request quota, not your wallet. Your wallet is only charged for usage outside the plan — non-plan models, fine-tuning, and embeddings. See Deposit funds for the deposit flow.
Because billing is prepaid, a request only runs if your balance can cover it. If it can’t, you get a 402 Payment Required instead of the response — see What happens when balance runs out.

How balance is used

WorkloadHow it charges
Inference (/v1/chat/completions)Per request, based on input + output tokens.
Embeddings (/v1/embeddings)Per request, based on input tokens.
Fine-tuning (/api/training)Per GPU hour, billed while the job runs (not while queued).
Agent (/api/agent/v1/...)Per request / per step, like inference.
To add funds, see Deposit funds. To track what’s been spent, see Billing & usage.

How deductions work

  1. When you call inference, embeddings, or the Agent, the platform:
    • Validates your API key.
    • Checks that your balance is sufficient (using an estimate or actual cost).
    • If sufficient — runs the request, computes usage (tokens), and deducts the cost from your balance.
    • If insufficient — returns 402 Payment Required and does not run the request or deduct anything.
  2. For fine-tuning, the job is billed per GPU hour while it runs. Insufficient balance can prevent the job from starting or cause it to fail — so fund the account before launching large jobs.
  3. Failed requests are not charged. If a request errors (4xx/5xx), no tokens are billed. Only successful completions are deducted.
Every request outside your Coding Plan quota — including free / Confidential (own-your-data) models, fine-tuning, embeddings, and non-plan models — is checked against your wallet balance first. A $0.00 balance returns 402 regardless of model tier. Requests against your plan’s included models consume quota, not wallet. See Coding Plans.

What happens when balance runs out

When your balance can’t cover a request, the API returns 402 Payment Required with this body:
{
  "error": "Insufficient balance",
  "message": "Insufficient balance. Required: $0.0012, Available: $0.0000"
}
  • Meaning — Your balance is too low for this request (or its estimated cost).
  • What to do — Add funds in the dashboard at Deposit funds, then retry. In your app, surface a clear message (e.g. “Add funds”) and link to billing.

Handling 402 in code

Treat 402 as a billing issue, not a transient failure. Don’t retry the same request in a loop — it will keep failing until the balance is topped up.
from openai import OpenAI, APIStatusError

client = OpenAI(base_url="https://api.llmtune.io/v1", api_key="sk_YOUR_API_KEY")

try:
    response = client.chat.completions.create(
        model="z-ai/GLM-5.2",
        messages=[{"role": "user", "content": "Hello"}],
    )
except APIStatusError as e:
    if e.status_code == 402:
        # Stop and ask the user to add funds — don't auto-retry.
        print("Balance too low. Please add funds at https://llmtune.io/billing.")
    else:
        raise

Best practices

  • Monitor balance — Track spend on the Usage dashboard and top up before it hits zero.
  • Handle 402 explicitly — Catch it in code, prompt the user to add funds, and do not retry until balance is updated.
  • Estimate before batch — For large batch or fine-tuning jobs, check balance first so you don’t start work that will fail mid-way.
  • Fund before fine-tuning — Training is billed per GPU hour; ensure enough balance for the whole run.
  • Watch for unexpected drain — A sudden balance drop often means a loop or runaway job. Check audit logs and usage by model/endpoint.

Next