DEV Community

Cover image for Comparing the 5 Best LLM Gateways for Routing, Cost Control, & Security
Dev Stack Hub
Dev Stack Hub

Posted on

Comparing the 5 Best LLM Gateways for Routing, Cost Control, & Security

LiteLLM, OpenRouter, and Cloudflare AI Gateway are the three LLM gateways I would shortlist first. Kong AI Gateway and Portkey fit more specific setups, mainly teams that already run Kong or want a security-led platform. The ranking rests on three jobs a gateway has to do: route requests across models, keep spend under control, and keep sensitive data out of prompts and logs.

This comparison draws on each product's own documentation and pricing pages as of December 2026. Those pages describe what a product offers, not how well it performs, so the article does not rank anything on speed or uptime. Where a page gives no number, the article says so.

Key points

  • LiteLLM: Self-hosted, MIT license, per-key budgets and rate limits across 100+ providers.
  • OpenRouter: Hosted, 700+ models, list-price inference plus a 5.5% fee on Standard credit purchases.
  • Cloudflare AI Gateway: Analytics, caching and rate limiting are free on all plans.
  • Kong AI Gateway: PII redaction across 20 categories and 9 languages, best for teams already running Kong.
  • Portkey: Now part of Palo Alto Networks' Prisma AIRS, so confirm current pricing and open-source status.

What an LLM gateway does

An LLM gateway sits between your application and the model providers, so your code calls one API instead of one per provider. Once every request passes through one place, you can add the controls that are painful to build into each service separately.

In practice, the controls fall into three groups:

  • Routing: Send a request to a chosen model, spread load across deployments, and fall back to another model or provider when one fails.
  • Cost control: Issue keys with budgets and rate limits, cache repeated requests, and see spend by team or project.
  • Security: Filter or redact sensitive data in prompts and responses, and keep logs for audit.

The five gateways below cover all three groups, but they weight them differently.

How I picked

The comparison uses five criteria, each checked against the vendor's own documentation.

Criterion What we checked
Routing and reliability Provider coverage, load balancing, fallbacks and retries
Cost control Budgets, rate limits, caching and spend visibility
Security and data handling Guardrails, PII or DLP controls, retention options
Deployment and licensing Self-hosted or hosted, open source or commercial
Pricing transparency Whether the page states fees and plan limits

A capability the page does not mention is reported as not stated, not as missing. No gateway was load-tested for this article.

The five LLM gateways at a glance

The table summarizes what each vendor's documentation says. Details and limits follow in each section.

Gateway How you run it Routing Cost control Security
LiteLLM Self-hosted, MIT license Load balancing, fallbacks, retries across 100+ providers Virtual keys with budgets and rate limits, spend by key, team, user and tag Content filters and PII masking, SSO and audit logs on Enterprise
OpenRouter Hosted Auto-routing and fallbacks across 700+ models List-price inference plus a 5.5% fee on credit purchases (Standard) Zero Data Retention routing on every plan, data-policy routing on paid plans
Cloudflare AI Gateway Hosted on Cloudflare Dynamic routes with conditional flows, fallbacks Caching and rate limiting free on all plans Guardrails and DLP scanning
Kong AI Gateway Self-hosted or Konnect Provider-agnostic API, round-robin and lowest-latency balancing Semantic caching and an AI rate limiting plugin PII redaction in 20 categories and 9 languages, prompt guard
Portkey Open-source gateway plus hosted, now owned by Palo Alto Networks Fallbacks and weighted load balancing Response caching, semantic caching in hosted and enterprise versions 40+ pre-built guardrails

The 5 best LLM gateways

1. LiteLLM

LiteLLM is an open-source gateway, linked to an MIT license on its docs site, that supports 100+ LLM providers. Its strength is governance: every key carries its own models, budgets and rate limits, and every request is logged with its cost.

  • Routing: Load balancing, fallbacks and retries move traffic between deployments when a provider has a problem.
  • Controls: Virtual keys can be issued to users, teams and projects.
  • Cost visibility: Spend is broken down by key, team, user and tag.
  • Security: Content filters, PII masking and policies apply to requests and responses.
  • Observability: Logs and metrics can go to Langfuse, Datadog, OpenTelemetry and Prometheus.

Not ideal if:

  • You do not want to host and maintain a gateway yourself.
  • You need SSO or audit logs. The docs list both under the Enterprise tier, and that list overlaps with features described for the core product, so verify before committing.

Best for: Teams that want to self-host the gateway and control budgets per key.

Pricing: The software is open source. The docs page gives no Enterprise price.

2. OpenRouter

