Budget is a first-class concept in Zap — every recipe must declare both an estimated cost and a hard spending ceiling before any provider call is made. This makes cost visible and controllable at authoring time, not after the bill arrives. The budget block is validated at parse time, quoted again at plan time, and enforced a final time on the server before provider submission, giving creators three independent opportunities to catch runaway spend before it happens.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/gratitude5dee/Zap/llms.txt
Use this file to discover all available pages before exploring further.
The Budget Block
estimate_usd— the author’s pre-run cost estimate, calculated by summingquoteStep()across all planned steps. Must be a non-negative number and must not exceedcap_usd.cap_usd— the hard spending ceiling. Any run whose live quote exceeds this value is rejected before a single provider call is made.
Enforcement Points
Budget enforcement happens at four distinct points in the Zap lifecycle: 1. CLI mock runs always quote $0.00 When running without--live, Zap executes in mock mode. All provider steps return deterministic zero-cost outputs. The planner still builds a full plan and prints the quote, but no real money is spent and no budget check is applied.
2. CLI live plans reject over-budget runs
When --live is passed, the planner calls planZapRun() to expand all steps (including video.extend repeats), sums per-step costs, and calls assertWithinBudget(). If the total quote exceeds cap_usd, the run is aborted with an error before any provider is contacted:
assertWithinBudget() check server-side, before the run job is enqueued for provider submission. This means a malformed client request cannot bypass the cap by skipping the CLI check.
4. Provider adapters attach observed cost to each run step
After a step completes, the provider adapter records the actual cost charged by the provider and attaches it to the run step record. This observed cost feeds into post-run reconciliation and is visible in the run history dashboard.
Model Rates
The Zap planner uses a built-in rate table to estimate costs. Rates are either per-request (flat fee regardless of duration) or per-second (multiplied byduration_s):
| Model | Pricing Type | Rate |
|---|---|---|
fal-ai/flux/dev | perRequest | $0.03 / request |
fal-ai/kling-video/v2.1/pro/image-to-video | perSecond | $0.28 / second |
fal-ai/veo3.1 | perSecond | $0.45 / second |
gemini-omni-flash-preview | perSecond | $0.10 / second |
happyhorse-1.1-i2v | perSecond | $0.28 / second |
seedance-2-0-260128 | perSecond | $0.07 / second |
seedance-2-0-260128-upscale | perSecond | $0.056 / second |
mock-* models and any custom model strings) return a quote of $0.00. The stitch and keyframes step kinds are always local and always quote $0.00.
Cost Calculation
The total estimated cost for a recipe is:quoteStep works as follows:
- If the step is
stitchorkeyframes→$0.00(local, no provider cost) - If the model has a
perRequestrate → that flat rate - If the model has a
perSecondrate →rate × duration_s(defaults to 1 second ifduration_sis omitted) - If the model is unknown →
$0.00
fal-ai/flux/dev image step and two 5-second seedance-2-0-260128 video steps:
