Docs / API reference

Spend limits, budgets and balance

Updated 2026-11-22. Published by PentestLLM.

Put the ceilings in place before a scanner or agent runs unattended. Limits live on each key, so you set them through the key routes, and under https://api.pentestllm.ai/v1 two read-only routes report what the organization can still spend while a third, kept for older clients, always answers zero. A fourth prices a request on every model without sending it. The OpenAPI document has no separate budget route.

Routes

RouteCredentialStatuses
GET /v1/creditsAPI key200, 401
GET /v1/dashboard/billing/subscriptionAPI key200, 401
GET /v1/dashboard/billing/usageAPI key200, 401
POST /v1/estimatenone, or an API key200, 400, 401, 413

The three balance reads fall back on the document-wide credentials, meaning any ordinary key sent the way your SDK already sends it. On console sessions for them, the OpenAPI document does not say either way. The estimate also runs with no credential at all. Limits are written with an admin key through POST /v1/keys and PATCH /v1/keys/{key_id}, whose statuses are on Keys and scopes.

Settings on a key

You write dollars; a key reads back in micro-dollars, a millionth of a dollar each. On a PATCH, null clears a cap.

WriteRead back asBehaviour
monthly_cap_usdmonthly_spend_limit_micro, period_spend_microA recurring dollar cap. Despite the name, it applies to whatever spend_limit_period says.
spend_limit_periodspend_limit_perioddaily restarts at 00:00 UTC, weekly at Monday 00:00 UTC, monthly (the default) on the first of the UTC month.
budget_usdbudget_micro, budget_spent_micro, budget_remaining_microA prepaid allowance for this key. Its charges plus open holds are checked against it, and the organization balance is still what pays.
user_budget_usduser_budget_microA cap per end user on this key; only the user who reaches it is stopped.
user_budget_perioduser_budget_perioddaily, weekly or monthly, monthly unless set.
session_max_requestssession_max_requestsCalls per session in any sliding hour, 1 to 100,000.
session_max_spend_usdsession_max_spend_microDollars per session per UTC day.
loop_guardloop_guardRefuses a session’s sixth identical tool call or identical body inside 10 minutes.
concurrencyconcurrency_limitCalls in flight at once. Independent of any dollar cap.

A budget cannot be lowered under what the key has spent against it (400 budget_below_spent). Clearing it with null removes it; setting one again starts its count from zero. To watch a key approach its limits, read its usage on Usage and receipts.

What a model call gets once a cap is hit

These come back from model routes, never from the balance reads. 402 carries monthly_limit_reached, weekly_limit_reached or daily_limit_reached for the recurring cap, key_budget_exhausted for the key budget, user_budget_reached for one end user, insufficient_balance when the organization is out of funds, and spend_cap_reached for a new account whose first payment has not settled. 429 carries session_cap, loop_detected or rate_limited.

Read the balance

None of the three takes a body or a parameter. GET /v1/credits returns data.total_credits, the available balance in dollars after subtracting what in-flight requests hold, and data.total_usage, which is always 0. GET /v1/dashboard/billing/subscription returns object, has_payment_method (always true), soft_limit_usd, hard_limit_usd and system_hard_limit_usd, all three equal to that same available balance rather than a recurring quota, and access_until, the key’s expiry in Unix seconds or 0 for none. GET /v1/dashboard/billing/usage returns object list and total_usage 0, for compatibility only. A failed credential is 401 invalid_api_key.

Estimate before sending

POST /v1/estimate takes input_tokens, or text to count in any mix of prompt, system and messages; output_tokens, 1000 when omitted; and an optional models list to narrow the answer. Text is counted at four characters a token plus four per message. The reply states prices (public, or your organization when a key was sent), the token counts, a basis line, and data, cheapest first, with each model’s cost_usd, list_cost_usd, saved_usd and saved_pct. No model is called and nothing is charged, and real token counts can differ. Errors: 400 invalid_request for nothing to count or a bad models list, 401 invalid_api_key when a key was sent and fails, 413 invalid_request for an oversized body.

Example

shell
1curl "https://api.pentestllm.ai/v1/credits" \
2 -H "Authorization: Bearer sk-ptl-live-…"

Questions

Does monthly_cap_usd only work per month?

No. Its sibling spend_limit_period picks the reset: each UTC day, each week from Monday, or each UTC month, which is the default.

Can billing/usage show what I spent last month?

No. It returns zero on purpose, so balance clients written for another provider keep working. For history, read key usage, request records or the usage CSV.

Does a key budget hold money apart from my balance?

No. It is a ceiling on one key. Every charge is still taken from the organization’s prepaid balance, and the budget stops the key once its charges plus open holds reach it.

Join on TelegramHelp