← Blog

How to Monitor Claude API Spend in Real Time

2026-10-23 · 5 min read · SubToAPI Team

If you're spending money on the Claude API, you need to know how much, by whom, and for what — before the invoice arrives, not after. Real-time spend monitoring means capturing token usage and cost data at the moment each request completes, aggregating it somewhere queryable, and setting thresholds that alert you when spend crosses a limit.

The short answer: Anthropic's console gives you historical usage graphs, but they're not built for live, per-request, per-key tracking. To actually monitor spend in real time, you need either to build your own logging layer around every API call, or use a gateway that already captures usage metadata and exposes it via a dashboard and API. Below is how to do both.

Why "real time" is harder than it sounds with the raw Claude API

The Claude API itself doesn't push cost events to you. Each response includes usage data (input tokens, output tokens, cache reads/writes if applicable), but turning that into "spend right now" requires you to:

If you have one app and one API key, this is manageable with a logging middleware. If you have multiple apps, multiple teams, or customer-facing usage you need to bill back, it gets complicated fast — you end up building a mini billing system just to answer "how much did we spend today."

Option 1: Build it yourself with usage metadata

If you're calling the Claude API directly, the usage field in every response is your source of truth:

{
  "id": "msg_01...",
  "model": "claude-...",
  "usage": {
    "input_tokens": 512,
    "output_tokens": 128
  }
}

A minimal self-built monitor looks like this:

const PRICE = { input: 0.000003, output: 0.000015 }; // example $/token

async function trackedCall(payload) {
  const res = await callClaude(payload);
  const { input_tokens, output_tokens } = res.usage;
  const cost = input_tokens * PRICE.input + output_tokens * PRICE.output;

  await db.insert('spend_log', {
    timestamp: Date.now(),
    model: res.model,
    input_tokens,
    output_tokens,
    cost,
    key_id: payload.keyId,
  });

  await checkThreshold(payload.keyId);
  return res;
}

Then run a background job or trigger on insert that checks a rolling total against a budget and fires a webhook, Slack message, or email when it's exceeded. This works, but you're now maintaining:

For a side project, that's a few hours of work. For a team shipping multiple products on Claude, it's an ongoing maintenance burden that has nothing to do with your actual product.

Option 2: Use a layer that already tracks this

This is exactly the gap SubToAPI fills. It sits between your app and Claude as a clean HTTPS API, and because every request goes through it with its own sub_live_... key, it already has the data needed for real-time spend tracking — no separate logging pipeline required.

With SubToAPI you get:

A basic call through SubToAPI looks the same as calling Claude directly, just pointed at a different endpoint:

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

Because the usage and cost data is already tracked server-side, your dashboard reflects spend as soon as the request finishes — no separate pricing table to maintain, no cron job computing rolling totals. If you're evaluating whether to build this yourself or not, start with the quickstart and the messages docs — you'll see the response shape is a drop-in replacement for direct Claude calls, so adding spend visibility doesn't require rewriting your integration.

Setting up alerts, not just dashboards

Monitoring in real time is only useful if it triggers action. Whichever approach you take, set up at least two thresholds:

  1. Soft limit — a Slack/email notification at 70-80% of your expected monthly budget, so you have time to investigate before it's a crisis.
  2. Hard limit — a point where you either pause the key, throttle requests, or require manual approval to continue.

If you're building this yourself, this means a scheduled job comparing rolling spend to a constant and calling a webhook. If you're using a gateway, check whether it exposes usage via API so you can wire your own alerting logic on top — SubToAPI's docs cover the available endpoints for pulling usage data programmatically.

Streaming and tool use change the math

If you're using streaming responses, remember that cost is still based on total output tokens generated, not the number of chunks sent — don't be misled by request count as a proxy for spend. Similarly, tool use calls that trigger multi-turn exchanges (model calls a tool, you return a result, model responds again) multiply your token usage per conversation. Any real-time monitor needs to sum tokens across the full exchange, not just the first response, or your numbers will undercount actual spend.

Getting started

If you want spend visibility without building a logging and alerting system from scratch, sign up for a free trial and check the pricing page to see which plan fits your team size — Solo at €9 for individual use, Team and Scale for shared visibility across multiple keys.

Questions

Does the Claude API have built-in real-time spend alerts? No. The Anthropic console shows usage history, but it's not designed for live per-request alerting. You need to build logging around the usage field in each response or use a layer that already tracks it.

What's the fastest way to get per-team-member spend breakdowns? Issue separate API keys per person or project, then track usage against each key. Gateways with team seats, like SubToAPI's Team and Scale plans, do this natively without extra setup.

Does streaming make spend tracking harder? Slightly — you need to sum tokens across the full streamed response, not count requests or chunks, since cost is based on total input and output tokens regardless of how the response was delivered.

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 →