Deployment deep dive12 min read

AI Gateways vs. Local LLM Runtimes: What Should You Actually Choose?

A practical framework for choosing among OpenRouter, Cloudflare AI Gateway, LiteLLM, Ollama, vLLM, SGLang, and hybrid AI infrastructure.

Published: September 2, 2026Last updated: September 3, 2026

This deep dive is for readers who have finished the deployment guide and are now deciding how to structure AI providers and APIs for their service. Read it when you start asking whether to call one model API directly, put a gateway in front, or run models on your own hardware.

Teams building AI products quickly encounter a crowded tool landscape: OpenRouter, Cloudflare AI Gateway, LiteLLM, Ollama, vLLM, SGLang, llama.cpp, and many others. They all appear to make large language models easier to use, so they often end up in the same comparison table.

That is where the confusion begins.

An AI gateway and a local LLM runtime solve different problems. A gateway manages requests across models and providers. A runtime loads a model onto your hardware and performs inference. One is the traffic-control layer; the other is the engine.

They are not necessarily alternatives. In a mature AI stack, they often work together.

The 60-second decision guide

If this describes your situationStart here
One provider and one model already meet the needCall that provider directly; a gateway may be unnecessary
You are comparing many hosted models with minimal setupOpenRouter
Your product already runs on Workers or PagesCloudflare AI Gateway
You need one controlled interface across cloud and self-hosted modelsLiteLLM
You want a private experiment on a laptop or workstationOllama or LM Studio
You need high-throughput self-hosted GPU servingBenchmark vLLM or SGLang with your workload

This article is based on official documentation as of 2026-09-02. Pricing and features change frequently, so verify the details in each provider's official docs before adopting anything.

The default for an early product is usually simpler than the final architecture. Add a gateway or self-hosted runtime when privacy, routing, reliability, or sustained usage makes the extra operating work worthwhile.

When calling the API directly is enough

A gateway is not a default requirement. If the following describe your situation, call the provider's API directly:

  • You use a single provider and a single model.
  • Volume is low, so cost attribution and fallbacks are unnecessary.
  • You have no compliance requirements such as audit logs or data residency.

In this case a gateway is just another server in the request path, adding latency and an operations burden. Do not adopt one early only because it might be useful later.

What an AI gateway does

Calling one model provider directly is simple enough. The complexity appears when a product needs multiple providers, model fallbacks, cost controls, team access, and consistent monitoring. Each provider has its own authentication, request format, rate limits, error behavior, and usage metadata.

An AI gateway inserts a control layer between the application and those providers. Depending on the product, it may provide:

  • A common API across multiple models
  • Routing, retries, load balancing, and fallbacks
  • Usage and cost tracking
  • Rate limits and spending limits
  • Request logs and performance analytics
  • Caching, guardrails, and access controls

This reduces provider-specific logic inside the application. It also makes it easier to test a new model or move traffic without rewriting the product.

Signals that you need a gateway

When several of these signals appear together, it is time to evaluate a gateway:

  • You use three or more providers or models.
  • You need automatic fallback when one model degrades or fails.
  • You need cost attribution per feature or per team.
  • You want rate limits and spending caps enforced outside application code.
  • Compliance requirements such as audit logs or data residency have appeared.
  • You want prompt caching to work across providers.

How the major gateway options differ

OpenRouter: broad model access with minimal setup

OpenRouter is attractive when a team wants to explore many models through one API. It is particularly useful during prototyping, evaluation, or product development when the winning model is not yet clear. Its provider-routing controls can also select endpoints according to factors such as price and availability.

Convenience still has a cost structure. Credit-purchase fees and bring-your-own-key allowances can vary by plan. At meaningful scale, teams should model the platform cost separately from the underlying inference cost and confirm the current terms in the official documentation.

Cloudflare AI Gateway: a natural fit for the Cloudflare stack

For products already built on Workers, Pages, or other Cloudflare services, AI Gateway can be an operationally convenient addition. Its documented feature set includes analytics, caching, rate limiting, spending controls, dynamic routing, guardrails, and data-loss-prevention capabilities. Some features may be in beta or subject to plan-specific limits.