OpenRouter is a hosted service. The Standard plan lists 700+ models with no minimums or lock-in, and inference is billed at the provider's list price on every plan. OpenRouter earns its money through a platform fee on credit purchases instead.

  • Routing: Auto-routing and preferred vendors are included on the paid plans, and routing can try alternative models when a provider is down.
  • Reliability: Under Zero Completion Insurance, failed attempts are not charged for model tokens.
  • Data handling: Zero Data Retention routing is available on every plan, and data-policy-based routing is on the paid plans.
  • Bring your own keys: The first $25,000 of list-price inference each month carries no OpenRouter fee on Standard and Business, then 5% of list price.

Not ideal if:

  • You want to avoid a platform fee. It is 5.5% on Standard and 8% on Business.
  • You need per-team budgets. The pricing page does not describe them.
  • You do not want prompts to pass through a third party.

Best for: Teams that want one hosted API and key for many models, with nothing to deploy.

Pricing: Free (25+ free models, 50 requests per day), Standard at 5.5%, Business at 8%, and Enterprise with contract pricing.

3. Cloudflare AI Gateway

Cloudflare AI Gateway has a free tier for its core features. Per its pricing page, the gateway is available on all plans, and dashboard analytics, caching, and rate limiting are free.

  • Routing: Dynamic routes handle conditional flows with percentage-based traffic splits and rate and budget limits, plus fallbacks when a model is unavailable.
  • Cost control: Identical requests can be served from Cloudflare's cache.
  • Security: Guardrails check prompts and responses for harmful content, and DLP scans for PII and financial data.
  • DLP: Free on all plans with two predefined profiles, unless you have a Zero Trust subscription.

Not ideal if:

  • You want to stay off Cloudflare's platform.
  • You plan heavy guardrail use, since guardrails are billed as Workers AI token-based inference.
  • You need to pay by anything but credit card, since Unified Billing accepts only cards.

Best for: Teams already on Cloudflare that want free caching, rate limiting, and DLP.

Pricing: core features are free. Unified Billing adds a 5% fee on credits, so a $100 purchase costs $105. Gateways created before September 24, 2026, keep legacy log limits of 100,000 logs on Workers Free and 10,000,000 per gateway on Workers Paid, while newer gateways follow Workers Logs pricing.

4. Kong AI Gateway

Kong AI Gateway is built on Kong Gateway, and its AI plugins work in all deployment modes, including self-hosted, hybrid, DB-less, Kubernetes and Konnect. For a team that already operates Kong, it is the natural extension.

  • Routing: A provider-agnostic API, with listed providers including OpenAI, Anthropic, and Azure AI. The balancer supports round-robin and lowest-latency.
  • Cost control: The AI Semantic Cache plugin caches LLM responses, and the AI Rate Limiting Advanced plugin manages traffic to your LLM API.
  • Security: Automatic detection and redaction of sensitive data across 20 categories and 9 languages, plus an AI Prompt Guard plugin with allow and deny lists.
  • Observability: Token usage, latency, and cost through audit logs and metrics exporters.
  • Agents: An MCP traffic gateway for agent infrastructure.

Not ideal if:

  • You do not already run Kong and want something lightweight.
  • You need clear pricing or edition details. The overview page gives neither.
  • You need token-based rate limits. The page does not say whether the limits count tokens.

Best for: Platform teams that already run Kong for their APIs.

Pricing: Not stated on the overview page, so confirm licensing with Kong.

5. Portkey

Palo Alto Networks announced on May 29, 2026, that it closed its acquisition of Portkey and described Portkey as the core AI Gateway for its Prisma AIRS security platform. The Portkey gateway repository is listed under an MIT license.

  • Routing: Fallbacks to another provider or model on failed requests, and weighted load balancing across keys or providers.
  • Cost control: Response caching, with semantic caching marked as available only in hosted and enterprise versions.
  • Security: 40+ pre-built guardrails for input and output checks.

Not ideal if:

  • You need the open-source gateway's future guaranteed. The acquisition announcement does not mention it.
  • You rely on its model count. The repository gives 1,600+ in the description and 250+ in the README.
  • You rely on its "<1ms latency" claim, but it includes no benchmark.

Best for: Teams that want a gateway tied to a security platform and can confirm its current terms.

Pricing: Not verified. Portkey's pricing page now redirects to a Palo Alto Networks page that I could not open.

Recent changes in the LLM gateway market

  • Palo Alto Networks closed its acquisition of Portkey on May 29, 2026, and positions it as the core gateway of Prisma AIRS.
  • Cloudflare changed AI Gateway logging for gateways created on or after September 24, 2026, which now follow Workers Logs pricing instead of the legacy limits.

How to choose

Start from the constraint that is hardest to change, which is usually where the gateway runs and who owns the data path.

