Spend caps and budgets
Limit what a connection, a job or an agent token can spend, and what Portal does when a limit is reached.
Warnings and limits
- Caps and budgets are off unless you set them. Set one only when you want a limit.
- A connection's cap is a hard limit: a machine whose worst-case cost would pass it is refused, and a running job is suspended when the cap would be reached.
- A job's budget acts a little early: when its cost plus 2 minutes of its machine's price would pass the budget.
- A job whose budget or cap is spent cannot be resumed or moved until you raise it.
- Costs are Portal's estimates. A provider's bill can differ, for example by disks and data transfer that quotes leave out.
- A budget must cover the machine's first lease (90 minutes) at the price the provider reserves, on EC2 spot the dearest zone's among those tried, or the launch is refused with the amount it could add.
- A cap counts each machine's lease ahead (1 hour; 90 minutes for a new machine). A Modal sandbox and a Fargate task count their lease; a Container Apps replica counts its whole 24-hour limit. A move from Modal or Container Apps counts the source for the move's window only.
Connection caps
A cap is a dollar amount for one connection. Set it when you connect, or change it later:
portal connect aws --from-cli --cap 200The console's Connections page, and the MCP tool set_cap, change a cap without touching the credentials. A cap is any amount from $0; $0 is a real limit. AWS EC2 and Fargate share their connection's cap.
Before a machine starts, Portal adds its worst case (its price over its first lease, 90 minutes, or the provider's minimum billing) to what the connection has spent and committed. If that would pass the cap, the machine is refused with a message such as:
aws: spent $182.40, committed $10.00, this resource could add $12.60, cap $200.00While a job runs, its machine's hard stop is kept about an hour ahead and renewed every 10 minutes, but only as far as the cap pays for. When the cap would be reached, the job is suspended; raise the cap to resume it. If the suspension fails, the job is stopped.
Job budgets
portal run train.py --on SPEC --project training --budget 25A budget is a limit for one job, in US dollars. When the job's cost plus 2 minutes of its machine's price would pass it, Portal suspends the job and releases its machine. A budget suspension that fails stops the job. A job whose budget is spent is refused a resume or a move.
The budget policy can stop the job instead of suspending it (budget.action), and act earlier (budget.margin_min). An Owner can also set a default budget for jobs that set none. See Settings.
On a provider whose machines stop at a fixed limit (Azure Container Apps), the machine's limit is set to what the budget pays for, and that whole span is reserved from the budget up front while the job runs there: a move away is admitted only within the move's window. The plan's warnings and the job's first event say so with the numbers ("on aca the job's budget reserves $2.00 of $2.00 up front, for the machine's limit of 4.0 h at $0.500/h"). Modal holds the machine's lease instead, so nothing is reserved beyond it.
Agent token budgets
An agent token can carry a budget. It applies to each job the token starts, not to all of them together: a job started with the token cannot set a larger budget or turn the budget policy off. See Sign in.
Nothing left running
- Every machine has a hard stop that Portal keeps renewing. If Portal stops renewing it, the machine ends itself.
- Portal checks every minute for machines past their lease or whose job has ended, and ends them 2 minutes later.
portal auditlists everything Portal runs on every connection and what leaked. An Owner cleans up leaks from the console's Machines page.