The value is strongest when the broader Cloudflare platform is already part of the architecture. A team outside that ecosystem should compare the integration benefit against more provider-neutral options.

LiteLLM: open-source control across cloud and self-hosted models

LiteLLM provides a self-hosted, OpenAI-compatible gateway across many model providers. It supports routing, retries, fallbacks, budgets, and virtual keys. Crucially, it can also route to self-hosted backends such as Ollama and vLLM, making it useful as the control plane for a hybrid architecture.

Open-source software is not the same as zero total cost. A self-hosted gateway still requires deployment, persistence, monitoring, upgrades, security work, and incident response. The right question is not merely “Is the license free?” but “Can our team operate this reliably?”

Portkey and Kong: observability or enterprise governance

Portkey is worth considering when request-level traces, prompt management, and evaluation workflows are central requirements. Kong becomes relevant when an enterprise wants to extend an existing API-management, security, and policy framework to AI traffic.

At this stage, the number of available models matters less than auditability, regional data requirements, role-based access, guardrails, and integration with existing controls.

What a local LLM runtime does

A runtime loads model weights, manages compute and memory, and serves inference requests. Teams usually consider local or self-hosted inference for one or more of these reasons:

  • Sensitive data should not be sent to an external model API.
  • Sustained, predictable usage may justify owned infrastructure.
  • The product must operate offline or with unreliable connectivity.
  • The team needs direct control over latency, concurrency, or model versions.

Self-hosting does not automatically make a system secure. It transfers more of the security responsibility to the operator: identity and access management, encryption, logging, patching, and model supply-chain controls still matter.

Ollama and vLLM are tools for different purposes

Both run models on your own hardware, but they are designed for different goals. Ollama optimizes for downloading and running models quickly on a developer laptop; vLLM optimizes for production GPU serving with high throughput under concurrent load. Treating them as interchangeable alternatives leads teams to pick whichever installs more easily, which is the wrong criterion.

Choosing a runtime

Ollama: the easiest local starting point

Ollama offers a low-friction way to download and run models on a developer laptop or workstation. It is well suited to local experiments, offline demonstrations, personal tools, and development workflows.

Ease of installation should not be confused with production scalability. A multi-user product with high concurrency needs workload-specific benchmarking and may require a runtime designed for server throughput.

vLLM: production-oriented GPU serving

vLLM focuses on efficient GPU memory use and high-throughput serving. It is a strong candidate for internal AI platforms or customer-facing products that must handle concurrent requests. Its OpenAI-compatible server also reduces application integration work.

The tradeoff is operational complexity. GPU capacity planning, model compatibility, deployment topology, monitoring, and upgrades all require expertise. Generic benchmark claims are less useful than tests with your own model, context lengths, output lengths, and concurrency profile.

SGLang: compelling for repeated context

SGLang deserves attention for retrieval-augmented generation and agent workflows that repeatedly reuse a system prompt or a long shared prefix. Its architecture can improve efficiency when requests share substantial context. Because the project evolves quickly, teams should include version stability and model support in their evaluation.

llama.cpp and LM Studio: edge flexibility or graphical exploration

llama.cpp is valuable when quantized GGUF models must run across CPUs, Apple Silicon, and resource-constrained devices. LM Studio is designed for users who prefer a graphical interface for discovering, loading, and comparing local models. The former emphasizes portable inference; the latter emphasizes an accessible local workflow.

Operational capabilities to confirm before self-hosting

Putting a local runtime into production is the beginning of infrastructure operations, not a software install. Confirm that your team can own the following:

  • GPU cost management and hardware upgrade planning
  • Model updates and security patching
  • Monitoring and incident response, including on-call coverage
  • Data backup and recovery procedures

If any of these are beyond the team, a managed service is usually cheaper and more reliable in total. For teams with only one or two engineers, human time becomes the limit long before GPU cost does.

The practical answer is often hybrid

