Dev.to AI 🤖 Ai 👁 0 📖 3 min read

How do I cap inference billing to avoid surprise costs from idle GPUs or runaway agents?

You cap inference billing by layering controls, not by flipping one switch. On DigitalOcean, Serverless Inference is prepaid, so your balance is a real ceiling, and scoped keys, alerts, and cleanup jobs cover the rest. S

You cap inference billing by layering controls, not by flipping one switch. On DigitalOcean, Serverless Inference is prepaid, so your balance is a real ceiling, and scoped keys, alerts, and cleanup jobs cover the rest. Spend alerts alone won't stop anything: they email you when spending crosses a threshold, but your usage keeps running.

Key takeaways:

  • Serverless Inference stops when funds run out, so fund a dedicated balance with only what you plan to spend.
  • Dedicated Inference and GPU Droplets bill by the hour until destroyed, so automate cleanup.
  • Agents need caps in your own code, because rate limits slow spending but don't cap it.

Use prepaid balances as a ceiling

Serverless usage draws from promotional credits, then the Inference and Agents balance, then your account prepayment balance. Only Serverless Inference and Managed Agents draw from the first, so it works as a separate AI budget. Auto-reload is on by default, so turn it off for a hard stop. A zero balance is also an outage, so reserve this for experiments and non-critical workloads.

Add alerts and scope your keys

Spend alerts email you at percentage thresholds of your monthly budget, within an hour of each threshold being crossed. Their sole purpose is notification. Give each service its own model access key, scoped to specific models and a VPC, so one leak or loop has a small blast radius. Regenerating a key takes effect immediately, which is how you want it to work during an incident.

Cap agents in code

Rate limits (up to 120 requests and 1.5M tokens per minute at the lowest serverless tier) limit speed, not total spend. Harness Runtime has no per-session or per-product spend limit, so an agent stuck in an unintended loop can quickly drain balances. Set a max output token count per call, a max step count per task, and a running spend counter that stops the run. You should also pause idle sessions, since paused sessions incur no compute charges.

Stop paying for idle GPUs

Dedicated Inference bills per GPU-hour, and GPU Droplets bill per second until destroyed. Powering off doesn't stop the meter. At \$30.32 per hour for 8x H100, an idle Dedicated Inference endpoint costs roughly \$728 a day.

To cap inference billing and avoid surprise costs, tag experimental GPU Droplets and destroy them nightly:

doctl compute droplet delete --tag-name ephemeral-gpu --force

Inference billing cap FAQ

Can I get usage alerts or hard spending caps on a managed AI platform before bills run away?

DigitalOcean spend alerts notify you at budget thresholds but don't limit usage. The closest hard cap is Serverless Inference's prepaid model, where access is suspended when credits and balances run out.

Does powering off a GPU Droplet stop billing?

No. The GPU stays reserved, so billing continues until you destroy the Droplet.

Which inference option doesn't penalize variable workloads?

Serverless Inference, which bills per token instead of reserving GPUs, is a solid choice for variable workloads. Dedicated Inference bills per GPU-hour, whether or not anyone calls it, so it suits steady traffic better than spiky traffic.

References & further reading

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.