Claude Code Subscription or API Key: Billing Compared (2026)
The short version: if your usage is uneven and you want a predictable bill, choose a subscription. If your usage is heavy or you need to wire Claude Code into automation, choose an API key with pay-as-you-go billing. If you don't have a Claude account or can't easily pay overseas, you can consider a gateway that is compatible with the Anthropic API (follow each service's terms and your local regulations). All three work with Claude Code. They differ in billing unit, cost ceiling, and account requirements, covered below.
Official prices, quota rules, and supported regions change, so this article lists no specific prices. Treat Anthropic's official pages as the source of truth.
What login and billing options does Claude Code have?
| Option | How you authenticate | Billing unit | Cost ceiling |
|---|---|---|---|
| Claude subscription login | Run /login after starting and sign in with your Claude account | Fixed monthly fee with a usage allowance (per the official terms) | Yes. When the allowance runs out, wait for a reset or upgrade |
| Anthropic API key | Create a key in the Console, then set an environment variable or choose API billing at login | Per token used | None, unless you set a spending limit in the Console yourself |
| Gateway with a compatible API | Change the endpoint and enter the key the gateway issued | Set by the gateway, for example a monthly allowance | Set by the gateway |
Claude hosted by cloud providers can also be used with Claude Code, billed through the cloud account. Setup follows each provider's documentation and isn't covered here.
When does subscription login fit?
A subscription has a fixed monthly fee, and once the allowance is used up you usually wait for it to reset (whether you can pay extra to keep going is per the official documentation). It suits you if:
- You use it every day, with moderate volume, and don't want to worry about the bill each month.
- You work alone, mostly writing code interactively in the terminal.
- You also want the same account for the web app or desktop client.
The uncertainty is in the allowance: the quota, reset period, and available models for each plan are decided by Anthropic and may change. When you run long tasks back to back, the allowance is more likely to be your bottleneck than the monthly fee.
When does an API key fit?
The API bills per token. The more you use, the more you pay, but there is no hard wall where things stop once an allowance runs out. It suits you if:
- Your usage swings: some months you barely use it, others you use it in bursts.
- You call it from scripts, CI, or shared team setups and want several keys with separate tracking.
- You need to attribute costs to projects or individuals.
The risk is runaway spend: one looping task or one very long context can burn through a lot of tokens. If you take this route, first check in the Anthropic Console whether you can set a spending limit, then use /cost in a session to see the current session's usage (how that command displays for subscription users is per the official documentation). Prompt caching can reduce the cost of repeated context; see "How to use Claude prompt caching to save money".
Can the two methods conflict?
Yes. If you're logged in with a subscription and ANTHROPIC_API_KEY is also set in your environment, Claude Code may show an auth conflict warning, or it may bill you by API key without you noticing. Before switching, run /status in a session to see which credential is in use, then check your shell config and the env section of settings.json. For details, see "Claude Code auth conflict and 401 errors" and "Claude Code settings.json hierarchy, precedence, and env config".
The third option: using a gateway with a compatible API
Claude Code lets you set a custom endpoint, so any gateway compatible with the Anthropic API format can be used. The idea is to point the address at the gateway and swap in the key it issued. For the variable names and syntax, see "Custom API endpoints for Claude Code, Codex, and OpenCode".
Take AGI Plan as an example (AGI Plan is a commercial partner of cdnping). It is a monthly-subscription, multi-provider LLM gateway that settles in RMB (Chinese yuan) and needs no overseas credit card. It is compatible with both the OpenAI and Anthropic API formats, so Claude Code needs only one endpoint change, and no Claude account is required. The service states plainly that it is not an officially authorized channel. Some models are marked "overseas only"; check https://agiplan.dev/models for specifics. Setup steps and plans are at https://agiplan.dev/startup.
Before picking any gateway, make sure you can verify its billing method, data policy, and uptime. The self-check methods in "Is a Claude API relay reliable?" are a good reference.
How do you decide using your own numbers?
- Estimate your monthly token volume first. Use the method in "How to estimate Claude Code token usage" and extrapolate from a week of real use.
- Multiply that volume by the official API's current unit prices to get the monthly pay-as-you-go cost. Prices are per the official pricing page.
- Compare with the subscription's monthly fee, and also consider whether the subscription allowance is enough: if you often hit the limit, add the cost of upgrading or waiting to the real cost.
- If neither of the first two works for you (no account, payment restrictions), put the gateway's monthly fee and allowance into the same table.
A simple rule of thumb: if the computed API cost is clearly below the subscription fee, use the API. If it's clearly above, lean toward a subscription or a monthly plan. If they're close, decide whether you care more about a predictable bill or about not being interrupted by an allowance.
How do you verify after switching?
- Run
/statusto confirm the credential source and endpoint. - Make one small request and check the relevant dashboard (the Anthropic Console or the gateway panel) to confirm the call shows up and is billed the way you expect.
- If you can't connect, check Anthropic status and Is Claude Code down? first, then work through "Troubleshooting Claude Code timeouts and connection errors" layer by layer.
Next steps
Spend a week recording real usage with /cost or your dashboard bills, then apply the four steps above. If you need a gateway option, read the three-step setup on the AGI Plan setup page and try it with a small allowance before committing long term.