Skip to content

BillingCaps and approvals

Docs

Billing

Caps and approvals

An agent spends from your wallet, so you decide how much, how fast and what needs your yes. Set the limits once; they hold for every client.

Monthly spend cap#

Set it on the billing page, in credits. The month starts on the 1st, in UTC. A call that would take the month's spend past the cap, counting what running calls hold, is refused before it runs with spend-cap-reached (HTTP 403) and a limits_url.

Cap per API key#

Each API key can have its own monthly cap, set when you create it. A call that would pass it is refused with spend-cap-reached. The wallet's own cap applies as well.

Approvals#

A call that may cost more than the approval threshold waits for your yes. The threshold starts at 1,000 credits and you change it on the billing page. Article writing always asks.

  1. The call answers HTTP 428 approval-required with the estimate and a confirmation_token.
  2. The agent asks you.
  3. On a yes, it calls again with the same arguments and the token. The token works for 15 minutes, for that call only.
428 approval-required
{
  "type": "https://trysnow.ai/errors#approval-required",
  "title": "Approval required",
  "status": 428,
  "detail": "This call costs 2,000 credits ($2) and takes a few minutes. Ask the user, then call again with confirmation_token.",
  "estimate_credits": 2000,
  "estimate_usd": 2,
  "approval_threshold_credits": 1000,
  "approval_threshold_usd": 1,
  "confirmation_token": "1760608800.Qm9n...",
  "expires_in_seconds": 900
}

Per call#

max_credits caps one call. List tools return fewer items to fit it. A value below the least a useful call costs is refused with max-cost-too-low, and minimum_credits says what it needs.

dry_run: true returns the price and your balance without running anything. cached: true means the answer would come from the cache.

Dry run
{
  "dry_run": true,
  "price_credits": 5,
  "price_usd": 0.005,
  "cached": false,
  "balance_credits": 9995,
  "balance_usd": 9.995,
  "available_credits": 9995,
  "available_usd": 9.995,
  "cost_credits": 0,
  "cost_usd": 0
}

An empty wallet#

A call the wallet cannot cover answers HTTP 402 and nothing is charged. Errors and limits shows the answer and what to do.