← Blog

How to Turn Anthropic Claude Into a Public API Service

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

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:

...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:

  1. Accepts requests with your own API key format (e.g. sub_live_...)
  2. Validates the key against a database
  3. Forwards the request body to Anthropic's Messages API using your real Anthropic key
  4. Streams the response back to the caller
  5. 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:

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:

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:

Use a hosted service if:

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.

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 →