What hosting an AI agent actually means
An AI agent is a long-running process. It holds a session, calls a model, uses tools, writes files, and waits for the next trigger. That last part is what separates hosting an agent from hosting a website. A website answers requests and forgets you. An agent has state: memory files, a workspace full of code, auth sessions, scheduled jobs mid-flight.
So hosting an AI agent means giving that process three things:
- A machine that never sleeps. If the hardware suspends, the agent suspends. Your laptop fails this test the moment you close the lid.
- Persistent disk. The agent's memory, workspace, and login state have to survive restarts. Wipe the disk and the agent starts life over.
- A way back in. You need to check on it, steer it, and read its output from wherever you are, ideally including your phone.
Everything below is judged against those three requirements. The model API is a separate cost and a separate decision. Hosting is about where the process runs, not which model it calls. If you want the full cost picture including tokens, we broke that down in how much it costs to run an AI agent.
The four options
Option 1: your own hardware. A desktop that stays on, a home server, a Raspberry Pi, an old laptop with the lid-close sleep disabled. Marginal cash cost is near zero. You already own the box. The catch is everything else: your home internet drops, the power flickers, the machine needs OS updates, and remote access means either exposing SSH to the internet or running a tunnel. Fine for tinkering. Fragile as the thing your agent's uptime depends on.
Option 2: a VPS. Rent a small virtual server for $5-10/month from Hetzner, DigitalOcean, or similar. This is the classic DIY answer and it genuinely works. You get root, a static IP, and a datacenter's uptime instead of your apartment's. You also inherit the sysadmin job: hardening SSH, applying patches, watching disk usage, and rebuilding the box when something breaks at 2am. We covered the concrete setup in best VPS for Hermes Agent, and the AI agent VPS guide has specs and provider picks for any CLI agent.
Option 3: serverless. Lambda, Cloud Run, Workers, and friends. Great for stateless request-response code. A poor fit for agents, and it is worth being precise about why. Serverless platforms bill per invocation and shut your process down between requests. Execution time limits (often 5-15 minutes) kill long tasks. Local disk is ephemeral, so the agent's memory and workspace vanish between runs. You can bolt on external storage and queues to fake persistence, but at that point you have built a distributed system to avoid renting a $6 server. Serverless makes sense for narrow event-driven automations, not for a persistent agent with a workspace.
Option 4: managed agent hosting. A platform provisions a dedicated machine, installs the agent, wires up a web interface, and handles updates and uptime. You trade root access and some flexibility for setup time measured in minutes instead of hours. This category barely existed two years ago. Hivra is our version of it: each agent runs on its own private VM, and the CLIs are the official unmodified ones, so Claude Code is signed into with your own Anthropic account and Codex with your own ChatGPT login. Zero markup on AI usage, because the usage bills through your accounts, not ours. We did the full total-cost math against DIY in managed vs self-hosted AI agents.
What CLI agents specifically need
Most hosting comparisons are written for web apps. CLI agents like Claude Code, Codex, and Hermes have a different shape. (Choosing between the first two? We compared them as hosted always-on agents in Claude Code vs Codex for 24/7 work.) Four requirements decide whether a host actually works for them:
- Process persistence. The agent must survive your disconnect. On a VPS that means running it inside tmux or screen so an SSH drop does not kill the session. On managed hosting the platform owns this.
- A real browser. Modern agents do research, fill forms, and test web apps by driving Chrome. That needs a full browser install on the same machine, plus the RAM to run it. Chrome is the hungriest thing on an agent box by a wide margin. Budget for it or the agent's most useful skill is missing.
- Memory and workspace on disk. Agents accumulate context: memory files, cloned repos, generated artifacts. The disk has to persist across restarts, and you want more than a few GB free.
- Restart behavior. Machines reboot. Kernels get patched. Something has to bring the agent back up afterward: a systemd unit you write yourself, or a supervisor the platform runs for you. An agent that stays down after the first unattended reboot is not a 24/7 agent.
Serverless fails the first and third requirements outright. Your own hardware and a VPS can meet all four if you do the work. Managed hosting meets them by default, which is most of what you are paying for.
Real cost comparison
Cash costs first, then the honest part: your time.
| Option | Cash per month | Setup time | Maintenance | Survives laptop sleep |
|---|---|---|---|---|
| Own hardware | ~$3-8 electricity | 1-3 hours | Yours, plus home internet risk | Yes, if the box stays awake |
| VPS (DIY) | $5-10 | 1-2 hours | Yours: patches, security, restarts | Yes |
| Serverless | Varies, often near $0 idle | Hours to days of glue code | Yours, and the architecture fights you | N/A, no persistent process |
| Managed (Hivra) | $0 free tier, $9.99 Pro, $19.99 Power | ~5 minutes | Handled | Yes |
On Hivra specifically: the free tier runs 1 agent at $0, but it sleeps after 4 idle days and has no browser automation. Pro at $9.99/month runs 3 agents always-on. Power at $19.99/month runs 5. Full details on the pricing page.
Two things the table cannot show. First, DIY cash costs are floors, not totals: an hour of your time spent patching a box has a price even if no invoice arrives. Second, model usage dwarfs hosting for heavy users either way. A busy agent can spend more on tokens in a day than the VPS costs in a month. If you want numbers for your own setup, the hosting cost calculator lets you compare DIY and managed with your actual usage.
Security basics that actually matter
An agent box is a strange thing to secure: it holds logged-in sessions for your accounts and it runs a program whose whole job is executing commands. Whatever host you pick, get these right:
- No public ports beyond SSH. The agent's web interface should never listen on 0.0.0.0 without auth in front of it. Reverse-proxy it behind authentication or tunnel to it. An open agent dashboard is remote code execution as a service, for everyone.
- SSH keys only, password auth off. One line in sshd_config. Non-negotiable on a public VPS.
- Prefer login sessions over raw API keys. A key pasted into a .env file on a server is a key that leaks in a backup, a log line, or a repo. Subscription logins (your Anthropic account for Claude Code, your ChatGPT account for Codex) keep the credential out of plaintext and revocable from the provider's side. We wrote more on this in BYO API key explained.
- Isolate the agent from your other stuff. Do not run your agent on the same box as your database or your personal files. One machine per agent is the clean model: if an agent is tricked into running something hostile, the blast radius is its own VM. This is how Hivra provisions every agent, and it is worth replicating if you self-host.
- Patch on a schedule. Unattended-upgrades on Debian or Ubuntu takes five minutes to enable and closes the boring-but-real hole of a six-month-old kernel.
One-click deploys: what is real
Deploy an AI agent in one click is a claim worth auditing, because it hides two very different products. Version one: a template that spins up a container with a chatbot wrapper and a text box. It demos well and does little, because there is no persistent workspace, no browser, and often no real CLI underneath. Version two: a platform that provisions actual infrastructure with the real agent on it.
The test is what exists after the click. You should be able to answer yes to all of these:
- Is it the official CLI, unmodified, not a fork or a wrapper?
- Do you sign in with your own model account, so usage bills at provider rates with no markup?
- Is there a persistent VM with a workspace, or just a stateless container?
- Can the agent drive a real browser?
- Can you reach the terminal, the files, and the running session from a browser, including on your phone?
On Hivra the click provisions a private VM, and about 5 minutes later you have the agent running with chat, terminal, files, and browser tabs on top of it. Six agents are launchable today: Hermes, Claude Code, Codex, and Aeon on the free tier, plus OpenClaw and Agent Zero from the Pro plan up. If you are weighing those last two against each other, we compared them in Agent Zero vs OpenClaw hosting. The full list is on the agents page.
Which option wins for which person
- You have a home server and enjoy tending it: your own hardware. Cheapest marginal cost, and you already accepted the ops work.
- You want full root, total control, and do not mind the sysadmin job: a $5-10 VPS with tmux, SSH hardening, and a systemd unit. Legitimate, proven, cheap.
- You need a narrow event-driven automation, not a persistent agent: serverless, honestly. Right tool for that one job.
- You want the agent working tonight and never want to think about the server: managed. Pick an agent, launch it, sign in with your own account, and the box stays up.
The wrong answer is the default one: leaving the agent on your laptop and hoping. An agent that dies when the terminal closes is a chat session with extra steps. Put it on a machine that runs 24/7, whichever of the four ways you choose, and it starts earning the name.