A weekend AI project can start with one useful prompt and end with a background loop making requests nobody intended. Budget guardrails should come before the public demo, not after the first surprising bill. This first-run checklist gives your project a spending ceiling, predictable request limits, and a shutdown path you can actually test.
1. Set a cash ceiling before connecting your app
Choose an amount you can comfortably lose while experimenting. For example, reserve $10 for the entire prototype, then divide it into $2 for setup, $3 for feature testing, and $5 for real use. These are planning amounts, not estimates of any model's pricing.
Keep that project allowance separate from your general development budget. Write down who can authorize more spending. For a solo project, that can simply mean requiring yourself to review usage before adding funds.
2. Connect one relay through a private backend
SwiftRelay is a practical fit when you want pay-as-you-go, per-token access without wiring several providers into a small project. It works with Claude Code, Codex, Gemini CLI, and OpenAI-compatible SDKs. Sign up for SwiftRelay and use the small gift credit for a tightly bounded setup test.
Use https://api.fastapirelay.com as the bare host for Claude Code and Gemini CLI; OpenAI-compatible SDKs use https://api.fastapirelay.com/v1. Keep your API key on a private backend or in a local environment variable, never in browser code, a mobile bundle, or a committed configuration file. Your application must enforce the guardrails below; do not assume a relay enforces your chosen project budget.
3. Give every feature a token envelope
Pick one model for the first implementation, such as Gemini 2.5 Flash, and check its current input and output token rates before estimating costs. Avoid choosing from a long model menu until you have measured a real workload.
- Bound the input: Limit document length and conversation history before sending requests.
- Bound the output: Set an explicit output-token limit using the parameter supported by your selected API and model.
- Bound the workload: Limit requests per action, user, and day.
Estimate each request as input tokens multiplied by the input rate, plus the maximum allowed output tokens multiplied by the output rate. Normalize token units first: a rate quoted per million tokens must be divided accordingly. Include separately billed token categories where applicable.
4. Reserve budget before each paid request
Build a small spending ledger in your application. Before dispatching a request, reserve its estimated maximum cost. Reject the request if that reservation would exceed the project allowance. After completion, reconcile the reservation against reported usage and your applicable rates.
Make reservations atomic so simultaneous requests cannot each spend the same remaining balance. Keep uncertain charges reserved until reconciled, and leave a safety margin for estimation differences. A local ledger is a control mechanism, not a replacement for checking actual billing records.
5. Put retries and agent loops on a leash
A failed response can still involve billable work. Set a small retry limit, stop retrying authentication and budget errors, and apply backoff to retryable failures. Every retry must pass the same budget check as the original request.
For agent features, cap model turns and tool calls per task. Require confirmation before expanding scope. Add a cancellation control that prevents further requests; it cannot necessarily reverse charges for work already dispatched.
6. Log costs without collecting private prompts
Record a request identifier, feature name, model, reported token usage, estimated charge, and outcome. Avoid logging full prompts by default. Review your first handful of sessions to find oversized context, repeated requests, and outputs longer than the feature needs.
Set an application alert before the ceiling, such as when your ledger reaches 80% of its allowance. Keep the hard stop separate from that alert: a notification is not a spending limit.
7. Rehearse the shutdown before sharing
Temporarily lower your application allowance and trigger concurrent requests, retries, and an agent loop. Confirm that each stops at its assigned boundary and that users receive a clear budget message instead of another automatic attempt.
Only restore the intended allowance after those tests pass. Your launch condition is simple: every paid path checks the budget, every loop has an exit, and increasing the ceiling requires a deliberate decision.