If you need Start with
Full control, self-hosting and per-team budgets LiteLLM
One hosted API and key for many models, no infrastructure OpenRouter
Free caching, rate limiting and DLP, and you already use Cloudflare Cloudflare AI Gateway
An extension of an existing Kong deployment Kong AI Gateway
A gateway tied to a security platform Portkey

Whichever you shortlist, send a week of your own traffic through it before you commit. Measure the latency it adds, the cost per successful request including fees, and how it behaves when you force a provider failure.

What to check before choosing

Beyond the feature comparison, work through these before putting a gateway into production.

1. Understand where your data goes.

A gateway makes model access easier, but it does not make your data private. Check how requests are processed, whether prompts and responses are logged, who receives the data, and what retention controls exist. Review this before going live with customer data or internal documents.

2. Test routing with real workloads.

A gateway that handles a basic chatbot may behave differently with streaming responses, agent workflows, or retrieval-augmented generation. Send a week of your own traffic through it and watch response consistency, latency, provider compatibility, and error handling.

3. Check fallback behavior.

Ask what happens when a model is unavailable, rate-limited, or slow. Failing over to another provider can improve reliability but may change response quality, latency, or cost. Force a provider failure in testing so you know the trade-offs before enabling automatic failover.

4. Look beyond basic cost tracking.

Token usage is only one part of spend. Consider model pricing, caching opportunities, the cost of unnecessary retries, request volume, platform fees, and the cost of using a powerful model for a job a simpler one could do. Measure cost per successful request, including fees. A good gateway helps you understand spending patterns, not just give you a total.

5. Understand operational responsibility.

A self-hosted gateway gives you control but also the maintenance. A managed gateway reduces ops work, but you need to review its deployment model, data handling, availability, and configuration options. These usually matter more than the number of supported providers.

Conclusion

An LLM gateway is more than a convenient way to connect model APIs. As your application grows, it becomes the control plane for routing, cost, security, and reliability.

LiteLLM suits teams that want to self-host with full control. OpenRouter suits teams that want one hosted API and the widest model choice. Cloudflare AI Gateway suits teams already on its platform. Kong fits organizations with existing API management, and Portkey fits those who want a security-platform-backed gateway, once its pricing and open-source status are confirmed.

There is no universal winner. A tiny app on a single model can do without a gateway. But as providers multiply, traffic grows, and cost becomes unpredictable, the gateway stops being optional.

Frequently Asked Questions

What is an LLM gateway?

It is a layer between your application and model providers. Your code calls one API, and the gateway handles routing, fallbacks, budgets, caching, guardrails, and logging.

Which LLM gateway is best?

LiteLLM, OpenRouter, and Cloudflare AI Gateway are the best LLM gateways. LiteLLM suits self-hosting, OpenRouter suits a single hosted API, and Cloudflare suits teams already on its platform.

Is LiteLLM free?

The gateway is open source and licensed under MIT. Its docs also describe an Enterprise tier that adds SSO/SAML, audit logs, spend tracking, multi-team management and guardrails. The docs give no price.

Does OpenRouter add a markup to model prices?

Its pricing page says inference is billed at the provider's list price on every plan. It charges a platform fee on credit purchases instead: 5.5% on Standard and 8% on Business.

Is Cloudflare AI Gateway free?

Core features, which are dashboard analytics, caching and rate limiting, are free on all plans. Guardrails, Unified Billing and Logpush carry separate charges.

Can a gateway protect sensitive data?

Several can filter or redact it. Cloudflare offers DLP scanning, Kong lists PII redaction across 20 categories, and LiteLLM lists PII masking. Test the detection on your own data, because the vendor pages do not give accuracy figures.

Top comments (8)

Collapse
 
debugtodeploy profile image
Vinay Shah •

Hot take after writing this: a lot of small apps don't need an LLM gateway yet. 🙃 If you're calling one model and your bill still fits on a sticky note, adding another layer may just give you one more thing to debug.

So where's your tipping point? A second provider, a surprise invoice, or the first time someone pasted customer data into a prompt? Tell me what pushed you, or why you're still happily calling the API directly. 👇

Collapse
 
devstackhub profile image
Dev Stack Hub •

Agreed, and I'd rather say it out loud than pretend every app needs a gateway. If you're on one provider, one model, and a bill you can eyeball, a direct API call plus a basic spending cap on the provider dashboard gets you most of the way. 🙂

For me the tipping point is whichever of these shows up first:

  1. The second provider. Once you want fallbacks or you're switching models per task, you start writing retry and routing glue yourself. That glue is what a gateway replaces.

  2. Spend you can't attribute. The surprise invoice isn't the real signal. Not being able to answer "which feature or key burned this?" is. That's when per-key budgets and logs start paying for themselves.

  3. Customer data in prompts. This is the one I wouldn't wait on. Even with one model, once real user data can end up in a prompt, you want redaction, logging controls, and an audit trail in one place instead of scattered across the codebase.

