How to Turn Anthropic Claude Into a Public API Service
If you want to turn Anthropic Claude into a public API service, you're really solving three problems at once: giving external users or applications a stable HTTPS endpoint, protecting your underlying Anthropic credentials from exposure, and tracking usage so you can meter, bill, or rate-limit access. Claude's own API is built for direct, trusted use — it doesn't hand you per-application keys, team seats, or usage dashboards out of the box. Turning it into something you can expose to customers, teammates, or third-party apps means adding an authentication and metering layer on top.
This article walks through what that layer actually needs to do, how to build it yourself, and when it makes more sense to use a hosted solution instead.
Why You Can't Just Share Your Anthropic API Key
Anthropic issues a single API key per account (or a small number tied to your organization). That key has full billing exposure — anyone who has it can run unlimited requests on your account. If you want to:
- Let multiple apps or clients call Claude under your account
- Give teammates individual access without sharing root credentials
- Track who used how many tokens, for billing or budgeting
- Revoke access for one consumer without breaking everyone else
...you need a proxy layer that issues its own scoped keys, forwards requests to Anthropic, and logs usage per key. This is the core of "turning Claude into a public API service" — you're not changing what Claude can do, you're adding an API gateway in front of it.
Building the Layer Yourself
A minimal version of this is a reverse proxy that:
- Accepts requests with your own API key format (e.g.
sub_live_...) - Validates the key against a database
- Forwards the request body to Anthropic's Messages API using your real Anthropic key
- Streams the response back to the caller
- Logs token usage against the calling key
Here's a stripped-down example in Node.js:
import express from "express";
import fetch from "node-fetch";
const app = express();
app.use(express.json());
app.post("/v1/messages", async (req, res) => {
const callerKey = req.headers["authorization"]?.replace("Bearer ", "");
const account = await lookupKey(callerKey); // your own DB lookup
if (!account) return res.status(401).json({ error: "invalid_key" });
const anthropicRes = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"x-api-key": process.env.ANTHROPIC_API_KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
body: JSON.stringify(req.body),
});
const data = await anthropicRes.json();
await logUsage(account.id, data.usage); // metering
res.json(data);
});
This works, but it's the easy 20%. The remaining 80% is:
- Streaming support — piping Server-Sent Events through your proxy without buffering the whole response
- Rate limiting — per-key and per-plan limits that don't bottleneck on a single process
- Tool use passthrough — forwarding tool definitions and tool_use blocks correctly, including multi-turn tool loops
- Key management UI — issuing, rotating, and revoking keys without touching a database by hand
- Usage dashboards — showing token counts and cost per key, per day, per team
- Team seats and billing — mapping multiple users to one account with their own keys and limits
- Uptime and retries — handling Anthropic-side errors, timeouts, and backoff without dropping requests
None of this is hard individually, but together it's a few weeks of infrastructure work before you've shipped anything customer-facing — and it's work you'll maintain indefinitely as Anthropic's API evolves.
Using a Hosted Gateway Instead
If the goal is to expose Claude as a public API quickly rather than build a gateway from scratch, a hosted proxy like SubToAPI does this layer for you. You connect your existing Claude access once, and SubToAPI gives you:
- Application API keys in the
sub_live_...format, issued and revoked from a dashboard - Full streaming support for long responses
- Tool use passthrough, so function-calling workflows work unchanged
- Usage metadata per key — tokens in, tokens out, request counts
- Team seats, so multiple people can share one Claude subscription with individually scoped keys
The request shape mirrors Anthropic's own API, so migrating existing integrations is mostly a base URL and key swap:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize this ticket."}]
}'
Everything downstream — streaming, tool calls, usage tracking — works the same way it would against Anthropic directly. The difference is you're issuing your own keys to your own users instead of handing out your root Anthropic credential. See the quickstart, messages, streaming, and tools docs for the full request/response reference.
Which Approach Fits Your Situation
Build your own proxy if:
- You need deep custom logic in the gateway itself (custom auth schemes, non-standard routing, embedding this inside a larger existing platform)
- You already run infrastructure for API key management and billing that you want to reuse
- You have the engineering time to maintain it long-term
Use a hosted service if:
- You want a working public API in front of Claude today, not in three weeks
- You don't want to own streaming edge cases, rate limiting, or usage logging
- You need team seats or per-key usage breakdowns without building a dashboard
SubToAPI has a free trial at signup, with Solo at €9/month for individual use, Team at €19/seat for shared access with per-seat keys, and Scale at €49/seat for larger usage. Check pricing for the full breakdown, or go straight to /signup to connect your Claude access and get your first key.
questions
Can I legally resell access to Claude through my own API? Check Anthropic's usage policies and your account terms before reselling access commercially — most setups are fine for internal tools, teams, and B2B integrations, but resale terms vary by use case and plan.
Do I need to change my code if I already call the Anthropic API directly? If you move to a proxy like SubToAPI, you typically only change the base URL and the API key — the request and response structure for messages, streaming, and tool use stays the same.
Will a proxy layer add noticeable latency? A well-built gateway adds a small, consistent overhead (typically low milliseconds) since it mostly forwards requests and streams responses rather than processing them.