Self-Hosted LLM Gateway vs Claude API: Which to Pick
Self-Hosted LLM Gateway vs Claude API: The Short Answer
A self-hosted LLM gateway (LiteLLM, Portkey OSS, Kong with an AI plugin, or a homegrown proxy) is software you deploy and operate yourself to route, log, and rate-limit calls to one or more model providers. The Claude API is Anthropic's direct endpoint — you send requests straight to api.anthropic.com with your API key, no middleware involved unless you add it.
The real decision isn't "gateway vs API" — it's who operates the layer between your product and the model. If you run that layer, you own uptime, auth, retries, logging, and every provider API change. If you don't want to run it, you either go fully direct to Claude (minimal features, maximum simplicity) or use a managed layer like SubToAPI that gives you gateway-style features — API keys, streaming, usage metadata, team seats — without the infrastructure.
What a Self-Hosted Gateway Actually Gives You
Self-hosted gateways exist to solve real problems: multi-provider routing, centralized logging, cost attribution, and policy enforcement across teams. Typical features include:
- Provider abstraction — one request format routed to Claude, GPT, or open-weight models
- Rate limiting and budgets per team or API key
- Caching for repeated prompts
- Audit logs stored on your own infrastructure
- Custom retry and fallback logic you write yourself
The tradeoff is operational. You're now running a stateful service that needs to stay up 24/7, scale under load, handle secrets rotation, and get patched when a CVE drops. Every Anthropic API change (new headers, new streaming event types, new tool-use schema) is your team's job to track and ship.
# Typical self-hosted gateway config (LiteLLM style)
model_list:
- model_name: claude-sonnet
litellm_params:
model: anthropic/claude-sonnet-4-5
api_key: os.environ/ANTHROPIC_API_KEY
That config file is simple. What's not simple is the Kubernetes deployment, the load balancer, the secrets manager, and the on-call rotation behind it.
What Calling Claude Directly Looks Like
Calling the Claude API directly is the leanest path technically, but it leaves you without most of what a gateway provides. You get raw model access and nothing else:
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize this ticket."}]
}'
No per-application keys, no built-in usage dashboard, no team seat management — you build that yourself if you need it, or you ship without it and hope billing attribution never becomes a problem.
Where a Managed Gateway Fits Between Them
This is the category most teams actually want but don't always know exists: a hosted service that sits in front of Claude and gives you the gateway features — scoped keys, streaming, tool use, usage metadata — without you running any infrastructure.
SubToAPI is built for exactly this gap. You connect your existing Claude access once, then issue sub_live_... keys per application or per client. Each key gets its own usage metadata, so you can see which app is burning tokens without building a logging pipeline. The API mirrors the Claude Messages format closely, so switching from a direct integration is mostly a base URL and header change:
const res = await fetch("https://api.subtoapi.app/v1/messages", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
"content-type": "application/json",
},
body: JSON.stringify({
model: "claude-sonnet-4-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Summarize this ticket." }],
stream: true,
}),
});
Full request/response shapes are in the docs, with a dedicated page for streaming and tool use if your app needs function calling.
Comparing the Three Paths
| Factor | Self-hosted gateway | Direct Claude API | Managed gateway (SubToAPI) | |---|---|---|---| | Setup time | Days to weeks | Minutes | Minutes | | Ongoing ops | You own uptime/patching | None | None | | Per-app API keys | DIY | No | Built in | | Usage metadata per key | DIY | No | Built in | | Team seats/billing | DIY | No | Built in | | Streaming/tool use | DIY proxy logic | Native | Native | | Multi-provider routing | Yes, if you build it | No | No (Claude-focused) | | Cost | Infra + engineering time | Just Anthropic usage | Flat plan fee + usage |
If multi-provider routing across Claude, GPT, and open-weight models is a hard requirement — say, for a fallback strategy — a self-hosted gateway or a multi-provider SaaS gateway is the right tool. If you're specifically building on Claude and want application-level keys, streaming, and team management without running infrastructure, a Claude-focused managed layer is a faster, cheaper path to the same operational maturity.
When Self-Hosting Actually Makes Sense
Self-hosting earns its complexity when:
- You need strict data residency and can't send metadata through any third party
- You already run a platform team maintaining similar proxies for other services
- You need routing logic across more than two model providers with custom failover rules
- Compliance requires logs to never leave infrastructure you control
For everyone else — most startups and small teams shipping a Claude-backed feature — the ops cost of a self-hosted gateway usually outweighs the control it buys you.
A Practical Starting Point
If you're not sure which path fits, start with the smallest footprint that solves today's problem. Issue scoped keys per application, add usage tracking, and only build (or adopt) routing logic once you actually need a second provider. SubToAPI's free trial lets you test this with your existing Claude access before committing to either a custom proxy or staying fully direct. Check pricing for Solo, Team, and Scale plans, and the quickstart to get a key issued in a few minutes.
Questions
Is a self-hosted gateway more secure than a managed one? Not automatically. Security depends on how well you implement key rotation, network isolation, and patching — a poorly maintained self-hosted gateway is riskier than a well-run managed service.
Can I switch from a self-hosted gateway to a managed one later? Yes, if both speak a Claude-compatible Messages format. Keep your request/response handling decoupled from the gateway itself so swapping the base URL and auth header is the only change needed.
Does a managed gateway support streaming and tool use like Claude does natively? Yes — SubToAPI passes through streaming and tool use; see the streaming docs and tools docs for request formats.