Choice 21. By Nicolas Dao · Last reviewed

Cloudflare AI Gateway, OpenRouter or LiteLLM?

My app calls several LLMs. Do I need an AI gateway, and which one: Cloudflare AI Gateway, OpenRouter, or a LiteLLM proxy I host myself?

OpenRouter by default: one key and one bill for every model, with fallbacks between providers, for 5.5% on credits. Cloudflare AI Gateway in front of it when you want logs, caching, rate and spend limits per client, and a way around OpenRouter itself, for a URL change and no fee. A self-hosted LiteLLM proxy only when every call and every log must stay inside the client's AWS account, in Sydney, in front of Bedrock, and the team will patch it: its 2026 supply-chain incidents make pinned versions non-negotiable. Usually two of them together: OpenRouter serves the models, the gateway controls the traffic.

When to pick which

Pick OpenRouter when

  • You want every model behind one key, one SDK and one bill, and switching models is one string.
  • Fallbacks between providers of the same model, and between models, without writing them.
  • Per-key credit limits for each client or feature, and traces sent to Langfuse, Datadog or PostHog.

Pick Cloudflare AI Gateway when

  • Logs, cost analytics, rate limits and spend limits per client, with no code change beyond a base URL, and no fee.
  • A fallback that goes around OpenRouter itself, straight to a provider with your own key.
  • Caching repetitive, identical prompts, or stopping personal data before it reaches a provider.

Pick LiteLLM, self-hosted when

  • Every request and every log must stay inside the client's AWS account in Sydney, in front of Bedrock, and no outside gateway is allowed.
  • The team will run it like any production service: pinned versions, a Postgres, patches within days.

Both, when

  • OpenRouter behind Cloudflare AI Gateway is my usual shape: OpenRouter picks and serves the model, the gateway logs and limits the traffic, and a gateway fallback reaches a provider directly if OpenRouter is down.
  • Per-user rules (login, quota, 50 messages a day) belong in your own Worker or Lambda, in front of either: a gateway knows the traffic, not the user.
  • LiteLLM and an outside gateway together defeats the point of LiteLLM: if the logs may leave AWS, a managed gateway does the job without a server to patch.

Questions that change the answer

  • Must the prompts and the logs stay in Australia? Then neither OpenRouter nor Cloudflare's logs qualify: Bedrock in Sydney, with LiteLLM if you need a gateway at all.

  • How many providers do you really call? One provider and no budgets to enforce needs no gateway: call it directly.

  • Who answers when the gateway breaks at 2 am? A managed one is someone else's pager; a self-hosted one is yours.

  • What do you need per client: spend caps, logs, separate keys? That decides between OpenRouter's key limits, a gateway per client, or both.

Proxy, router, gateway: the words

Three words get used for the same box, and they mean different things:

  • A proxy forwards requests. Mine is a Worker that holds the provider key, so the browser never sees it: The LLM streaming proxy is the worked example. Every app that calls a model from a browser needs one, gateway or not.
  • A router decides which model or provider answers each request: by price, by latency, by availability. OpenRouter is a router you rent.
  • A gateway sits in the traffic and governs it: keys, logs, cost per client, rate and spend limits, caching, retries and fallbacks. Cloudflare AI Gateway is one, and LiteLLM's proxy server is one you host.

So the real question is rarely "which gateway?". It's which of those jobs you need, and who should run each.

The short version

OpenRouter Cloudflare AI Gateway LiteLLM proxy, self-hosted
My verdict My default Watching: on my shortlist Not something I run
What it is A router that serves every model, on one key A gateway in front of any provider An open-source gateway you host
Serves models itself Yes, through its providers No: it forwards to them No: it forwards to them
Fee 5.5% on credits; with your own keys, the first $25,000 a month free, then 5% Free; logs beyond 20M events a month at $0.60 per million MIT-licensed; you pay the hosting, about $77 a month on AWS for one small setup (my estimate), and the engineer
Per-client control Credit limits per key One gateway per client: logs, rate and spend limits Virtual keys with budgets and spend tracking
Fallbacks Between providers and models Retries; route fallbacks for OpenAI-format requests Fallbacks and load balancing
Data in Australia No: global routing, in-region only for the EU and the US, on Business No: logs can't be pinned to a jurisdiction Yes, if you host it in Sydney in front of Bedrock
Who runs it OpenRouter Cloudflare You