The cloud-versus-local choice is not binary. A practical production architecture can use one OpenAI-compatible interface while routing requests to different backends:

  1. The application sends every request to a gateway.
  2. The gateway applies policy based on data sensitivity, cost, latency, or required capability.
  3. Private or repetitive workloads go to an internal vLLM deployment.
  4. Complex reasoning or provider-specific features go to a cloud frontier model.
  5. If local capacity is exhausted, approved requests can fall back to a cloud model.

This design does not magically optimize cost, privacy, and quality at the same time. It gives the team a place to express the tradeoffs explicitly and change them without rewriting the application.

Quick selection: cloud, local, or hybrid

SituationRecommended approach
One provider, one model, low volumeCall the cloud API directly; no gateway
Multiple cloud models with minimal infrastructure workManaged gateway (OpenRouter, Cloudflare AI Gateway)
Sensitive data or repetitive high-volume requests are centralLocal runtime (vLLM, SGLang) plus GPU operations capability
Cost, privacy, and quality priorities differ per requestHybrid (LiteLLM across cloud and local backends)

Five questions to answer before choosing a tool

1. Whether the data can leave your environment

Start with regulatory, contractual, and privacy constraints. Check not only where inference occurs but also where prompts, responses, and logs are stored.

2. Whether demand is steady or bursty

External APIs can be economical for intermittent workloads. Sustained and predictable demand may improve the economics of self-hosting, but only if utilization is high enough to justify the hardware and operating effort.

3. How many models you really need

If one provider and one model meet the requirement, a gateway may add unnecessary complexity. The gateway becomes more valuable as routing, fallbacks, experimentation, and organizational controls become real needs.

4. Who will operate the system

The hidden cost of self-hosting is not just the GPU. It is engineering time for deployment, observability, security, upgrades, and incidents.

5. Defining failure behavior

Define fallback models, acceptable quality degradation, latency limits, and whether sensitive requests are ever allowed to leave the environment. A fallback that violates the data policy is not resilience; it is a security failure.

Frequently asked questions

Should I adopt OpenRouter or LiteLLM first?

Start with OpenRouter if you want minimal operational work. Consider LiteLLM when you also run self-hosted models or need internal control over budgets and access. The two are stages, not mutually exclusive choices.

Can an Ollama prototype go straight to production?

It can for internal tools or a handful of users. A service with concurrent multi-user traffic should move to a serving-focused runtime such as vLLM or SGLang and be benchmarked with the real workload.

Is a local LLM really free?

The license costs nothing, but GPUs, electricity, monitoring, upgrades, and incident response do. Self-hosting tends to win on total cost only when request volume is consistently high enough to keep utilization up.

Do I have to use Cloudflare to use Cloudflare AI Gateway?

No. It works standalone, but the operational benefits are largest when you already run on Workers or Pages. Outside that ecosystem, compare its complexity against provider-neutral options such as LiteLLM or OpenRouter.

When is the right time to introduce a gateway?

When you run three or more providers or models and real requirements appear: fallbacks, per-feature cost attribution, spending caps, or audit logs. Adopting one early on speculation only grows complexity.

Conclusion: choose the boundary, not the winner

For fast model exploration, OpenRouter or Ollama can be effective starting points. For a product already built on Cloudflare, Cloudflare AI Gateway may fit naturally. For provider-neutral control across cloud and local backends, LiteLLM is a strong candidate. For high-throughput self-hosted inference, evaluate vLLM or SGLang with your actual workload.

The most important decision is not which tool ranks first. It is where you want the boundary between managed convenience and direct control. Once that boundary is clear, gateways and runtimes stop looking like competitors and become complementary layers of the same system.

This article reflects publicly available information as of September 2026. Pricing, supported models, limits, and beta features can change; verify them in each product's official documentation before adoption.

References

Next steps

Deployment guide · Deep dives

Which Modern Cloud Database Should You Choose? Start With the Workload, Not the Feature List

Model infrastructure and data infrastructure jointly define cost and operational boundaries. Continue with the other decision guide.

About the Author

Jaehee Song

Jaehee Song

Enterprise data platform architect with 20+ years of experience building data systems for Fortune 500 companies. AI development educator who has taught vibe coding and AI development to hundreds of students. Founder of Seattle Partners, helping Korean technology startups navigate the US market.

Author of the AI Development Guide