Self-Hosted vs. API-Based Agents: Real Cost and Latency Numbers, Not Vibes
“It depends on your usage” is true and also not an answer. Here’s what the actual numbers look like as of August 2026, and how to run the breakeven calculation for your own workload instead of trusting a rule of thumb.
API pricing, current as of this writing
| Model | Input ($/M tokens) | Output ($/M tokens) |
|---|---|---|
| Claude Sonnet 5 | $2.00 | $10.00 |
| Claude Opus 4.6 | $5.00 | $25.00 |
| GPT-5.2 | $1.75 | $14.00 |
Source: Finout’s Claude Sonnet 5 pricing breakdown, pricepertoken.com, Finout’s OpenAI vs. Anthropic comparison. Sonnet 5’s $2/$10 pricing launched as introductory and became Anthropic’s permanent price on August 10, 2026 — a previously scheduled increase to $3/$15 was cancelled. Check current pricing before making a decision regardless; these numbers still move.
What this actually costs in practice: an agent doing moderate tool use — say 50,000 input tokens and 5,000 output tokens per task (a realistic ratio for an agent re-reading accumulated context each turn) — costs roughly $0.15 on Claude Sonnet 5’s current pricing. At 1,000 such tasks a month, that’s about $150/month. The API model’s defining cost trait: it scales with usage, and it’s zero when you’re not using it.
Self-hosted GPU pricing
| Instance | On-demand hourly | Running continuously (672 hrs/mo cap) |
|---|---|---|
| H100 | ~$3.39/hr | ~$2,280/mo |
| H200 | ~$3.70/hr | ~$2,486/mo |
Source: DigitalOcean GPU Droplet pricing via Spheron’s breakdown. Reserved/longer-term contracts bring this down to roughly $1.91–$7.94/hr depending on hardware and commitment — but note DigitalOcean bills you even while the instance is powered off until it’s actually destroyed, which matters if your agent runs on a schedule rather than continuously.
The self-hosted model’s defining cost trait is the inverse of the API model’s: it’s fixed regardless of usage, and it’s the same cost whether the agent runs once or ten thousand times that month.
The actual breakeven calculation
Using the numbers above: an H100 at ~$2,280/month buys you a fixed capacity budget. At Claude Sonnet 5’s ~$0.15/task rate, $2,280 buys roughly 15,200 equivalent tasks worth of API spend. Below that volume, the API is cheaper. Above it, self-hosting an open-weight model on your own H100 starts winning on pure compute cost — if the open-weight model you’re running is actually good enough for your task, which is a capability question this article isn’t answering.
Run this for your own numbers:
def breakeven_tasks_per_month(gpu_monthly_cost, api_cost_per_task):
"""How many tasks/month before self-hosting is cheaper than the API."""
return gpu_monthly_cost / api_cost_per_task
# example using the figures above
print(breakeven_tasks_per_month(2280, 0.15)) # ≈ 15,200 tasks/month
The number that actually matters is your own api_cost_per_task — it depends
entirely on your input/output token ratio, which varies a lot between “answer a
question” agents and “re-read a large codebase every turn” agents. Compute it from
your own logs before trusting any published rule of thumb, including this one.
What this calculation leaves out, honestly
- Your engineering time isn’t in this math, and self-hosting has real, ongoing operational cost — serving infrastructure, monitoring, scaling under load — that a fixed monthly GPU price doesn’t capture.
- Latency is a real factor this piece isn’t giving you numbers for. Self-hosting removes the network round trip to a third-party API, but your own single-GPU serving setup is very likely slower per token than a provider’s production-grade optimized serving stack unless you’ve invested real effort in your inference pipeline (batching, quantization, a real serving framework). Don’t assume self-hosted is faster without measuring your specific setup — it frequently isn’t.
- Model capability isn’t a cost line item, but it’s the real gate. If the open-weight model you can realistically self-host doesn’t perform well enough on your actual task, the breakeven math above is irrelevant — you’re not choosing between two equally-good options at different prices, you’re choosing whether a worse model is still good enough.
Where to actually run it
If the breakeven math above points you toward self-hosting, RunPod is a GPU cloud built specifically for this — on-demand H100/H200 pods, billed by the second rather than DigitalOcean’s bill-until-destroyed model mentioned above. (Disclosure: that’s our referral link — we earn a small percentage of your spend if you sign up through it, at no extra cost to you. We’re not paid to say this; see the site affiliate policy for the full picture.)
The actual decision rule
Compute your own api_cost_per_task from real usage, divide the GPU instance cost
you’re considering by it, and compare that number to your realistic monthly task
volume. Below the breakeven line, the API is cheaper and simpler — take it. Above it,
self-hosting is worth seriously evaluating, but only after separately confirming the
open-weight model on the table is actually good enough for the job.