# API keys as a last resort, with a spend cap

> Let Claude Code fall back to an API key only when every subscription is out, with a spend cap on each fallback run. How it works in Shuriken.

Source: https://shuriken.sh/blog/api-keys-last-resort

Let Claude Code fall back to an API key only when every subscription is out, with a spend cap on each fallback run. How it works in Shuriken.

Update By Shuriken Updated 27 October 2026 4 min read

**Contents**

Every heavy Claude Code user eventually has the same thought at the same bad moment: "My subscriptions are all out, the agent is halfway through something, and I have an API key sitting right there. Why can't it just use that?"

It can. The trick is making sure it uses the key only then, and that "only then" doesn't quietly turn into a surprise bill. So that's how we built it.

## Subscriptions first, keys last #

In Shuriken, an API key is a source like any of your subscriptions. Press Switch settings at the top of Sources, and under When every subscription is out there's a switch: Switch to API keys. It's off until you turn it on.

With it on, the order is simple:

- Your chats run on your subscriptions, switching between them as each one reaches your switch point.
- Only once every subscription that could take the chat is out do API keys and endpoints step in.
- When a subscription has room again, chats go back to it.

The move is visible. A Switched to … card in the chat says which source took over and why, so you always know when you're on metered time.

Keys only take chats once every subscription is out, under a cap for each fallback run.

## A spend cap on every fallback run #

Each time your chats fall back to API keys, that stretch gets a spend cap (Spend cap per fallback in the same section). Past the cap, the keys stop taking chats and the work waits for a subscription to have room. It's on by default, starting at 25 US dollars, and you can change the amount. The cap counts the whole run for that agent's provider, across every key the run touches. It is not a cap per key, so three Anthropic keys don't get three times 25 dollars.

The cap belongs to the fallback run, not to the calendar. When a subscription takes chats back, the run ends, and the next time you fall back you start with a fresh cap. You can also turn the cap off. Then a fallback keeps spending until a subscription has room, and Shuriken still counts what it spends.

One detail we're glad we got right: if you pick an API key yourself and press Use, that isn't a fallback. You chose it on purpose, so the cap doesn't step in and stop you.

## Why keys go last #

