← Blog

Claude API Multi-Tenant SaaS Architecture Guide

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

If you're building a SaaS product that calls the Claude API on behalf of many customers, the question isn't "how do I call Claude" — it's "how do I isolate, meter, and secure that access per tenant without rebuilding Anthropic's infrastructure myself." That's what a multi-tenant Claude API architecture actually solves: giving each customer (or each team inside a customer) their own scoped access, usage tracking, and rate limits, while you keep a single underlying Claude account or set of accounts.

This matters because Claude API keys and usage are account-level by default. Anthropic doesn't give you per-customer sub-keys, per-customer spend caps, or per-customer usage dashboards out of the box. If you're reselling Claude capability inside your product — a chatbot builder, an internal tools platform, an agency serving multiple clients — you need a layer that turns one Claude account into many isolated, billable identities. Below is a practical architecture for that layer, plus where to build it yourself versus where a hosted gateway saves you weeks.

The core problem: one account, many tenants

A typical multi-tenant SaaS has three identity layers:

  1. Your platform account — the single Anthropic/Claude API key you hold.
  2. Tenants — your paying customers, each needing isolated usage and limits.
  3. End users — people inside a tenant's org, sometimes needing per-seat tracking too.

Claude's API has no concept of tenants or sub-keys. Every request you send uses the same credential and counts against the same account-level rate limits and spend. If Tenant A runs a runaway loop, it can throttle Tenant B. If Tenant A churns, you have no clean way to revoke just their access without rotating the key for everyone.

The fix is an application-layer gateway between your product and Claude that enforces tenant boundaries.

Architectural decisions you need to make

1. Tenant isolation model

Decide whether isolation happens at the request layer (your backend attaches a tenant ID to every Claude call and enforces limits in code) or the key layer (each tenant gets a distinct API key that maps back to usage and limits). Key-layer isolation is strictly better for auditability — you can revoke one tenant instantly, trace every request to its key in logs, and hand tenants their own credential without exposing your root Anthropic key.

2. Per-tenant rate limiting and quotas

Anthropic's rate limits apply to your whole account. To stop one tenant from starving others, you need a token bucket or sliding-window limiter keyed by tenant ID, sitting in front of the Claude call:

const buckets = new Map(); // tenantId -> { tokens, last }

function allow(tenantId, limit = 60, windowMs = 60_000) {
  const now = Date.now();
  const b = buckets.get(tenantId) || { tokens: limit, last: now };
  const elapsed = now - b.last;
  b.tokens = Math.min(limit, b.tokens + (elapsed / windowMs) * limit);
  b.last = now;
  if (b.tokens < 1) return false;
  b.tokens -= 1;
  buckets.set(tenantId, b);
  return true;
}

This runs in-process for a single server; for a distributed deployment, back it with Redis so limits hold across instances.

3. Usage metering for billing

Every Claude response includes token counts in its usage metadata. Multi-tenant billing requires capturing that per request, tagged with tenant ID, and aggregating it into your own ledger:

function recordUsage(tenantId, usage) {
  db.insert("usage_events", {
    tenant_id: tenantId,
    input_tokens: usage.input_tokens,
    output_tokens: usage.output_tokens,
    created_at: new Date(),
  });
}

Decide upfront whether you bill by token, by request, or by a flat seat price with soft usage caps — this changes how granular your metering needs to be.

4. Credential management per tenant

The cleanest pattern is issuing each tenant (or each of their environments) its own scoped application key, rather than routing everything through one shared secret buried in your backend. This is exactly the gap a service like SubToAPI fills: it turns your existing Claude access into HTTPS endpoints with individual sub_live_... keys per team or project, so you can hand a tenant-scoped key to a sub-account instead of building your own key-issuance service from scratch. See the quickstart for how key issuance works in practice.

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

Each tenant's key is independently revocable, shows up separately in usage metadata, and doesn't require you to maintain your own rate-limiting or key-rotation logic in front of the raw Anthropic API.

5. Streaming and tool use across tenants

If your product streams responses (chat UIs, live agents) or uses tool calling, make sure your gateway layer passes through SSE chunks and tool-use blocks without buffering the whole response — buffering kills perceived latency for every tenant simultaneously under load. Keep the tenant-ID tagging at the connection level so you can attribute streamed token usage correctly once the stream closes. Reference implementations for both patterns are in streaming and tools.

Reference architecture

Tenant request → Auth (tenant-scoped key) → Rate limiter (per-tenant bucket)
   → Claude API call → Usage recorder (per-tenant ledger) → Response to tenant

Each box above is something you either build yourself with Redis + a thin proxy service, or delegate to a gateway that already does key scoping, rate limiting, and usage metadata capture. Building it yourself is reasonable if tenant count is small and you need custom billing logic; delegating makes sense once you're managing more than a handful of tenants or multiple internal teams, since the operational surface (key rotation, abuse isolation, usage reconciliation) grows faster than it looks.

Where to draw the line

If you're early and have 2–3 pilot customers, a single shared key with an in-code tenant ID and a Redis rate limiter is enough. Once you cross into dozens of tenants, or you need teams inside your own company to get separate seats and keys without touching your core Anthropic credential, move to per-tenant application keys. SubToAPI's Team and Scale plans are built for that second stage — per-seat keys, shared dashboards, and usage metadata without writing your own gateway.

Questions

Do I need separate Anthropic accounts per tenant? No. One Anthropic account is fine; isolation should happen at the application layer through scoped keys, rate limiting, and usage tracking, not by multiplying Anthropic accounts.

How do I stop one tenant's traffic from throttling others? Enforce a per-tenant rate limiter (token bucket or sliding window, backed by Redis in distributed setups) in front of the Claude call, independent of Anthropic's account-wide limits.

Can I bill tenants by actual token usage? Yes — capture input_tokens and output_tokens from each response's usage metadata, tag it with the tenant ID, and aggregate into your own billing ledger or pull it from a gateway that already exposes per-key usage metadata.

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 →