← Blog

How to Add Claude API to an Existing SaaS Product

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

Adding Claude to a SaaS product you already run is a different problem than building an AI app from scratch. You already have users, billing, an auth system, and a codebase with its own conventions — Claude just needs to slot into that without becoming a second platform to maintain. The short answer: pick a single entry point for model calls (either Anthropic's API directly or a gateway in front of it), wrap it behind your existing auth and billing, stream responses where the UI needs it, and add usage tracking before you ship to real customers.

This guide walks through the decisions that actually matter when you're retrofitting Claude into a live product, not starting a greenfield AI project.

Why this is harder than a fresh integration

In a new app, you design the data model, the UI, and the API calls together. In an existing SaaS, Claude has to respect constraints that already exist:

None of this is hard individually, but it's easy to bolt on a Claude call in a hurry and end up with a feature that bypasses your billing logic or leaks API keys to the frontend.

Two integration paths

There are really two ways to add the Claude API to an existing product:

1. Direct integration with Anthropic's API. Your backend holds the API key, builds the request (system prompt, messages, tools), and calls the Messages API directly. This gives you full control but means you own key rotation, retries, rate-limit handling, and per-customer usage accounting yourself.

2. Integration through an API layer. You put a thin service between your app and the model — either one you build, or a product like SubToAPI that turns your Claude access into a standard HTTPS API with its own keys, streaming, and usage metadata per key. This is useful when you want to issue a separate sub_live_... key per customer, environment, or internal team without managing Anthropic credentials and billing reconciliation yourself.

Most teams start with path 1 for a prototype, then realize they need path 2's structure once more than one team or customer segment touches the integration.

Step-by-step plan

1. Scope the first feature narrowly

Pick one feature — a summarizer, a draft generator, a search assistant — rather than "add AI everywhere." Ship it, learn the usage pattern (token volume, latency tolerance, error rate), then expand.

2. Keep the model call server-side

Never expose an Anthropic key, or any model API key, to the browser. Your frontend calls your own backend endpoint; your backend calls the model.

// your existing backend route
app.post('/api/summarize', requireAuth, async (req, res) => {
  const response = 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: req.body.text }],
    }),
  });

  const data = await response.json();
  res.json(data);
});

The important part isn't the specific API — it's that requireAuth and your existing session logic sit in front of the call, so every request is already scoped to a logged-in customer.

3. Decide how usage maps to your pricing

If you charge per seat, you probably want to cap or meter AI usage per account rather than per request. Log tokens or request counts against your internal customer ID so you can later decide whether AI features are included in a plan tier or billed as an add-on. If you're issuing separate keys per customer or environment, check usage per key in one place — this is one of the reasons teams use SubToAPI's dashboard instead of parsing raw Anthropic billing exports.

4. Add streaming only where the UI needs it

Chat-style or long-generation features benefit from streaming; short structured outputs (classification, extraction, scoring) usually don't need it. Don't add streaming infrastructure to every endpoint — see the streaming docs for the request shape when you do need it.

5. Use tool use for anything that touches your own data

If the feature needs to look up a customer's records, call your internal APIs, or write back to your database, use Claude's tool-calling instead of asking it to guess. Define tools with clear schemas and let the model request them; your backend executes the actual call. Details and examples are in the tools docs.

6. Roll out behind a flag

Gate the new feature behind a feature flag tied to plan tier or an internal allowlist. This lets you test latency and cost with a small group before it's visible to every account, and gives you an easy kill switch if token usage spikes unexpectedly.

Where SubToAPI fits

If you don't want to manage Anthropic credentials, rotate keys across environments, or build your own per-customer usage dashboard, SubToAPI sits between your product and Claude: you get sub_live_... keys scoped per app, environment, or team seat, with streaming, tool use, and usage metadata already built in. Plans start at €9/month for solo use, with Team (€19/seat) and Scale (€49/seat) tiers for multi-key setups, and a free trial at signup. The quickstart and Messages API reference cover the request format if you're migrating from a direct Anthropic integration.

questions

Do I need to rebuild my auth system to add Claude? No. Keep your existing auth as-is and call the model from your authenticated backend routes. The model call is just another server-side operation your app performs on behalf of a logged-in user.

Should I let users choose the Claude model themselves? Usually not at first. Pick one model for the feature, ship it, and only expose model choice later if you have customers with distinct latency or cost needs that justify the UI complexity.

How do I avoid surprise AI costs in an existing pricing plan? Track usage per account from day one, set soft caps per plan tier, and alert yourself before a customer approaches a limit — don't wait for a billing surprise to find out usage patterns differ from your estimate.

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 →