Skip to content
Billfuse

How to set a spending limit on the Anthropic API

Last updated

Anthropic stops your API requests at three kinds of monthly limit: the spend cap that comes with your usage tier, a spend limit you set for your organization, and a spend limit you set for a workspace. This page shows where to find and set them, what your app sees when one is reached, and what they don't cover.

Everything here was checked against Anthropic's docs on November 12, 2026. The credit balance error message and the note on API keys were added and checked on November 13, 2026. The sources are linked under the sections they back up.

The short version

  1. In the Claude Console, open Spend limits.
  2. Next to Monthly spend limit, click Set limit or Adjust limit.
  3. Enter an amount. It can't be higher than your tier's cap.

To cap one workspace instead, open Workspaces, select the workspace and click Spend limits.

Three limits, from Anthropic and from you

You can use all three: a small limit on the workspace that runs agents or experiments, and an organization limit set to the most you could stand to lose in one month.

Sources: Anthropic, Rate limits → Spend limits, Anthropic, Workspaces → Workspace limits

Set a limit on the whole organization

  1. In the Claude Console, go to Spend limits. Your tier's monthly spend cap is shown there too.
  2. Next to Monthly spend limit, click Set limit or Adjust limit.
  3. Enter a new value. It can't be higher than your tier's cap.

Set a limit on one workspace

  1. In the Claude Console, open Workspaces and select the workspace.
  2. In the panel that opens, click Spend limits.
  3. Set the monthly limit. In the same place, you can add alerts for when spending reaches certain thresholds.

You can't set a spend limit on the Default Workspace. To cap an agent or an experiment, create a workspace for it, create a new API key in that workspace, and give the workspace a small limit. An existing key can't be moved to another workspace. Only organization admins can create workspaces.

Anthropic's docs don't describe a spend limit for a single API key, only for an organization and for a workspace. The Claude Code workspace is different: Anthropic says it is the only workspace that supports per-user monthly spend limits.

Sources: Anthropic, Rate limits → Setting your own spend limit, Anthropic, Workspaces, Claude Help Center, Create and manage workspaces

What happens when you reach a limit

What your app gets depends on which limit was reached.

A limit you set

Requests fail with error 400 and the type invalid_request_error. The message starts with “You have reached your specified API usage limits”, or “You have reached your specified workspace API usage limits” for a workspace limit, and says when access comes back. Raise or remove the limit to get access back sooner.

Your tier's spend cap

Requests fail with error 429 and the type rate_limit_error, the same as a rate limit. On the Messages API, the error's details.error_code is enforced_spend_limit_reached, and there's no retry-after header. Usage stays paused until 00:00 UTC on the 1st of next month, unless Anthropic raises your limit sooner. To ask for that, use Request tier increase on the Rate limits page in the Console, or contact Anthropic support if it's urgent.

Limits on the Claude Code workspace work differently: Claude Code requests over that workspace's limit can get a 429 with a retry-after header instead.

Sources: Anthropic, Rate limits → Reaching your spend cap, Anthropic, Errors

Stop your code from retrying a limit

Anthropic's official SDKs retry rate limits 2 times by default, and the spend cap's 429 looks like a rate limit. Anthropic says retrying it, including the SDK's automatic retries, fails until access comes back. In our test against a local server that sends Anthropic's documented spend cap error, one call with the SDK's default settings sent 3 requests. If your own code retries too, those retries add up. Check for a spend limit before you retry:

Python
import anthropic

# A spend limit you set on the organization or a workspace
YOUR_LIMIT = (
    "You have reached your specified API usage limits",
    "You have reached your specified workspace API usage limits",
)

# Your own retry loop decides, so turn off the SDK's 2 automatic retries
client = anthropic.Anthropic(max_retries=0)


