Daily API budget allocator
Decide how much you can spend on a model per day and instantly see how many requests that buys. Enter a daily dollar cap, describe a typical request in tokens, pick your model, and the allocator floors your budget into a clean maximum requests per day figure — plus the exact point where you cross your chosen alert threshold.
How it works
Every request has a fixed cost driven by tokens and model price:
cost_per_request = (input_tokens / 1,000,000) × input_price
+ (output_tokens / 1,000,000) × output_price
max_requests = floor(daily_budget / cost_per_request)
Output tokens are usually 3–5× more expensive than input, so a chatty completion can shrink your request ceiling fast. The alert threshold simply marks a percentage of the budget — say 80% — and reports the request number at which spend reaches it, giving you a buffer to throttle or switch to a cheaper model.
Why per-request cost varies so much between models
LLM pricing has a wide range, and model selection is typically the largest single lever on your request ceiling. As a rough illustration (verify current pricing in your provider dashboard, as rates change):
- Lightweight / cheap models are designed for high-throughput, simple tasks. A request with 500 input tokens and 200 output tokens can cost just a fraction of a cent.
- Mid-tier models offer stronger reasoning and longer context. The same request profile may cost several times more.
- Frontier models with the highest capability are priced at a significant premium per million tokens.
For the same daily budget, switching from a frontier model to a lightweight model for a simple classification or extraction task can multiply your request ceiling by 10 to 50 times. This is why routing — using a cheap model for easy tasks and a powerful model only when necessary — is such a high-value optimisation for any production AI application.
Understanding the alert threshold
The alert threshold is the percentage of your daily budget at which you want to be warned. Setting it at 80% means the allocator identifies the request number at which you have spent 80% of your cap, leaving 20% as a buffer.
Why not just use the hard maximum? Because request volume is rarely perfectly flat throughout the day. A traffic spike in the afternoon, a batch job that runs longer than expected, or a partner webhook that fires repeatedly can consume the final 20% in minutes. With an alert at 80% you have time to throttle the rate, switch to a cheaper model for the remainder of the day, or simply stop non-critical requests until the daily reset.
Worked example
Suppose you set a daily budget of $5.00 and your typical request uses 800 input tokens and 400 output tokens on a mid-tier model priced at, for example, $2.00 per million input tokens and $8.00 per million output tokens:
cost_per_request = (800 / 1,000,000) × 2.00 + (400 / 1,000,000) × 8.00
= 0.0016 + 0.0032
= $0.0048 per request
max_requests = floor($5.00 / $0.0048) = floor(1,041.7) = 1,041
With an alert at 80%: the alert fires at request number floor(0.80 × 1,041) = 832, at which point you have spent approximately $4.00 and have $1.00 of buffer remaining.
Tips for stretching a daily budget
- Trim output, not just input. Capping
max_tokensis often the single biggest lever because output is priced highest. - Set the alert at 70–80%. That leaves headroom for traffic spikes without blowing the cap.
- Model a worst-case request. Budget against your longest typical call, not the average, so a busy period does not silently overrun.
- Use prompt caching when available. Some providers offer discounted prices for cached input tokens on repeated system prompts or context. This can dramatically reduce effective input token cost for use cases with a fixed system prompt.
- Separate concerns by model tier. Route simple tasks (yes/no classification, short extraction, templated outputs) to lightweight models and reserve your budget’s expensive requests for tasks that actually need reasoning depth.