Claude Code API Without a Subscription
Claude Code's local terminal can use API billing instead of a monthly Claude plan. You still pay for model usage; the difference is how authentication and billing work.
You can use the Claude Code API without a subscription in the local terminal by choosing an API-billed provider instead of signing in with a paid Claude.ai plan. Anthropic officially supports Claude Console API billing, cloud providers, and LLM gateways alongside Pro, Max, Team, and Enterprise subscription authentication.
With OmniaKey, that means funding a prepaid balance, creating an API key, and giving Claude Code both an Anthropic-compatible base URL and a bearer token. There is no recurring Claude subscription on this path, but every model request still consumes paid API usage.
Without a subscription does not mean free or unlimited. It means replacing a recurring plan and its included usage limits with metered API billing. You must use a funded, authorized API or gateway account.
Does Claude Code require a subscription?
Not for its local terminal workflow. Claude Code supports several legitimate authentication and billing paths:
| Path | How you authenticate | How you pay | Best fit |
|---|---|---|---|
| Claude Pro, Max, Team, or Enterprise | Subscription OAuth through /login | Recurring plan with included usage limits | Regular interactive use and Claude's hosted surfaces |
| Claude Console | Console login or ANTHROPIC_API_KEY | Anthropic API usage | Teams that want direct Anthropic API billing |
| LLM gateway such as OmniaKey | ANTHROPIC_BASE_URL plus ANTHROPIC_AUTH_TOKEN | Gateway balance or contract | Pay as you go, one balance, and centralized usage |
| Bedrock, Google Cloud, or Foundry | Cloud-provider credentials | Cloud-provider bill | Organizations already standardized on a cloud platform |
Anthropic's authentication documentation puts ANTHROPIC_AUTH_TOKEN ahead of both ANTHROPIC_API_KEY and saved subscription OAuth credentials. That is why a properly configured gateway session can run independently of a Claude subscription.
This article covers the local Claude Code CLI and the tools that wrap its credential path. Claude Code on the Web always uses subscription credentials; environment API keys and gateway tokens do not override that hosted surface.
Set up Claude Code pay as you go with OmniaKey
1. Install Claude Code
Follow Anthropic's current Claude Code setup instructions, then confirm the command is available:
claude --version
Installing the client does not fund model requests. The credential you choose next determines where usage is authorized and billed.
2. Fund the API account and create a key
Add balance to your OmniaKey account, then create a key in the API Keys dashboard. Use a separate key for each machine or automation environment so you can revoke one without interrupting the others.
Never commit the key to a repository, paste it into a shell history you share, or place it in a public issue. Treat it like a password.
3. Set the base URL and bearer token
For macOS or Linux:
export ANTHROPIC_BASE_URL="https://api.omniakey.com"
export ANTHROPIC_AUTH_TOKEN="your-omniakey-api-key"
claude
For PowerShell:
$env:ANTHROPIC_BASE_URL = "https://api.omniakey.com"
$env:ANTHROPIC_AUTH_TOKEN = "your-omniakey-api-key"
claude
ANTHROPIC_AUTH_TOKEN is sent as an Authorization: Bearer credential. Anthropic documents this variable specifically for gateways and proxies that use bearer-token authentication.
Use the bare host, without /v1. Claude Code appends /v1/messages itself. Setting https://api.omniakey.com/v1 produces the wrong /v1/v1/messages path.
The detailed Claude Code API key guide also covers Windows setup, model ids, and the exact endpoint contract.
For the shortest product-specific path, keep the OmniaKey Claude Code setup beside your terminal while configuring the two variables.
4. Verify which billing path is active
Inside Claude Code, run:
/status
Then make one small, read-only request and confirm that its usage appears in the OmniaKey dashboard. Verification matters because setting only ANTHROPIC_BASE_URL does not replace a saved subscription credential. A gateway needs both its base URL and its credential.
If you also export ANTHROPIC_API_KEY, remove it from that shell to make the intended path unambiguous:
unset ANTHROPIC_API_KEY
Do not unset a credential blindly in shared automation. First identify which provider the job is meant to use, then keep exactly that credential in its secret store.
What does pay-as-you-go Claude Code cost?
There is no honest universal monthly number. Claude Code is an agent loop: it repeatedly reads context, writes output, calls tools, sees results, and may spawn more work. Model choice, repository size, cached context, thinking, retries, MCP definitions, and parallel sessions all change the bill.
Current OmniaKey catalog rates checked on August 7, 2026 are shown below in USD per million tokens. Prices can change, so verify the live model catalog before budgeting.
| Model | Input | Cache hit | Output | Example: 1M input + 100K output |
|---|---|---|---|---|
| Claude Haiku 4.5 | $0.20 | $0.02 | $1.00 | $0.30 |
| Claude Sonnet 5 | $0.60 | $0.06 | $3.00 | $0.90 |
| Claude Opus 5 | $1.00 | $0.10 | $5.00 | $1.50 |
The example uses uncached input and excludes cache writes, long-context modifiers, special speed modes, retries, and any additional tool-driven turns. It is a comparable unit, not a prediction for a complete coding task.
Anthropic's own cost guide says API spend varies widely and recommends measuring a pilot instead of assuming an average will describe your workload. The same principle applies to any gateway: observe completed-task cost in your own repositories.
When API billing makes sense
Pay-as-you-go access is a good fit when:
- Claude Code use is occasional or bursty rather than daily;
- you want spending tied to actual requests instead of another seat;
- several coding tools should draw from one prepaid balance;
- you need revocable keys for local machines or CI;
- you want to choose a cheaper model for routine work and escalate explicitly.
A subscription can still be the better operational choice when you use Claude Code heavily every day, want Claude Code on the Web, need a subscription-only feature, or prefer a predictable seat purchase over metered usage. Do not assume either route is cheaper without measuring your own use.
Keep API spend under control
To reduce usage itself instead of only limiting the invoice, follow the Claude Code token-reduction guide. It covers context, tool output, effort, and completed-task measurement.
Start routine work on the right model
Use Claude Sonnet 5 as a balanced daily default, Claude Haiku 4.5 for narrow and repeatable tasks, and Claude Opus 5 when ambiguity or error cost justifies it. The Claude Code model guide gives a fuller routing policy.
Clear stale context between unrelated tasks
Long conversations resend more context. Rename a session you may need later, then use /clear before starting unrelated work. This reduces waste without discarding the saved session.
Disable tools you are not using
Every active integration can add tool definitions and results to context. Keep the MCP set focused, avoid dumping full logs into the session, and filter large command output before Claude reads it.
Judge completed work, not one response
A cheaper token rate can lose its advantage if the model needs repeated correction. Track the total cost of a merged fix, accepted review, or passing feature, including retries and human cleanup.
For the broader metering principles, read how transparent API billing should work.
Common mistakes
Setting only ANTHROPIC_BASE_URL
The URL changes the network destination, not necessarily the active credential. Supply the matching ANTHROPIC_AUTH_TOKEN and verify the result.
Adding /v1 to the base URL
Claude Code adds the Messages API path. Use https://api.omniakey.com, not https://api.omniakey.com/v1.
Mixing direct and gateway credentials
ANTHROPIC_AUTH_TOKEN has higher priority than ANTHROPIC_API_KEY, but leaving unrelated secrets in the same environment makes debugging harder. Give each shell or job one intentional billing path.
Expecting the hosted web product to use the API key
Claude Code on the Web uses subscription credentials. This pay-as-you-go configuration is for local CLI-based surfaces, not a way to unlock hosted subscription features.
Treating “no subscription” as “no payment”
API billing still requires funds. A zero balance, revoked key, or spending limit stops requests just as a plan limit can stop subscription usage.
FAQ
Can I use Claude Code without Claude Pro or Max?
Yes. The local CLI can authenticate through Claude Console API billing, a supported cloud provider, or an LLM gateway. You still need valid credentials and a funded billing account for the chosen provider.
Is Claude Code API usage free without a subscription?
No. Without a subscription, model calls are metered against the API or gateway account. “Pay as you go” describes the billing schedule, not free access.
Will an API key consume my Claude subscription allowance?
Not when the intended API or gateway credential is active. Anthropic documents API and gateway credentials ahead of saved subscription OAuth in authentication precedence. Use /status and the provider's usage dashboard to verify rather than guessing.
Can I use this configuration in Claude Code on the Web?
No. Anthropic states that the hosted web product always uses subscription credentials and does not let environment API keys override them.
Which OmniaKey variable should Claude Code use?
Use ANTHROPIC_AUTH_TOKEN for the OmniaKey bearer token and ANTHROPIC_BASE_URL=https://api.omniakey.com. Do not put /v1 at the end of the URL.
Sources
- Anthropic: Claude Code authentication
- Anthropic: manage Claude Code costs
- Anthropic: connect Claude Code to an LLM gateway
- Anthropic: Claude API pricing
- OmniaKey Claude Code API key guide
Fact-checked August 7, 2026. Authentication behavior, model availability, and rates can change; verify the linked first-party documentation and live catalog before relying on them.