OpenRouter: the router I already use

OpenRouter is how my client systems reach models: one SDK, one key, every vendor, and the price of each model passes through, plus 5.5% on credit purchases. Bring your own provider keys and the first $25,000 of usage a month carries no fee at all, then 5%. It already does the router's job well. If a provider of a model is down or slow, it tries the next; a models list falls back to another model; and provider routing can sort by price, latency or throughput, exclude providers, or require zero data retention.

It has a gateway's basics too: a credit limit on each key, presets that name a model with its fallbacks and parameters, and Broadcast, which sends traces to about twenty tools, Langfuse, Datadog and PostHog among them. For many apps that's enough, and adding a gateway in front buys nothing but a hop.

What it can't give you is a way out of OpenRouter. If OpenRouter itself fails, every model fails with it.

Cloudflare AI Gateway: control for a URL change

The gateway doesn't host models. You point the SDK's base URL at it, and every call to OpenRouter, Anthropic, OpenAI, Bedrock or Workers AI passes through Cloudflare first, where it's logged, counted, rate-limited, capped, cached if identical, and retried. One gateway per client and environment gives each client its own logs, cost analytics and limits, with no change to the app's code. The core is free; Workers Paid ($5 a month) includes 20 million log events a month.

Its best trick in front of OpenRouter is redundancy: a fallback that sends the request straight to a provider with your own key when OpenRouter is down. That fallback runs through dynamic routing, which only accepts the OpenAI chat-completions format, so it works for OpenRouter calls but not for Anthropic-format traffic such as Claude Code's, which still gets the logs, retries and limits.

Three limits to plan for. Spend limits are estimates from token counts, enforced with a lag, so they're a guardrail, not a wallet. The cache matches identical requests only. And a gateway token reaches every gateway and stored key in the account, so a client whose keys must be isolated gets an account of their own. Setup, the costs and the Claude Code variables are on the entry.

LiteLLM: a gateway you host and patch

LiteLLM's proxy server is open source (MIT, apart from an enterprise folder) and does a gateway's whole job: virtual keys, budgets and rate limits per key, spend tracking, fallbacks and load balancing across a hundred-odd providers, and guardrails. It needs a Postgres, and Redis once it runs on more than one instance. On AWS, one small Fargate task, a small Postgres and a load balancer come to roughly $77 a month at list prices, before logs, networking and the time of whoever runs it. That's my estimate, not a vendor price.

The case for it is narrow and real: a client whose prompts, answers and logs must all stay in their own AWS account in Sydney. Bedrock keeps the inference there; Cloudflare's logs and OpenRouter's routing don't. A LiteLLM proxy in the same account, in front of Bedrock, is the one gateway here that stays inside that boundary.

The case against it is 2026's record. In March, two releases on PyPI were malicious, published with the maintainers' PyPI credentials after a poisoned security-scanner GitHub Action stole them. On 21 October, version 1.107.0 was poisoned on PyPI and on the Docker latest tags with a credential stealer, traced back to a key leaked in May and never revoked. A gateway holds every provider key you own, so that's the worst place for a supply-chain compromise. If you run it: pin an exact version and image digest, never latest, build from a reviewed release, keep it off the internet behind your own auth, and give it keys scoped to what it calls.

Do you need one at all?

Often not on day one. An app on one provider, with no budgets to enforce per client, needs a proxy for the key and nothing else. OpenRouter covers the next stage, many models on one bill. A gateway earns its place when there are several clients to separate, spend to cap, or an outage you can't afford to wait out. And for strict Australian residency, the model call itself has to happen in Sydney first: Amazon Bedrock, compared with the alternatives in Anthropic API, Bedrock or OpenRouter?.

