Hosting an AI agent 24/7 costs about $12.70 a month on a Fly Machine with one shared vCPU and 2 GB of RAM, billed per second while it runs, and under a dollar a month on a Fly.io Sprite when the agent only has to wake on events and can sleep in between.[1][2]
You have an agent that works. It answers in a chat channel or watches a repository, and you want it running when your laptop lid is closed. Every host you price quotes a different unit, from a monthly preset to vCPU-seconds to GB-hours of memory actually used.
One question comes before any price. An agent that holds a connection open around the clock is a server. An agent that reacts to a webhook, a message or a schedule only needs compute while it handles one. The two cost very different amounts and belong on different compute.
Everything below is hosting cost: CPU, memory and disk. Model and API spend is a separate bill that grows with tokens, not uptime, and is out of scope here.
How Much Does It Cost to Run an AI Agent 24/7?
An agent that runs every hour of a 30-day month costs whatever its machine costs for 720 hours, and that machine is usually small, because most agents spend their time waiting on a model call or a human.
On Fly.io a mostly idle agent fits is a shared-cpu-1x Machine: $6.70 a month with 1 GB of RAM, plus $6.00 per additional GB, which puts the 2 GB shape at $12.70 for 30 days of continuous runtime in Ashburn (iad).[1] Machines are billed by the second while running, so the same agent costs about 1.8 cents an hour. A lightweight agent fits the smallest preset, 256 MB for $2.19 a month; one that parses documents or drives a headless browser between calls moves to a performance-1x Machine with 2 GB at $33.00.
State that has to outlive a restart goes on a volume at $0.15 per GB-month, so 10 GB adds $1.50, and outbound data is $0.02 per GB in North America and Europe.[1] Any configuration can be priced before you deploy it at fly.io/calculator.
Does Your AI Agent Actually Need to Be Always On?
Often it does not, and finding out is the largest saving available. An agent has to be always on when it holds something open, such as a gateway connection to a chat platform or a loop that polls a feed. Nothing outside can wake it, because the agent is the thing listening. An agent that reacts to inbound events, such as a GitHub webhook or a scheduled request, can sleep until one lands, do its work, and sleep again.
Polling keeps an agent awake
The usual reason a cheap agent turns into an always-on one is trigger design. An agent that checks an inbox every minute never sleeps, so it bills as a server. The same agent subscribed to a webhook sleeps between deliveries. Moving from polling to push changes the hosting shape, not just the price.
What keeps a sleeping agent awake
On a Fly.io Sprite, four things reset the idle timer: an in-flight HTTP or API request, output to a session’s stdout, an open TCP connection, and an active task.[2] With none present, the Sprite moves from running, which is billed, to warm and then cold, neither billed for compute. That rule sorts agents cleanly: one that keeps a TCP connection open all day belongs on a Fly Machine, and one that waits for requests belongs on a Sprite.
What a 24/7 Agent Costs on Each Host
A mostly idle 24/7 agent with 1 vCPU and 2 GB costs $14.20 a month on a Fly Machine with a 10 GB volume, and $22 to $86 on per-second hosts. The workload: 720 hours, 5% CPU busy, 1 GB of memory in use, 10 GB of disk, plan fees excluded.
| Host | Billing basis | Shape priced | Monthly cost | Runs one sandbox 24/7? |
|---|---|---|---|---|
| Fly Machine | flat preset, per second while running | shared-cpu-1x, 2 GB, 10 GB volume | $14.20 | Yes |
| Fly.io Sprite, kept awake | CPU and memory actually used | 1 vCPU, 1 GB used, 10 GB hot | $22.05 | Yes |
| Vercel Sandbox | Active CPU plus provisioned memory | 1 vCPU, 2 GB | $35.14 | No, 24-hour sessions on Pro |
| Cloudflare Sandbox | active CPU plus provisioned memory and disk | standard-2 (1 vCPU, 6 GiB, 12 GB) | $43.65 | Only while kept active |
| E2B | reserved CPU and memory while running | 1 vCPU, 2 GiB | $59.62 | No, 24-hour sessions on Pro |
| Daytona | reserved resources while started | 1 vCPU, 2 GiB, 10 GiB | $60.00 | Yes, with auto-stop disabled |
| Modal Sandboxes | higher of request or usage | 1 vCPU, 2 GiB | $85.65 | No, 24-hour maximum |
Our arithmetic on published rates, not a figure any vendor quotes. Sources: [1][2][3][4][5][6][7][8][9], rates checked 2026-10-05.
The Fly Machine wins because its price is flat. An agent that never sleeps pays for memory every hour on any meter: $15.75 of the Sprite’s $22.05 is 720 GB-hours of memory.[2] E2B and Daytona bill reserved vCPU and memory for every second the sandbox runs, so idle time costs full price.[3][4][5] Vercel and Cloudflare stop the CPU line while the agent waits but bill provisioned memory all month, and Cloudflare’s smallest shape with a full vCPU carries 6 GiB.[7][9] Modal bills whichever is higher, the request or actual usage.[6] Per-unit rates for every provider are in AI sandbox pricing.
Session caps are a cost too
Three of these products cannot keep one sandbox alive for a month. E2B caps continuous runtime at 1 hour on Hobby and 24 hours on Pro, and Pro is a $150 monthly plan fee before compute.[10][3] Vercel caps a session at 45 minutes on Hobby and 24 hours on Pro; the limit resets when a persistent sandbox stops and resumes, so a month of uptime is thirty stop and resume cycles.[7] Modal sandboxes take a timeout of up to 24 hours, and Modal’s advice for longer runs is to snapshot the filesystem and restore it into a new sandbox.[11]
Cloudflare stops an inactive instance unless something keeps it active, and its disk and memory end when it stops.[12] Daytona is the exception: auto-stop defaults to 15 minutes, and setting it to 0 lets a sandbox run indefinitely.[13]
Each restart costs more than its minutes. The agent loses its process memory and open connections, rebuilds its context, and depends on restore logic someone has to write and test. These products are built for sessions, the split covered in ephemeral vs persistent sandboxes, and a 24/7 agent is not a session.
What an Agent That Wakes on Events Costs
An agent that wakes on events and sleeps in between costs under a dollar a month on a Fly.io Sprite. Take 60 webhooks a day at about a minute each: 30 hours awake a month, 20% CPU busy while awake, half a GB of memory in use, 10 GB of disk.
| Line | Usage | Cost |
|---|---|---|
| CPU | 6 CPU-hours at $0.0385 | $0.23 |
| Memory | 15 GB-hours at $0.021875 | $0.33 |
| Hot storage, while awake | 10 GB for 30 hours at $0.000683 | $0.20 |
| Cold storage, while asleep | 10 GB for 690 hours at $0.000027 | $0.19 |
| Fly.io Sprite, per month | $0.95 | |
| Same agent on a Fly Machine left running | 720 hours, 2 GB, 10 GB volume | $14.20 |
Our arithmetic on published rates, not a figure any vendor quotes. Sources: [1][2], rates checked 2026-10-05.
The Sprite costs a fifteenth of the always-on Machine because compute stops while it sleeps. Sprites meter CPU time from cpu.stat and memory actually in use, with no per-Sprite charge, so an idle Sprite costs only its storage.[2] A request to its HTTPS URL wakes it with the same disk every time, so installed packages and the agent’s history are where it left them, and a webhook reaches it with no tunnel in front.
The crossover comes when awake time stops being small. A Sprite holding 1 GB costs about 2.2 cents an hour in memory alone, so an agent awake most of the day is cheaper on the flat Machine price.
How Much Does It Cost to Run 5 AI Agents?
Five always-on agents cost $71.00 a month on Fly Machines and five event-driven agents cost $4.75 on Sprites, using the two workloads above. Cost scales linearly, because each agent gets its own machine.
| Agents | Fly Machines, 24/7 (2 GB, 10 GB volume each) | Fly.io Sprites, event-driven (30 h awake each) |
|---|---|---|
| 1 | $14.20 | $0.95 |
| 5 | $71.00 | $4.75 |
| 10 | $142.00 | $9.50 |
Our arithmetic on published rates, not a figure any vendor quotes. Sources: [1][2], rates checked 2026-10-05.
One agent per machine is deliberate. Agents run code they wrote or fetched, and one that fills its disk or wedges its event loop takes down everything sharing its host. A separate Machine or Sprite per agent keeps that failure on one Firecracker microVM, the property an agent sandbox exists to provide.
Fleets often mix both shapes. A coordinator holding a chat connection runs on a Machine, and the workers it dispatches sleep on Sprites until called. Ten workers and one coordinator cost about $23.70 a month at these rates.
Keeping an Agent Running Without Babysitting It
An agent that crashes at 3am and stays down until you wake up has a supervision problem, not a price problem. The fix is a supervisor that restarts the process without you, and on Fly.io it is a setting on the Machine.
The Machine restart policy has three values. always restarts the Machine whenever its main process exits, even cleanly, and is the recommended policy for always-on apps with no services configured: an agent that holds an outbound connection and serves nothing. on-fail restarts a Machine after a non-zero exit, up to 10 times in a 5-minute window by default, and is what fly launch sets. no leaves it stopped. Under always, a crash at 3am is a restart and a log line, not an outage that waits for you.
State is the other half. A Machine’s root filesystem resets when it stops, so anything the agent must remember goes on a volume, whose data survives stops and restarts. A Sprite keeps its whole ext4 filesystem across sleeps and restarts, and its services come back after a reboot.
Hosting an AI Agent 24/7 on Fly.io
Fly.io runs both shapes on the same Firecracker substrate. An agent that never sleeps runs on a Fly Machine: a flat per-second price from $2.19 a month, a restart policy that brings it back after a crash, and a volume for its state. fly launch detects the project, writes the configuration and deploys it.
An agent that wakes on events runs on a Sprite: a persistent Linux computer that sleeps when the agent goes idle, wakes on the next request to its URL with its filesystem intact, and bills only the CPU and memory used while awake. The Sprites documentation covers creating one and running the agent as a service. Code an agent builds in a Sprite runs on Machines in production with no rewrite.
Frequently Asked Questions
Do AI agents work 24/7?
Yes, when the host keeps the process alive and restarts it after a crash. On Fly.io, a Fly Machine with the always restart policy brings the agent back whenever its process exits, and an agent that only reacts to events can run on a Sprite that sleeps between them.
How much should an AI agent cost to host?
A mostly idle agent costs about $12.70 a month on a Fly Machine with 1 shared vCPU and 2 GB running 24/7, and about $0.95 a month on a Fly.io Sprite if it is awake 30 hours a month. Model and API spend is a separate bill.
How much does it cost to run an AI agent per hour?
About 1.8 cents an hour on a 2 GB shared-cpu-1x Fly Machine, billed per second. On a Fly.io Sprite, an awake hour costs $0.0385 per CPU-hour used plus $0.021875 per GB-hour of memory used, and a sleeping hour costs only storage.
Can a sandbox run an AI agent 24/7?
No, not on most sandbox products without restarts. E2B and Vercel cap a session at 24 hours on Pro and Modal caps a sandbox at 24 hours, so a month of uptime means about thirty restarts. A Fly Machine has no session cap.
Does a sleeping agent lose its state?
No, not on a Fly.io Sprite, which wakes on the next request with its filesystem intact. On a Fly Machine the root filesystem resets when the Machine stops, so state that has to persist belongs on a volume.
How do I keep an AI agent running without babysitting it?
Give it a supervisor that restarts it without you. On Fly.io, the always restart policy restarts a Machine whenever its main process exits, and on-fail restarts it after a non-zero exit, up to 10 times in 5 minutes by default.
How do I lower the cost of a long-running agent?
Stop it polling. An agent that checks for work every minute never sleeps and bills as a server, while one that receives webhooks can sleep on a Fly.io Sprite between deliveries and pay only storage while asleep.
Does the hosting price include the AI model cost?
No. Hosting covers CPU, memory and disk; the model provider bills API calls per token. On Fly.io, a 24/7 agent on a 2 GB Machine costs $12.70 a month in hosting whatever its token spend.
Sources
- ^ Fly.io, “Fly.io Resource Pricing”. docs.fly.io/about/pricing. Checked 2026-10-05.
- ^ Fly.io, “Sprites | Linux computers for agents”. fly.io/sprites. Checked 2026-10-05.
- ^ E2B, “Pricing | E2B”. e2b.dev/pricing. Checked 2026-10-05.
- ^ Daytona, “Daytona - Secure Infrastructure for Running AI-Generated Code”. daytona.io/pricing. Checked 2026-10-05.
- ^ Daytona, “Billing | Daytona”. daytona.io/docs/en/billing. Checked 2026-10-05.
- ^ Modal, “Pricing: Pay per second for GPUs and CPUs”. modal.com/pricing. Checked 2026-10-05.
- ^ Vercel, “Vercel Sandbox pricing and quotas”. vercel.com/docs/sandbox/pricing. Checked 2026-10-05.
- ^ Cloudflare, “Pricing · Cloudflare Containers docs”. developers.cloudflare.com/containers/platform/pricing. Checked 2026-10-05.
- ^ Cloudflare, “Limits and Instance Types · Cloudflare Containers docs”. developers.cloudflare.com/containers/platform/limits. Checked 2026-10-05.
- ^ E2B, “Billing & limits”. docs.e2b.dev/billing. Checked 2026-10-05.
- ^ Modal, “Sandboxes | Modal Docs”. modal.com/docs/guide/sandboxes. Checked 2026-10-05.
- ^ Cloudflare, “Sandbox lifetime · Cloudflare Sandboxes docs”. developers.cloudflare.com/sandbox/concepts/lifetime. Checked 2026-10-05.
- ^ Daytona, “Sandboxes | Daytona”. daytona.io/docs/en/sandboxes. Checked 2026-10-05.