Credits, budgets and limits
Credits and cost_micro
A credit is $0.001 (1,000 µ$). What you set and read in limits, grants, budgets and balances is in credits (period_credit_cap, budget.run_credits). What something actually cost is cost_micro, in millionths of a dollar, on a run, an action's receipt and a usage row: cost_micro: 432 is 0.432 credits. A usage row carries both: credits, rounded up, and the exact cost_micro. A run carries both too, its credits exact (cost_micro / 1000, so 0.432), so you can add runs up. A usage row's cost_micro is its window's runs added up, plus any work that belongs to no run (memory upkeep, voice transcription). A running run reads what it has spent so far, and when one reply answered several of your user's messages at once, the earliest run carries the whole charge and the others read 0.
Where credits come from
Your organization has one credit pool per mode. Workspaces spend from it, inside their own limits. In test mode a free monthly allowance funds the pool, and no money moves.
Each workspace that runs holds a float. A run spends from its workspace's float, not from the pool. When a workspace needs credits, it takes a refill out of the pool: 2 runs' holds (a run's hold is its budget.run_credits), then 2, 4, 8 and at most 10 as it keeps running in the period. So GET /balance's available drops when a refill moves into a workspace, not as runs spend, and in_workspaces is what workspaces hold. What a workspace hasn't spent goes back to the pool when its period ends, when it has started no run for 8 days, or when you archive it (POST /workspaces/{id}/archive). In test mode, this is why the allowance can look used up after little spend: the workspaces that ran are holding it.
What one run may spend: budget.run_credits
A run starts only once it can set aside its template's whole budget.run_credits from the workspace, and gives back what it doesn't use. One that can't yet waits, or is refused (When credits run out).
-
Once a run starts, the workspace cap never cuts it off. A run that spends its whole budget stops with
run_budget_exhausted, a sign the budget is too small for the work: raise it in the template. -
Above 0, it must be at least the floor of the template's costliest model tier: 10 credits for
fast. A version below its floor is refused withparameter_invalidonbudget.run_credits, and the message names the floor. -
Set it. Without it (or at 0), a run sets aside the per-run ceiling of the dearest tier it may reach: 250 credits for
reasoningand 1,000 credits ($1.00) forfrontier, many times what most runs spend. A tier your end customers may move an agent to (customizable.model_tier.allowed) counts, so a workspace's caps must cover it before anyone moves one. A workspace with less than that left runs nothing.npx openlegion devwarns when it pushes a template that allowsfrontierwith nobudget.run_credits. -
A budget per preset. When people may pick a preset (
customizable.model_tier.allowed), one number either starves the slower, more thorough preset or holds too much for the quick one.budget.run_creditsmay instead be a map,{ fast: 40, reasoning: 250 }: a run holds, and stops at, the entry of the preset it starts on, a person's pick included. A preset left out, or at 0, holds its ceiling. Each entry above 0 must be at least its preset's floor (10 forfast, 50 forreasoning, 200 forfrontier), and each key a preset an agent is on or a person may pick; a version that breaks either is refused withparameter_invalidon that entry (budget.run_credits.reasoning). -
When a run stops at its budget, the person is told to say "continue" only when a new run could get on with it. When the conversation alone would take half of the next run's budget, they're told that continuing would stop again, and what helps instead. When a limit would refuse the next run, they're told which one and when it resets. The run's
partner_messagesays which it was.
Measured in November 2026: one live run of eight ordinary tasks (web research, a report as a file, a PDF, an email, a schedule, a saved key), each done once on each preset. On
reasoning, the heavier tasks used about 80 to 150 credits, and a budget of 100 stopped two of the eight before they finished. Onfast, every task finished at 40 credits or under. So leavingreasoningat its ceiling (250: leave it out of the map, or set 0) is the safe default.
npx openlegion init's template sets budget: { run_credits: 10 }.
What one customer may spend: workspace limits
Each workspace has a period cap and an optional daily cap:
await ol.workspaces.limits.update(ws.id, { period_credit_cap: 5_000, daily_credit_cap: 500 });
cap_mode: "hard"(the default) refuses new runs at the cap;"soft"allowssoft_overage_pctmore and reports it as overage.period_anchorsets when the monthly period renews, like a billing cycle anchor. The default is the workspace's creation time.- Start a customer's month on the day they buy: send the subscription's billing anchor as
period_anchorwithperiod_restart: trueon every sync. The month starts there if it has not; if the workspace is already on that cycle, nothing changes. - A workspace created without limits takes the template's
default_limits. GET /workspaces/{id}reportscredits_used,credits_reservedandcredits_remaining, fresh from the ledger, so you can show "credits left" from it directly.
A one-off top-up moves credits from your pool into the workspace, spent after its period allowance:
await ol.workspaces.creditGrants.create(ws.id, { credits: 1_000, expires_at: "2027-01-31T00:00:00Z" });
What is left of a grant returns to the pool when it expires, or when the workspace is archived or erased.
Both calls need a key with the limits:write scope. The key npx openlegion init wrote doesn't have it, on purpose: it sits in your app's .env.local, and a leaked one must not be able to raise a cap or grant credits. It can read usage (usage:read). To change limits from your server, make a key with limits:write on the console's Keys page and use it for these calls (Keys and your team).
What one agent may do in a day
Each agent also has two limits over any 24 hours, from its template: budget.agent_daily_run_cap (runs) and budget.agent_daily_credit_cap (credits). A run past one is refused 402 cap_reached when it is created, and its partner_message names the field to raise. The agent runs again as its earlier runs pass 24 hours.
- The daily credit cap admits a run while the agent is under it. A run sets nothing aside against this cap, so a run that starts under it finishes, and the agent's last 24 hours can end above the cap by what the runs then in flight spend. The next run is refused.
When credits run out
A run that can't set aside its budget only because runs in flight still hold credits isn't refused. It waits (the stream's data-queued part, reason workspace_busy), holds nothing while it waits, and starts when they finish and give back what they didn't use.
A run that wouldn't fit even with nothing in flight is refused before it starts: 402 cap_reached (a workspace cap, and workspace.cap_reached fires) or 402 credits_exhausted (the pool). A run that waits too long gets the same refusal then, and reads failed with its code. Your user sees a sentence written for them; the error's partner_message tells you which cap and what to do.
Late corrections
What a model call cost can be corrected after its run has ended, when the model vendor reports the final price. A correction is booked when it arrives, in the period and the day it arrives in, even when that takes the workspace or the agent past a cap: a cap decides which runs start, not what a finished run cost. A correction upward takes at most what the workspace still holds, and what that doesn't cover isn't charged. A correction downward is always booked in full.