← Blog

What Is an API Gateway and When Do You Need One?

2026-09-07 · 5 min read · SubToAPI Team

An API gateway is a single entry point that sits between clients and your backend services, handling things like authentication, rate limiting, routing, and logging so individual services don't have to. If you're searching for this term, you're probably trying to figure out whether your project needs one, which type fits your use case, or how to expose an internal service (including an AI model) as a clean, controlled API.

The short answer: you need an API gateway when you have more than one client consuming a service and you want consistent auth, metering, and observability without duplicating that logic everywhere. If you're a solo developer calling one internal function from one script, you don't need one yet. The moment you add a second consumer, a team, or a billing requirement, a gateway starts paying for itself.

What an API Gateway Actually Does

Strip away the marketing language and an API gateway does a small number of concrete jobs:

A gateway doesn't run your business logic. It's a layer of policy and plumbing in front of the services that do.

Build vs. Buy: The Real Trade-off

Most teams face this decision at some point: write your own thin proxy, or adopt an existing gateway product.

Rolling your own makes sense when your needs are narrow — a single auth check and a rate limiter can be 50 lines of middleware. It stops making sense once you need per-client billing, usage dashboards, team seats, or multiple environments, because you end up rebuilding a worse version of an existing product.

Adopting a gateway (open-source like Kong or Traefik, or managed like AWS API Gateway, Apigee, or a purpose-built product) makes sense when:

The mistake to avoid is treating "API gateway" as a single category. A generic gateway (Kong, NGINX-based proxies) is infrastructure — you still configure routing rules, write plugins, and manage upstream services yourself. A specialized gateway is opinionated toward one job.

API Gateways for AI Model Access

This is where things get specific if your "backend" is an LLM. If your team or product uses Claude through a shared Anthropic Console login, you run into a problem generic gateways don't solve out of the box: the underlying access isn't designed to be metered per application or per teammate. There's one login, one set of credentials, and no built-in way to hand out scoped keys, track usage per key, or bill it back internally.

That's the specific problem SubToAPI addresses. It's a gateway purpose-built for turning existing Claude access into a proper HTTPS API:

Compare that to setting up Kong or AWS API Gateway in front of raw model access yourself: you'd still need to write the auth layer, the per-key metering, the streaming proxy logic, and the billing rollups. A specialized gateway skips that build.

A Minimal Example

Once keys exist, calling through a gateway looks like any other HTTPS API call:

curl https://api.subtoapi.app/v1/messages \
  -H "Authorization: Bearer $SUBTOAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4",
    "max_tokens": 512,
    "messages": [{"role": "user", "content": "Summarize this ticket."}]
  }'

No difference from calling any other gateway-fronted service — which is the point. The complexity (auth, quota, streaming, metadata) is handled behind the endpoint, not in your application code. See /docs/quickstart and /docs/messages for the full request format, and /docs/streaming or /docs/tools if you need SSE responses or tool-calling in your requests.

Choosing the Right Gateway for Your Situation

A quick decision framework:

  1. Internal microservices, need routing and auth → generic gateway (Kong, Traefik, cloud-native option)
  2. Public API product with many external developers → managed API management platform (Apigee, AWS API Gateway) with a developer portal
  3. Shared AI model access across a team or app, need per-key billing and metering → a specialized layer like SubToAPI, since generic gateways don't understand model-specific concerns like streaming token usage or tool-call metadata

If you're in category 3 and want to skip the build-it-yourself route, signing up gets you API keys and a working endpoint faster than configuring a general-purpose gateway to fake model-aware metering.

Common Mistakes

questions

Is an API gateway the same as a reverse proxy? No. A reverse proxy forwards requests; a gateway adds policy on top — auth, rate limits, transformation, and metering. Every gateway uses proxying, but not every proxy is a gateway.

Do I need an API gateway for a single internal service? Usually not. Add one once you have multiple clients, need per-key usage tracking, or require consistent auth across services without duplicating code.

Can an API gateway handle streaming responses? Yes, if it's built to. Not all gateways proxy long-lived connections like SSE cleanly — check this specifically if you're streaming model output, as noted in /docs/streaming.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →