putty
API ReferenceLedger

Estimate what a build run will cost and what it is capped at

The estimate the Build composer shows next to the prompt: what this prompt text and this project's current size are expected to cost, and the hard cap the run will stop at. The run is metered as it goes and charges step by step, so this is an estimate and the cap is a promise — the run checkpoints and ends with `budget.exhausted` rather than billing past the cap. `affordable: false` is the early warning that precedes the 402.

GET
/billing/estimate

The estimate the Build composer shows next to the prompt: what this prompt text and this project's current size are expected to cost, and the hard cap the run will stop at. The run is metered as it goes and charges step by step, so this is an estimate and the cap is a promise — the run checkpoints and ends with budget.exhausted rather than billing past the cap.

affordable: false is the early warning that precedes the 402.

Query Parameters

prompt*string

The prompt text about to be sent.

Length1 <= length <= 20000
projectId?string

The project the run will execute against, for the size term.

cap?integer

Override the default cap. A caller may raise it; a run never bills past whatever cap it has.

Range1 <= value <= 10000

Response Body

application/json

application/json

application/json

application/json

curl -X GET "https://example.com/billing/estimate?prompt=string"
{  "runEstimate": {    "promptCredits": 0,    "projectCredits": 0,    "total": 0,    "cap": 0  },  "balance": {    "allowance": 0,    "purchased": 0,    "total": 0  },  "affordable": true}