What a Self Hosted AI Agent Really Costs Each Month
Our real 30-day bill for a self hosted AI agent on one VPS: 133.64 dollars in model calls, where the tokens went, and three settings that keep it low.
What a self hosted AI agent actually costs each month
Over the last 30 days, six agent profiles on one VPS spent 133.64 US dollars on model calls. That is an average of 4.31 dollars a day and a median of 2.77, with one bad day at 16.27.
Those numbers come from the usage table on our production box, not from a pricing calculator. The box runs 81 scheduled jobs around the clock.
The always-on part is nearly free in tokens. Waiting, polling and checking cost almost nothing. The real bill is the work you ask the agent to do.
If you have not built one yet, start with how I run my own AI agent, then come back for the invoice.
The line items, one by one
Here is the full month, split the way I would split it on a client invoice.
| Line | What we actually measured | Monthly cost |
|---|---|---|
| The server | Contabo Cloud VPS 8: 8 vCPU AMD EPYC, 24 GB RAM, 300 GB SSD. Listed at 13.44 dollars, ours is prepaid for the year | about 6 dollars |
| Workhorse model calls | 1,355 calls, 98.4 percent of all tokens | 91.88 dollars |
| Premium calls through a second provider | 947 calls, 1.6 percent of all tokens | 41.77 dollars |
| Flat-rate plan, writing only | One subscription, never used by the scheduled jobs | 20 dollars |
| Small stuff | Image generation 1 to 2 dollars, domains about 2 dollars | 3 to 4 dollars |
Add it up: about 163 dollars a month all in, or about 171 if you pay for the server month to month instead of prepaying.
Where the money actually goes: the cache reads
In 30 days the box moved 11.95 billion tokens. Of those, 11.72 billion were cache reads. That is 98 percent of the volume.
A cache read is input the provider has already seen in a recent call, such as the system prompt and the conversation so far, billed at a fraction of the fresh input price.
Fresh input was only about 164 million tokens, and output about 69.2 million. An agent rereads its own context on every step, so the cache is where the volume lives.
That makes the price of a cache read the number that decides your bill. Look at our two routes:
- The workhorse route carried 98.4 percent of the tokens for 68.8 percent of the bill, about 0.0078 dollars per million tokens.
- The second provider carried 1.6 percent of the tokens for 31.3 percent of the bill, about 0.2156 dollars per million.
Per token, the second route costs roughly 27 times more. A thin slice of premium work is a third of the money.
The same work priced on a premium model
I ran a route audit: take the engine workload exactly as logged, then reprice it at other models' published rates.
| Model | Same engine workload | Multiple |
|---|---|---|
| Cheap workhorse model (recorded) | 87 dollars | 1x |
| Sonnet-class model | 3,161 dollars | 36x |
| Opus-class model | 4,182 dollars | 48x |
The decisive line is the cached input rate. Our cheap model lists 0.30 dollars per million input, 0.006 per million cached input and 1.20 per million output at peak, and half of that off peak. So cached input lands at 0.003 dollars per million, against 0.20 on the premium model. That is 67 times, applied to 98 percent of the volume.
The honest conclusion is a split. The workhorse loop runs on the cheap model, with a fallback pipe to the same model at a second provider. The expensive model is used only where a human reads the output, such as a client email or a weekly report.
Three settings that keep the bill low
Most of the schedule costs nothing
Of our 81 scheduled jobs, 61 are plain scripts that never call a model. A backup or a disk check does not need a language model.
The monitors are gated. Each one checks state first. If there is nothing new, it prints IDLE and exits before any model call.
import sqlite3, sys
db = sqlite3.connect("monitor.db")
last = db.execute("SELECT COALESCE(MAX(event_id), 0) FROM checked").fetchone()[0]
new = db.execute("SELECT COUNT(*) FROM events WHERE id > ?", (last,)).fetchone()[0]
if new == 0:
print("IDLE")
sys.exit(0)
# only past this line does the agent get called
Do the arithmetic on one monitor that runs every 15 minutes: that is 96 runs a day. On a quiet day the gate turns all 96 into a cheap database query, and every extra gated monitor saves another 96 model calls.
A cheap principal model plus a fallback pipe
The principal model is the cheap one. When its provider times out or rate-limits, the agent retries the same model through a second provider.
That is a fallback, not a router. A router decides which model answers. A fallback only decides which pipe carries the same model, so the price per token stays where you set it.
hermes config set fallback_providers \
'[{"provider":"openrouter","model":"deepseek/deepseek-v4.1-flash"}]'
That writes this into the profile's own config, and it takes effect on the next call:
fallback_providers:
- provider: openrouter
model: deepseek/deepseek-v4.1-flash
The reason is the second failure below: the one time we let a router choose, it chose a premium model and the bill nearly tripled.
Prune the session store
Every session the agent runs gets stored, and the store only grows. Our six state databases total about 1.9 GB.
hermes sessions stats # how big the store is now
hermes sessions optimize # merge the search index, then VACUUM
That second command changes no data and runs while the agent is working. One profile store went from 2,051 MB to 229 MB in 33 seconds. Pruning is a monthly chore for us now, not a daily one. If you delete rows yourself instead, stop the agent first and copy the file before you touch it.
This query measures the spend on the same box, straight from the usage the agent already records:
SELECT model, billing_provider, ROUND(SUM(estimated_cost_usd), 2) AS usd,
ROUND(100.0 * SUM(cache_read_tokens) / SUM(input_tokens + output_tokens + cache_read_tokens), 1) AS cache_pct
FROM session_model_usage
WHERE first_seen >= strftime('%s', 'now', '-30 days')
GROUP BY model, billing_provider
ORDER BY usd DESC;
The two failures that cost real money
The worker that never retried. A publishing worker connected to its queue once at boot. When that connection dropped, it never tried again. The process stayed up, the pipeline reported healthy, and nothing published for hours.
The fix is to prove a fresh poller rather than trust the dashboard. A check now pushes one test item through the queue and fails loudly if it does not come out the other end.
The router that picked premium. We tried an auto-router. It quietly sent work to a premium model, and the bill ran 2.4 to 3 times our normal rate. On cache reads it was about 7 times, because that is where the volume is. That is why no route on our box is chosen by a router.
The four numbers to check each day
I look at these every morning. If you already log what your AI agent does, each one is a single query.
- Spend: the total for the day, next to the 7-day average.
- Cache-hit share: cache reads as a share of all tokens. Ours sits at 98 percent, so a drop means something broke the cache.
- Cost per scheduled job: one job that doubles its cost shows up here before it shows up on the bill.
- Called versus idle: how many jobs actually called a model, and how many printed IDLE and did nothing.
Alert when a day passes 3 times the median. For us that is about 8.31 dollars, which would have flagged our 16.27 day.
When renting still wins
Self-hosting is not the cheapest answer for everyone. These are the prices I checked in October 2026.
- OpenAI's always-on Dots need ChatGPT Pro, from 100 dollars a month for the first agent. At launch on 29 September 2026, Pro access excluded the EEA, Switzerland and the UK. Business Premium, at 125 dollars per seat per month, includes them in its supported regions.
- Devin repriced in 2026: 20 dollars per seat on Pro, 200 dollars a month on Max.
- If you rent the server elsewhere, a 16 GB memory-optimized droplet is 84 dollars a month and a basic 4 GB one is 24, before you have paid for a single model call.
Rent when you do not want to operate the box. Patching, backups and a worker that dies at 3 a.m. are real work, and 100 dollars is cheap if your time is not. Run your own when you want the ceiling fixed and the data local.
This post was written with AI assistance and reviewed by a human. Every spend and token figure for our setup came from our own production box over a 30-day window, not from a vendor's pricing page.
Frequently asked questions
Is a self hosted AI agent cheaper than a subscription?
For us, yes: about 163 dollars a month all in for six agent profiles, against 100 dollars a month for a single always-on agent on ChatGPT Pro. For one light agent, a subscription can come out level once you count your own time.
What is the biggest surprise in the bill?
Cache reads. They were 98 percent of our tokens, so the cached input rate matters far more than the headline price per million.
How do I stop the spend if it runs away?
Use prepaid credit with auto top-up switched off. Our balance at the provider was 2.81 dollars when I wrote this, so a runaway loop stops when the credit does, and the 3x-median alert tells you which job caused it.
If you would rather hand this off: I build and run self-hosted stacks for a living, and an agent that stays inside its budget is a two-day job.