Skip to content
Billfuse

How to put a hard spending cap on OpenAI, Anthropic, Gemini and OpenRouter

Last updated

An AI agent stuck in a loop can spend a month's budget in one night. OpenAI, Anthropic, Google Gemini and OpenRouter all let you set a hard cap: a dollar amount where your requests start to fail. This guide shows where each cap is, what happens when you hit it, and what the caps don't cover.

Everything here was checked against each provider's own docs on November 6, 2026. The Anthropic and Gemini sections were checked again on November 12, 2026, and the OpenRouter section on November 13, 2026. The links are at the end of each section.

The short version

Set one on every provider you use, even if you also use a tool like Billfuse. It's free, and it's the fastest way to stop spending.

OpenAI

You can cap each project, and the whole organization. Both caps are monthly.

Set a cap on one project

  1. Open the project, then go to Project settings → Limits.
  2. Under Spend, click Edit spend limit.
  3. Enter a monthly spend limit.
  4. Turn on Enforce a hard limit. This switch is what blocks requests. Without it, nothing is blocked.
  5. Click Save.

Organization limits works the same way, but its cap is one total for all your projects together, not a cap for each project.

What happens when you hit it

Requests fail with error 429 and the code project_spend_limit_exceeded (or organization_spend_limit_exceeded for the organization cap). They work again when you raise the limit, or when the next month starts.

Watch out

More on OpenAI, including the other 429 errors and code that stops retrying a limit: How to set a hard spending limit on the OpenAI API.

Source: OpenAI, Spend limits

Anthropic

Accounts on the Start, Build and Scale tiers already have a monthly cap. You can set a lower one yourself.

Set your own cap

  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.

What happens when you hit it

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

Watch out

More on Anthropic, including workspace limits and code that stops retrying a limit: How to set a spending limit on the Anthropic API.

Sources: Anthropic, Rate limits → Spend limits, Claude Help Center, Create and manage workspaces

Google Gemini

Since March 2026, Google AI Studio lets you put a monthly cap on each project. Google Cloud Billing can do the same with a spend cap budget.

Set a cap on one project

  1. Open Google AI Studio and go to Spend.
  2. Under Monthly spend cap, click Edit spend cap.
  3. Enter an amount.

You need the project editor, owner or admin role.

Watch out

More on Gemini, including the 10-minute spend limit and code that stops retrying a cap: How to set a spending limit on the Gemini API.

Sources: Google AI Studio, Billing, Google blog, March 16, 2026, Google Cloud, Budgets, Google Cloud, Manage spend cap budgets

OpenRouter

Each API key can have its own credit limit. It's the only one of the four that can reset every day.

Set a cap on one key

  1. Give the key a credit limit in dollars.
  2. Choose when it resets: daily, weekly or monthly. Resets happen at 00:00 UTC, and weekly ones on Monday.

OpenRouter's docs describe both settings for creating and updating keys through its API.

What happens when you hit it

Requests with that key fail with error 403, and the error's limit_source is openrouter_key_limit. OpenRouter's docs also list a spent key limit under error 402, so check limit_source, not only the status. The limit applies to that key only.

Watch out

More on OpenRouter, including workspace budgets and code that stops retrying a limit: How to set a spending limit on the OpenRouter API.

Sources: OpenRouter, Create a new API key, OpenRouter, Errors and Debugging, Limits

What the caps don't cover

A setup that works

  1. Put a hard cap on every provider. Make it the most you could stand to lose in one bad month.
  2. Give agents and experiments their own project, workspace or key, with a much smaller cap. On OpenRouter, use a daily limit.
  3. Add alerts well below the cap, so you hear about a problem before things stop.

If a key has already leaked, see what to do first when an AI API key leaks.

Where Billfuse fits

Billfuse is the tool we built for the gaps above. It doesn't replace the caps. 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.