Getting Your First Agent Live

Local model hosting vs cloud APIs for production agents

Matt DoughtyMatt DoughtyCEO & Co-Founder, Prefactor
5 min read
Abstract illustration: When to Host Models Locally vs. Call External APIs for Your Agents

Choosing where your agent runs its inference shapes latency, cost, compliance exposure, and how much your team owns operationally. Local models cut round-trip time and keep data inside your boundary. External APIs offer frontier capability with no hardware commitment. Neither is the right default, and the factors below show where each path breaks down.

The five factors that drive the decision

Latency

Local inference is faster at the network level because there is no round trip. A 7B model running on local hardware averages 20 to 40 milliseconds time-to-first-token; a 70B model averages 40 to 80 milliseconds. Cloud APIs average 200 to 500 milliseconds under normal load, not counting retry logic or queue time during peak demand.

That gap matters most for AI voice agents and real-time conversational AI agents, where a 400-millisecond delay is perceptible. For a nightly data-analysis agent or a batch document processor, it rarely matters at all.

Cost

Cloud APIs charge per token with no upfront commitment, which makes them cheaper at low volumes. Local LLMs break even with cloud APIs at approximately 500,000 tokens per day for a 7B model and 2 million tokens per day for a 70B model, after accounting for hardware, power, and engineering overhead.

Desert Ant Labs positions its on-device models explicitly on this point: no per-token cost. That works if your agent runs continuously or at high frequency. If your agent handles a few hundred requests a day, the hardware and maintenance costs are unlikely to pay off within a reasonable horizon.

Data privacy and compliance

When you send a prompt to an external API, that data leaves your infrastructure. For healthcare AI agents, financial services workflows, or any context involving regulated personal data, that transfer may conflict with HIPAA, GDPR, or sector-specific data residency rules regardless of your provider’s certifications.

Mayo Clinic’s AI triage system, which analyzes millions of EHR records and billions of patient data points to assign real-time risk scores, is an example where the sensitivity of the data pushes hard toward controlled inference environments. Local or private-cloud hosting keeps data within your defined boundary, but you then own AI security for the model itself, including access control, model integrity, and logging.

Capability

This is where local models give the most ground. Frontier cloud models handle ambiguous multi-step reasoning, long contexts, and novel tasks better than any sub-13B model available today. MaskShift’s production harness enables local tool calling without external dependencies, which covers structured tool use well. But if your agent needs to draft nuanced analysis, reconcile conflicting instructions, or operate reliably across a wide range of edge cases, a smaller local model will produce more errors, and you will need human review in the loop to catch them.

Doctolib’s deployment of Claude Code across 600 engineers cut project ramp-up from weeks to days precisely because the cloud model could handle unfamiliar tech stacks without hand-holding. A local 7B model would have required far more prompt scaffolding for the same coverage.

Operational overhead

Local inference means you maintain the model, the hardware, the serving stack, and the update cycle. Cloud APIs shift that burden to the provider, at the cost of control and the risk of rate limits or service changes. OpenAI’s capacity pause in September 2026 is a concrete illustration: teams dependent on a single cloud provider can find themselves rationed.

Production harnesses that abstract the serving layer, such as Prefactor for cloud-side orchestration or MaskShift for local tool calling, reduce some of that overhead, but neither eliminates the operational responsibility of whichever side you choose.


Decision flowchart

flowchart TD
    A[Define agent use case] --> B{Regulated or sensitive data?}
    B -- Yes --> C[Local or private cloud inference]
    B -- No --> D{Latency requirement under 100ms?}
    D -- Yes --> E{Token volume above 500K/day?}
    E -- Yes --> C
    E -- No --> F[Cloud API]
    D -- No --> G{Complex reasoning or long context?}
    G -- Yes --> F
    G -- No --> H{Token volume above 500K/day?}
    H -- Yes --> C
    H -- No --> F

Hybrid patterns

Many teams in production run both. A local model handles high-frequency, low-complexity calls, such as intent classification, slot filling, or structured extraction, while a cloud API handles escalations and edge cases that exceed the local model’s reliable range.

Walmart’s inventory optimization system, which coordinates replenishment across more than 4,700 locations, is the kind of high-volume, structured-task workload where local inference for the inner loop and cloud inference for exception handling makes sense economically. The classification step runs thousands of times an hour; the edge-case reasoning step runs far less often.

If you take this path, you need a routing layer that decides which model receives each request, and you need agent observability across both paths so failures do not disappear into whichever side you are watching less carefully. You should also confirm that your AI agent governance policy covers both inference environments, not just the cloud-facing one.


What to check before you commit

Before finalising your inference path, confirm three things. First, run your actual task distribution against the candidate model, not a benchmark. Second, calculate your token volume over a 30-day window, not a peak day. Third, map every data field your agent processes against your compliance requirements.

If you are building AI agents for automation in a regulated industry, the compliance check alone often narrows the decision before latency or cost enter the conversation. If you are in a less constrained environment, cost at your expected volume is usually the deciding factor.

For teams evaluating local AI agents as a path to reducing cloud spend, the honest answer is that the savings are real above the breakeven thresholds but the operational lift is also real. Neither option is free.


Where to start

Map your use case against the five factors above, then take the agent readiness assessment to identify which infrastructure gaps need resolving before your agent reaches production. The assessment covers model selection, data handling, and operational readiness in one pass.

Matt DoughtyMatt DoughtyCEO & Co-Founder, Prefactor

Founder of Prefactor, writing on the operational reality of getting AI agents into production — evaluation, observability, governance, and the plumbing assistants never needed.

Frequently asked questions

At what usage volume does local inference become cheaper than a cloud API?

Based on May 2026 cost analysis, a 7B model breaks even with cloud API pricing at roughly 500,000 tokens per day, and a 70B model at around 2 million tokens per day. Below those thresholds, cloud APIs are usually cheaper once you factor in hardware, maintenance, and engineering time.

Can a locally hosted model handle tool calling without an internet connection?

Yes, if the model and the tool-calling harness both run locally. Production harnesses like MaskShift demonstrate this by executing tool calls entirely on-device, with no external dependency. The trade-off is that you own the reliability and update cycle for both the model and the harness.

What capability gaps should I expect from smaller on-device models?

Smaller models, typically under 13B parameters, perform well on narrow, well-specified tasks but degrade on multi-step reasoning, long context, and ambiguous instructions. If your agent needs to handle edge cases reliably without human review, test the local model against your actual task distribution before committing to it.

How does data residency affect the choice between local and cloud inference?

When you call a cloud API, your prompt and any included context leave your infrastructure and are processed on the provider's servers. For regulated data, such as patient records or financial transaction details, that transfer may breach compliance requirements regardless of the provider's certifications. Local inference keeps data within your boundary, but you then become responsible for model security and access control.

Stay ahead of the curve

No spam. Unsubscribe anytime. A resource by Prefactor.

Almost there — check your inbox to confirm your subscription.