Until one of those hits, I'd skip the extra layer. A gateway is one more hop to debug, and "we added it early just in case" is how it becomes the thing nobody wants to own.

What pushed you, or are you happily calling the API directly? Curious which of the three people hit first. 👇

Collapse
 
mayur-upadhyay profile image
Mayur Upadhyay •

Saying "not stated" instead of "missing" when a vendor page is silent is the right call, and most roundups skip that distinction.

The "Not ideal if" lists helped most. The Cloudflare note that guardrails are billed as Workers AI inference and the OpenRouter platform fee (5.5% on Standard, 8% on Business) are the kind of costs that only show up after launch. Measuring cost per successful request, including fees, is a good way to compare gateways.

One question: if a team is already on Cloudflare but needs per-team budgets, would you pair it with LiteLLM, or does that add too much overhead? I'm curious how you'd handle that case.

Thanks for flagging the Portkey acquisition and the uncertainty around open source.

Collapse
 
devstackhub profile image
Dev Stack Hub •

Thanks, that's very kind. Measuring cost per successful request is the check I'd push people hardest on, because the gateway fees only show up once you're in production.

On your question: I haven't tested this combination, and the vendor pages don't describe it, so treat this as a judgment call rather than a benchmark.

The article doesn't state per-team budgets for Cloudflare. It does list rate and budget limits on dynamic routes, but nothing about issuing budgets per team. LiteLLM documents exactly that, with virtual keys, budgets and spend by key, team, user and tag.

If per-team budgets are a hard requirement, I'd try LiteLLM in front as the budget and key layer, pointing at Cloudflare as the upstream. You'd keep Cloudflare's caching, rate limiting and DLP and add team-level governance on top.

The overhead is real, though. You'd be running and patching a self-hosted service, and you'd have two places that log and count spend. Before committing, I'd check three things:

  • Do the budget numbers in LiteLLM match what Cloudflare reports? If they drift, finance will ask which one is right.
  • Does caching still behave as expected with the extra hop?
  • What happens to latency and failover when one layer is slow or down?

If you only need rough team-level visibility, tagging requests and reporting from Cloudflare's logs may be enough without adding LiteLLM. If teams need hard spending caps that cut off requests, LiteLLM is the safer way to get that.

Which is it for your team: hard caps, or just visibility?

Collapse
 
elsie-rainee profile image
Elsie Rainee •

Confession: after comparing all five, my answer to "which one should I use?" is still the annoying one: it depends on what you're willing to babysit. 😅 A server you host yourself, a platform fee, or one more vendor in your data path. Pick your headache.

So which did you pick, and do you regret it yet? I'm especially curious about fallback stories. Did it save you at 2 AM, or quietly send everything to a pricier model while you slept? 👀

Collapse
 
devstackhub profile image
Dev Stack Hub •

Ha, "pick your headache" is honestly the most accurate summary of the whole article 😄

Straight answer: I haven't run any of these in production, so I don't have a 2 AM war story for you. The comparison is based on each vendor's docs and pricing pages, and I didn't load-test any of them. I'd rather say that than invent a pick I supposedly regret.

Your silent-fallback scenario is exactly why "force a provider failure in testing" is on my checklist. Automatic failover can change quality, latency and cost without anyone noticing. The number I'd watch is cost per successful request, including fees and retries, rather than just whether the request succeeded. I'd also log which model actually answered each request and put a spend alert on it, so the "quietly sent everything to a pricier model" case shows up before the invoice does.

If I were starting a trial today, I'd run a week of real traffic through LiteLLM (if I'm fine hosting it) or OpenRouter (if I want nothing to deploy) and break a provider on purpose.

Have you hit a fallback surprise yourself? I'd love to hear which way it went. 👀

Collapse
 
gautamtalksdev profile image
Gautam K •

Really useful comparison. For anyone picking one, I'd look first at how each gateway handles per-key spending limits and logs, since those matter most once agents start making calls on their own.

Collapse
 
devstackhub profile image
Dev Stack Hub •

Thanks, glad it helped. I agree, and I'd put it near the top of the checklist. Once agents start calling models on their own, nobody is watching each request. Per-key spending limits are your safety net against a runaway loop or a leaked key. Logs are how you work out afterward what happened and who or what made the call.

If you're picking one, I'd test both before committing:

  • Limits: Can you set budgets per key, per team, or per agent, and what happens at the cap? A hard stop and a soft alert are very different in production.
  • Logs: Do they capture the key, model, tokens, cost, and latency per request, and can you export them to your own tooling?

Are you evaluating gateways for an agent setup right now? I'd be curious which of these two matters more in your case.