Because they're metered. A subscription gives you a [5-hour window](https://shuriken.sh/guides/claude-5-hour-limit-explained) and a [weekly limit](https://shuriken.sh/guides/claude-weekly-limit-explained) for a fixed monthly price. An API key bills for every token. In Anthropic's words, "Claude Code charges by API token consumption" ([Claude Code docs](https://code.claude.com/docs/en/costs)).

That difference is also behind a classic trap. Anthropic's help centre warns that if an ANTHROPIC_API_KEY environment variable is set, "Claude Code will use this API key for authentication instead of your Claude subscription", which means API charges rather than your plan's included usage ([Claude Help Center](https://support.claude.com/en/articles/11145838-use-claude-code-with-your-pro-or-max-plan)). One forgotten line in a shell profile and your "free" sessions aren't free.

In Shuriken a key never sneaks in like that. It's a source you added on purpose, it takes chats only in the order above, and the switch to it is marked in the chat.

If you're still deciding between a plan and a key in the first place, our guide to Claude Code on an API key or a subscription, in the links below, does the sums.

Shuriken shows what every plan you hold has left in one figure, and what each turn costs as it runs.

[Try Shuriken](https://shuriken.sh/)

## How to add a key as a source #

- Open Settings › Sources, choose Add source and pick the agent, say Claude Code.
- Choose API key and paste it. For an Anthropic- or OpenAI-compatible service, choose Custom endpoint instead and fill in its Address and key.
- For an endpoint, give it a Label if you like and press Test: Shuriken checks that it answers and tells you how many models it reached.
- Press Switch settings at the top of Sources, turn on Switch to API keys and set Spend cap per fallback.

That's it. The key now sits at the back of the line, which is where it belongs. It shows on the Sources page next to your subscriptions, and [source switching](https://shuriken.sh/features/source-switching) handles the rest.

An API key sits in the Sources list beside the subscriptions, with its credits shown instead of limits.

Shuriken takes no cut of any of this, by the way. We never bill model usage: the provider bills your key directly. More on why in [Bring your own plans](https://shuriken.sh/blog/we-dont-bill-model-usage).

## A fallback with no bill per token #

Keys are a fine safety net, but it's still money. Since 5.1, local models are sources too: point one at Ollama, LM Studio or any OpenAI- or Anthropic-compatible address on your own computer or network. A local model is an endpoint, so it never goes ahead of a subscription. It takes chats when you pick it, or once every subscription is out, and on your own hardware there's no bill per token. Whether a local model can carry on your particular task is another question, but for a lot of chores it can.

[Try Shuriken](https://shuriken.sh/), add your plans first and your key last, and let the order do the worrying.

Try the free tool: [Claude limit reset tracker](https://shuriken.sh/tools/limit-resets/claude)

Share

[X](https://x.com/intent/post?url=https%3A%2F%2Fshuriken.sh%2Fblog%2Fapi-keys-last-resort&text=API%20keys%20as%20a%20last%20resort%2C%20with%20a%20spend%20cap)[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fshuriken.sh%2Fblog%2Fapi-keys-last-resort)[Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fshuriken.sh%2Fblog%2Fapi-keys-last-resort&t=API%20keys%20as%20a%20last%20resort%2C%20with%20a%20spend%20cap)[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fshuriken.sh%2Fblog%2Fapi-keys-last-resort&title=API%20keys%20as%20a%20last%20resort%2C%20with%20a%20spend%20cap)[E-mail](mailto:?subject=API%20keys%20as%20a%20last%20resort%2C%20with%20a%20spend%20cap&body=https%3A%2F%2Fshuriken.sh%2Fblog%2Fapi-keys-last-resort)

## Sources

- [Claude Help Center: Using Claude Code with your Pro or Max plan](https://support.claude.com/en/articles/11145838-use-claude-code-with-your-pro-or-max-plan) (accessed 22 October 2026)
- [Claude Code docs: Manage costs effectively](https://code.claude.com/docs/en/costs) (accessed 22 October 2026)

## Frequently asked questions

**Will Shuriken use my API key while a subscription still has room?**

No. With the API as a last resort, keys and endpoints take chats only once every subscription is out. As soon as a subscription has room again, chats go back to it.

**What happens when the spend cap is reached?**

The keys stop taking chats, and chats wait for a subscription to have room. Each new fallback run starts with a fresh cap.

**Can I turn the cap off?**

Yes. With the cap off, a fallback keeps spending until a subscription has room. Shuriken still counts what it spent.

**Does Shuriken charge for the API usage?**

No. Shuriken never bills model usage. The provider bills your key directly, at its own per-token prices.

**Can I use an API key as my main source instead?**

Yes. Pick it yourself and chats run on it. A key you chose on purpose isn't a fallback, so the fallback cap doesn't stop it.

Fuel

All your plans, in one fuel gauge.

Shuriken adds up what your subscriptions have left, one figure per provider and per limit, in the top bar.

[Try Shuriken](https://shuriken.sh/)

[How it works](https://shuriken.sh/features/fuel)

## Keep reading

- [Claude Code: API key or subscription?: Guide 27 Oct 2026 6 min read Pro and Max are flat-priced with 5-hour and weekly limits; an API key bills every token with no plan limits. How to compare with your own numbers.](https://shuriken.sh/guides/claude-code-api-vs-subscription)
- [Claude Max 5x vs 20x (2026): what you really get: Guide 27 Oct 2026 6 min read Claude Max 20x gives 20 times Pro's 5-hour allowance and Max 5x five. Anthropic publishes no weekly multiplier; users report 20x at 1.5 to 2 times 5x.](https://shuriken.sh/guides/claude-max-vs-max-20x)
- [Claude Team seats for Claude Code, explained: Guide 27 Oct 2026 5 min read Team Standard seats get 1.25x Pro's usage per session, Premium 6.25x, each with a 5-hour and weekly limit. Prices, Team vs Max, and a personal plan.](https://shuriken.sh/guides/claude-team-seats-for-claude-code)
- [No more waitlist: you're a Founding member: Update 27 Oct 2026 2 min read On 21 October 2026 the waitlist ended: everyone who signed up before launch, by account or email, gets Pro at no charge for as long as Shuriken runs.](https://shuriken.sh/blog/founding-members)
- [Claude Pro vs Max for Claude Code: Guide 27 Oct 2026 5 min read Pro suits a few Claude Code sessions a week; Max suits daily heavy use and parallel agents. Prices, limits, the signs you've outgrown Pro, and upgrading.](https://shuriken.sh/guides/claude-pro-vs-max-for-claude-code)

## Free tools

- [Claude limit reset tracker](https://shuriken.sh/tools/limit-resets/claude)
- [Codex limit reset tracker](https://shuriken.sh/tools/limit-resets/codex)