Sources, checked on 27 October 2026: AI Gateway pricing, AI Gateway dynamic routing, AI Gateway authentication, OpenRouter FAQ (fees), OpenRouter BYOK, OpenRouter provider routing, OpenRouter model fallbacks, deploying the LiteLLM proxy, LiteLLM enterprise features, LiteLLM security incident, 21 October 2026, Snyk on the March compromise, Datadog Security Labs on the October compromise.

More choices

  1. 01 Lambda, Web Functions or Workers? Where should this piece of logic run?
  2. 02 Lambda, Fargate or EC2? My Lambda is busy all day, or its reserved concurrency keeps going up. When is it time to move to a container, and where is the line?
  3. 03 SQS, EventBridge or SNS? Something happens in my app and other code must act on it. Do I put it in a queue, on an event bus, or on a topic?
  4. 04 SQS retries or Durable Functions? A job calls something flaky (a third-party API, an LLM, a slow Postgres). How do I retry it reliably, and when do I reach for Lambda durable functions instead of tuning SQS?
  5. 05 Durable functions or Step Functions? A job has several steps, retries and waits. Do I write it as a Lambda durable function, or as a Step Functions state machine?
  6. 06 pgvector or S3 Vectors? Where should my embeddings live?
  7. 07 Pulumi or Terraform? We're putting our infrastructure in code. Pulumi or Terraform, and what if we already run one of them?
  8. 08 Cloudflare or S3 and CloudFront for a website? Where should a website, SPA or PWA live, Cloudflare static hosting or S3 behind CloudFront, and where do its heavy files go?
  9. 09 CloudWatch and Firehose, side by side How do I keep chatty logs without a CloudWatch-sized bill?
  10. 10 Athena or DuckDB? How should I query my data lake, and what changed when AWS bought DuckDB's company?
  11. 11 Neon or Aurora? I need Postgres for an app on AWS. When is Neon the right call, and when does it have to be Aurora?
  12. 12 Better Auth or Cognito? Which sign-in should my app use, and what do I actually get for free?
  13. 13 Why I ended up on AWS Which cloud should my company run on, and is AWS just the one you know?
  14. 14 Better Auth, run yourself or managed by Neon? My app is on Neon. Should I run Better Auth myself, or switch on Neon Auth, which is Better Auth managed by Neon?
  15. 15 Stripe or PayPal Should we take payments with Stripe or PayPal, and when is PayPal worth the pain?
  16. 16 Tailscale or Cloudflare Tunnel? I need to reach a private box or VPC, or put a service from it online. Is that Tailscale or Cloudflare Tunnel?
  17. 17 Resend or SES? Our app sends email, and maybe a newsletter. Resend, or Amazon SES in our own AWS account?
  18. 18 WhatsApp or Telegram Our bot should reach users in a messaging app. WhatsApp or Telegram, and why did yours get blocked?
  19. 19 Which model, at what price Claude, GPT or an open model? Which is the cheapest model that's good enough, tier by tier?
  20. 20 Anthropic API, Bedrock or OpenRouter? My product will call Claude. Do I buy it from Anthropic directly, through Amazon Bedrock in the client's AWS account, or through OpenRouter?
  21. 22 Function URL or API Gateway? My Lambda needs an HTTPS endpoint. When is a function URL enough, and when do I start on API Gateway from day one?
  22. 23 Serper or DataForSEO Should an agent get Google results from Serper or from DataForSEO, and do the two overlap or work together?

Want this stack in your AWS account?

Cloudless Labs is a Sydney consultancy. We migrate on-premises systems to AWS, build serverless apps on this stack, and coach teams to ship with Claude Code and Codex.

Talk to us

Contact Us

For general inquiries, please contact us at:

For e-learning capabilities, please contact: