← Blog
Claude CodeCostPricing

Claude Code Without a Subscription: Pay Per Token Instead

(prices in the text follow the live price list)

Short answer

Yes, you can use Claude Code without a Claude Pro or Max subscription: give it an API key and pay per token instead. With APIVAI, set ANTHROPIC_BASE_URL to https://api.apivai.com (no /v1) and ANTHROPIC_AUTH_TOKEN to your APIVAI key, then start claude; this key takes priority over a claude.ai login. Each session is billed from a prepaid balance, for example $1.15 / $5.74 per million input / output tokens for Claude Sonnet 4.6 as of 2026-10-10, with no monthly fee and no weekly cap. Pay-per-token is usually cheaper for light or irregular use, while a subscription can cost less if you run Claude Code for several hours every day.

Can you use Claude Code without Claude Pro or Max?

Yes. Anthropic's Claude Code authentication docs list several ways to authenticate: a Claude Pro or Max subscription, Claude for Teams or Enterprise, a Claude Console account billed through the API, cloud providers, and credentials passed in environment variables. A subscription is one of these options, not a requirement. (The Free plan does not include Claude Code; claude.com/pricing says "Claude Code is included in all paid plans".)

When Claude Code authenticates with an API key, every request is billed by input and output tokens instead of counting against a plan's usage limits. Claude Code itself works the same, including /model. You can use a Console key at Anthropic's list prices, or a Claude API proxy such as APIVAI that accepts the same Anthropic-format requests at lower per-token prices for most models.

How does Claude Code choose between a subscription and an API key?

According to the authentication docs (checked October 2026), when several credentials are present Claude Code uses the first one it finds in this order:

  1. Cloud provider credentials, when CLAUDE_CODE_USE_BEDROCK, CLAUDE_CODE_USE_VERTEX or CLAUDE_CODE_USE_FOUNDRY is set
  2. ANTHROPIC_AUTH_TOKEN, sent as an Authorization: Bearer header and meant for gateways and proxies
  3. ANTHROPIC_API_KEY, sent as an X-Api-Key header; in interactive mode Claude Code asks you once to approve it
  4. The output of an apiKeyHelper script
  5. CLAUDE_CODE_OAUTH_TOKEN, a long-lived token from claude setup-token that uses your subscription
  6. Anthropic profile and federation credentials
  7. The subscription login you created with /login

What this means in practice:

  • With ANTHROPIC_AUTH_TOKEN set, Claude Code uses that key even if you are also logged in to Pro or Max. Requests do not touch your plan's limits.
  • If you have a subscription and also set ANTHROPIC_API_KEY, Claude Code uses the key once you approve it. You can change that choice later with the "Use custom API key" toggle in /config.
  • Type /status to see which credential is active. When a login and a key are both configured, /status marks the one that is not in use.

How do I set up Claude Code with a pay-as-you-go key?

The short version is below; the full Claude Code setup guide covers Windows cmd, the settings.json alternative and a curl test.

  1. Create an account, top up (from $10, no subscription) and create a key on the Dashboard. Give the key a budget limit so one session cannot spend your whole balance.
  2. Set two environment variables. On macOS or Linux, add them to ~/.zshrc or ~/.bashrc:
export ANTHROPIC_BASE_URL="https://api.apivai.com"
export ANTHROPIC_AUTH_TOKEN="your-apivai-key"

In PowerShell, add them to your profile (notepad $PROFILE):

$env:ANTHROPIC_BASE_URL = "https://api.apivai.com"
$env:ANTHROPIC_AUTH_TOKEN = "your-apivai-key"
  1. Open a new terminal, run claude, then /status to confirm the token from your environment is the active credential.
  2. Pick a model with /model.
SettingValue
ANTHROPIC_BASE_URLhttps://api.apivai.com (no /v1, no trailing slash; Claude Code adds /v1/messages itself)
ANTHROPIC_AUTH_TOKENYour APIVAI key
ANTHROPIC_API_KEYLeave unset, so only one key is in play

Keeping your subscription as well? Leave plain claude on your claude.ai login and add an alias that sets the variables only for one command, for example in bash or zsh:

alias claude-api='ANTHROPIC_BASE_URL="https://api.apivai.com" ANTHROPIC_AUTH_TOKEN="your-apivai-key" claude'

claude then uses the plan and claude-api bills per token, handy when a limit hits mid-task.

What do Claude Pro and Max cost, and what limits do they describe?

As listed on claude.com/pricing in October 2026 (prices exclude tax):

PlanPriceUsage as described on the page
Pro$20 per month billed monthly, or $17 per month billed annually ($200 up front)"at least 5x more usage per 5-hour session than Free"; includes Claude Code
MaxFrom $100 per month, in 5x and 20x options"5x or 20x more usage per 5-hour session than Pro"; also lists monthly API credits for the Claude Platform

The page explains limits this way: "Every plan has usage limits that reset on a rolling five-hour session window, and paid plans add weekly limits on top". When you reach a limit you can wait for the reset, move to a higher plan or, on paid plans, turn on usage credits "to keep working at standard API rates". The page does not translate these limits into tokens, so any comparison with per-token billing is an estimate.

What does Claude Code cost per token?

Each Claude Code step resends its system prompt, tool definitions, the files it has read and the conversation so far. Below we assume one hour of active work is about 40 requests, each with about 40,000 input tokens and 1,000 output tokens. These are assumptions, not measurements; large repositories and long sessions send more, small tasks less. Months have 22 working days.

Usage (with Claude Sonnet 4.6)Requests per monthOfficial APIAPIVAI
Occasional: 8 hours a month320$43.20$16.56
Regular: 1 hour per working day880$119$45.53
Heavy: 4 hours per working day3,520$475$182

The same heavy month on Claude Opus 5.5 would be $244 on APIVAI ($634 at list price).

These figures ignore prompt caching, so treat them as an upper bound. Claude Code keeps its context stable so that repeated parts are cached automatically. For Claude Sonnet 4.6 on APIVAI, cache reads cost $0.12 per 1M tokens and cache writes $1.44, against $1.15 for normal input. As a rough estimate, if about 80% of a session's input is read from cache, the input part of the bill drops to around a third of the uncached figure.

When is a subscription cheaper, and when is pay-per-token cheaper?

Pay-per-token usually wins when:

  • Your use is light or irregular. A week without coding costs nothing; a subscription bills every month.
  • A team shares one budget. One balance, a separate key per person or project, each with its own budget limit.
  • You use GPT models too. The same key and balance work in OpenAI-format tools such as Codex CLI; see how to cut Claude Code and GPT API costs.
  • You do not want five-hour windows or weekly caps. Your limits are your balance, the key's budget and a rate limit of 60 requests per minute per key (support can raise it).

A subscription can be cheaper when:

  • You run Claude Code for hours every day, especially on Opus models or long autonomous tasks. If your per-token estimate is well above $100 a month and you stay inside the plan's limits, a flat fee is hard to beat.
  • You also use the Claude apps on the web, desktop or phone, which a plan covers and an API key does not.
  • You rely on features tied to a claude.ai login, such as cloud sessions.

A practical test: use pay-per-token for a week, read the total on your Dashboard, multiply by about 4.3 and compare it with $20 or $100. To compare Cursor and Codex CLI too, see Claude Code vs Cursor cost.

Which model should you use on a per-token budget?

Prices per 1M tokens on APIVAI as of 2026-10-10; the full list is on the pricing page:

ModelInput / outputGood for
Claude Sonnet 4.6$1.15 / $5.74Everyday coding, the most popular choice
Claude Sonnet 5.5$0.77 / $3.82Everyday coding on a newer model
Claude Opus 5.5$1.54 / $7.65Hard bugs, large refactors
Claude Haiku 4.5$0.38 / $1.92Simple questions, the cheapest option

Start on Sonnet and switch to Opus with /model when a task gets stuck. Model IDs change over time, so take them from the pricing page.

Troubleshooting

SymptomLikely causeFix
Claude Code still uses your Pro or Max limitsThe variables are not loaded in this terminalOpen a new terminal, run /status and check which credential is active
"Login expired · Please run /login"Claude Code is using a claude.ai login, not your keyLoad the variables (new terminal or alias) instead of logging in again
401 UnauthorizedWrong or deleted key, empty balance, or the key reached its budgetCopy the key again from the Dashboard, top up or raise the key's budget
401 although the key is rightA leftover ANTHROPIC_API_KEY or an old key in settings.jsonRemove the extra credential so only ANTHROPIC_AUTH_TOKEN is set
404 Not Found/v1 or a typo in the base URLUse exactly https://api.apivai.com
429 Too Many RequestsMore than 60 requests per minute on one keyWait a moment, or ask support for a higher limit

FAQ

Do I need Claude Pro to use Claude Code?

No. Claude Code also works with an API key billed per token. Set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN and it runs without any plan.

Can I keep my Pro or Max plan and still use an API key?

Yes. Use an alias such as claude-api that sets the variables for one command, and check with /status which credential a session uses.

Is pay-per-token cheaper than Claude Max?

It depends on volume. For a few hours a week it is usually cheaper; for several hours of Opus every day, Max can cost less if you stay within its limits. Compare a week of real Dashboard data with the plan price.

Are there weekly limits with an API key?

There are no five-hour windows or weekly caps. Usage is limited by your balance, any budget you set on the key, and 60 requests per minute per key by default.

Can I use GPT models with the same balance?

Yes, in OpenAI-format tools such as Codex CLI, with the base URL https://api.apivai.com/v1. Claude Code itself works with Claude models. Create an account, top up from $10 and paste your key into Claude Code.

Ready to start?

Get your API key in 30 seconds. Pay as you go for Claude and GPT.

Get Started