def spend_limit_reached(error: Exception) -> bool:
    """True when Anthropic's response says a spend limit stopped the request."""
    if not isinstance(error, anthropic.APIStatusError):
        return False
    body = error.body if isinstance(error.body, dict) else {}
    info = body.get("error") or {}
    if error.status_code == 429:
        # Your tier's monthly spend cap. Anthropic documents this code
        # for the Messages API.
        details = info.get("details") or {}
        return details.get("error_code") == "enforced_spend_limit_reached"
    if error.status_code == 400:
        return str(info.get("message", "")).startswith(YOUR_LIMIT)
    return False


def is_retryable_rate_limit(error: Exception) -> bool:
    """True for a 429 that isn't a spend limit."""
    if not isinstance(error, anthropic.RateLimitError):
        return False
    return not spend_limit_reached(error)
TypeScript
import Anthropic from "@anthropic-ai/sdk";

// A spend limit you set on the organization or a workspace
const YOUR_LIMIT = [
  "You have reached your specified API usage limits",
  "You have reached your specified workspace API usage limits",
];

type ErrorBody = {
  error?: { message?: string; details?: { error_code?: string } };
};

// Your own retry loop decides, so turn off the SDK's 2 automatic retries
const client = new Anthropic({ maxRetries: 0 });

// True when Anthropic's response says a spend limit stopped the request.
function spendLimitReached(error: unknown): boolean {
  if (!(error instanceof Anthropic.APIError)) return false;
  const info = (error.error as ErrorBody | undefined)?.error;
  if (error.status === 429) {
    // Your tier's monthly spend cap. Anthropic documents this code
    // for the Messages API.
    return info?.details?.error_code === "enforced_spend_limit_reached";
  }
  if (error.status === 400) {
    const message = info?.message ?? "";
    return YOUR_LIMIT.some((start) => message.startsWith(start));
  }
  return false;
}

// True for a 429 that isn't a spend limit.
function isRetryableRateLimit(error: unknown): boolean {
  return error instanceof Anthropic.RateLimitError && !spendLimitReached(error);
}

Call the checks in your retry loop. When the rate limit check says yes, wait as long as the retry-after header says, or back off if there's no header. When the spend limit check says yes, stop and tell someone: the request will keep failing until the limit changes or access comes back.

The checks read Anthropic's response body instead of fields added in newer SDKs, so they don't need a recent SDK. We ran them with the Python SDK (anthropic 2.8.0 and 0.60.0) and the TypeScript SDK (@anthropic-ai/sdk 1.8.0 and 0.60.0), against a local test server that sends the errors described above. The newest SDKs also raise their own EnforcedSpendLimitReachedError for the spend cap. It's a kind of rate limit error, so the checks still work there.

Sources: Anthropic, Errors, Anthropic, Rate limits → Ramp limits, Anthropic, Python SDK → Retries, anthropic-sdk-python, anthropic-sdk-typescript

Prepaid credits stop requests too

Most organizations pay for Claude API usage with prepaid credits. Organizations with an invoicing arrangement are billed monthly instead. When the credits run out, you can't call the API until you add more.

Error message
Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits.

To fix it, buy credits on the Billing page in the Claude Console. Anthropic says purchased credits are available immediately. If you see it in Claude Code while you pay for a Claude plan, or it stays after you buy credits, the guide to this error covers those cases.

Anthropic's docs show this message on one page, about the API credits that come with Max, Ultra and Team plans, and give no status code. Developers report it as a 400 with the type invalid_request_error (GitHub issues from November 12 and November 13, 2026). A spend limit you set returns the same status and type, so read the message to tell which one you hit. The checks above don't treat this error as a spend limit or as a rate limit, so your loop won't retry it.

With auto-reload on, Anthropic buys more credits whenever your balance falls below an amount you choose. Then running out of credits may not stop a runaway loop, so set a spend limit as well.

Sources: Claude Help Center, How do I pay for my Claude API usage?, Anthropic, API credits for Max, Ultra, and Team plans

What the limits don't cover

Where Billfuse fits

Billfuse is the tool we built for these gaps. It doesn't replace Anthropic's limits. Keep them on.

More guides

It's free while Billfuse is in early access. You can try it with sample data first, no sign-up needed.