DeepSeek Token PlanPlaybook
05
Monthly LLM API Budget: Forecast, Alert and Cap Spend
A monthly LLM API budget starts with two measured numbers, tokens per request and requests per month, and ends with a prepaid balance that cannot overspend. This method turns them into a figure, an alert and a hard cap.
Updated

- per 1M input tokens
- $0.15
- Output tokens / 1M
- $0.50
- token context
- 100,000
- trial credit
- $0.50
- requests per minute
- 300
Key takeaways
- Budget = requests x (input tokens x $0.15 + output tokens x $0.50) / 1M; use measured averages, not guesses.
- Add a 20% margin, then pick a top-up; credit never expires, so surplus carries into the next month.
- Prepaid credit is a natural spend cap, and X-Balance-USD on each response gives you a live balance to alert on.
- Add per-user and per-feature limits in your own code, because the balance cannot tell customers apart.
The method in five steps
- Measure average input and output tokens per request for each feature, from real usage.
- Forecast requests per day and per month, with a low, expected and high case.
- Price each case with $0.15 per 1M input tokens and $0.50 per 1M output tokens.
- Size a top-up that covers the high case, and take any bonus tier it reaches.
- Watch the balance and the daily burn, and alert before it runs out.
The rest of the article expands each step with a worked example. The service is a hosted, OpenAI-compatible text API running one open-weight model from an independent provider; it is prepaid pay as you go with no subscription, which makes the last step simple.
Step 1 and 2: measure and forecast
If you have no production data, run a pilot of a few hundred requests with the $0.50 trial credit from the API key page, and log usage.prompt_tokens and usage.completion_tokens for each. Take averages per feature, because a chat reply and a document summary are very different.
Now forecast volume. Start from the number of active users, then sessions per user and requests per session. Write down a low, expected and high case. The high case should reflect a launch spike or a feature people love, not the worst imaginable day.
Example: a support assistant with an expected 3,000 requests a day, which is 90,000 a month. In the pilot, a request averaged 1,500 input and 400 output tokens.
Step 3: price the forecast
Multiply tokens and apply the two rates.
- Input: 90,000 x 1,500 = 135M tokens. 135 x $0.15 = $20.25.
- Output: 90,000 x 400 = 36M tokens. 36 x $0.50 = $18.00.
- Expected month: $38.25.
| Case | Requests per month | Cost |
|---|---|---|
| Low (half) | 45,000 | $19.125 |
| Expected | 90,000 | $38.25 |
| High (plus 50%) | 135,000 | $57.375 |
Every request costs $0.000425 (1,500 x 0.15 + 400 x 0.50, divided by 1M), which is a useful number to keep: cost per request times requests equals the month. Multiply by your requests and you are done.
Include things that quietly add tokens: retries, hidden system prompts, summarization jobs and test traffic. Add about 20% for the unknown. Here, 20% over $38.25 gives $45.90.
Step 4: size the top-up
Top-ups are whole amounts from $20 to $500, paid in crypto (USDT on TRC20 or USDC on Base). A bonus applies on larger ones: +5% from $50, +10% from $100, +15% from $200.
For the example above, the expected month with margin is $45.90 and the high case is $57.375. A $50 top-up gives $52.50 of credit, enough for the expected case with margin, but not for the high one. A $100 top-up gives $110, which covers the high case and leaves $52.625 for the next month. Credit never expires, so surplus is not lost. See the pricing page for the full table.
The key point: with prepaid credit, your worst-case monthly spend is the balance you chose to load. A bug that loops cannot bill you beyond it. That is the hard cap, and failed or refused requests are not charged.
If you run several products on one account, give each its own key. Accounts that have topped up can hold up to 5 keys with labels, and you can revoke one without touching the others. Labeled keys also make it easier to attribute usage when you review the month.
Step 5: watch the balance in code
Every response includes an X-Balance-USD header with the remaining credit. This wrapper reads it after each call and warns when the balance falls under a threshold or when days of runway get short. Replace the print calls with your alerting.
import os, time
from openai import OpenAI
client = OpenAI(
base_url="https://api.deepseektokenplan.com/v1",
api_key=os.environ["API_KEY"],
)
WARN_BALANCE = 10.0 # dollars
DAILY_BURN = 1.275 # expected spend per day: 38.25 / 30
last_alert = 0
def ask(messages, **kw):
global last_alert
raw = client.chat.completions.with_raw_response.create(
model="uncensored", messages=messages, **kw
)
bal = float(raw.headers.get("X-Balance-USD", "nan"))
runway = bal / DAILY_BURN
if (bal < WARN_BALANCE or runway < 7) and time.time() - last_alert > 3600:
print("ALERT: balance $%.2f, about %.1f days left" % (bal, runway))
last_alert = time.time()
return raw.parse()
r = ask([{"role": "user", "content": "Reply with ok."}], max_tokens=5)
print(r.choices[0].message.content)
Runway is balance divided by daily burn. With $52.50 and a burn of $1.275 a day, you have 41 days. A good rule is to alert at 14 days, act at 7. You can also query GET /v1/balance or the OpenAI-style GET /v1/dashboard/billing/credit_grants from a scheduled job; both are in the docs.
Caps you must build yourself
The balance caps total spend, but it does not know who spent it. Add limits at the level where abuse or accidents happen.
- Per user: a daily request or token allowance, so one account cannot drain the balance.
- Per feature: a separate counter for expensive features such as long-document summaries.
- Per request: a
max_tokensceiling so a runaway answer stays small. Output costs $0.50 per 1M, more than three times input. - History trimming: bound chat history, since each turn bills the whole thread as input.
- Retry rules: back off on 429 instead of looping, and never retry blindly on a bad key.
The service limits also shape spend. A full key allows 8 concurrent requests and 300 per minute, so a runaway loop cannot exceed about 300 requests a minute. At $0.000425 per request, that is at most $0.1275 a minute.
Setting alert thresholds that you will act on
An alert nobody acts on is noise. Tie each threshold to a clear action, and tie them to days of runway rather than raw dollars, so they stay valid as traffic grows.
| Runway | Level | Action |
|---|---|---|
| More than 14 days | Normal | Review the numbers at the monthly check |
| 14 days or less | Notice | Plan the next top-up and confirm the crypto wallet has funds |
| 7 days or less | Warning | Top up now; check whether burn is higher than forecast |
| 2 days or less | Urgent | Top up immediately; enable stricter per-user limits until done |
Why the early lead time? Crypto transfers take a little time to arrive and confirm, and you may want to finish a task before the balance is empty. Leaving 14 days gives room for a weekend and a slow transfer.
Also watch for jumps. If today's spend is more than twice the average of the last seven days, look at it the same day. Common causes are a new feature with a long prompt, a retry loop or a user script hitting your app. Your logs of tokens per request, by feature, show which one it is.
A monthly review routine
Once a month, compare forecast and actual. Pull total spend from your logs or the drop in balance, then divide by requests to get the real cost per request. If it is more than 15% off, find out which feature moved. Update the averages, adjust the next top-up and keep a note of the reasons for any change.
For production habits around keys, limits and logging, the production checklist is the companion read.
More guides
Frequently asked questions
How do I forecast monthly spend on an LLM API?
Multiply requests per month by the cost per request, which is input tokens x $0.15 plus output tokens x $0.50, divided by 1M. Use averages from real usage and add a margin of about 20%.
Can the API overspend my budget?
Not beyond your prepaid balance. You pay from loaded credit, so the balance is the cap.
Does unused balance expire at month end?
No. Credit never expires, so what you do not spend rolls into the next month.
How do I get the current balance?
Read the X-Balance-USD header on any response, or call GET /v1/balance.
Get your API key
Sign up, copy your key, update the base URL. That is the entire setup.
Start with trial credit
Provide email and password to receive your key instantly.