# Claude Code API Without a Subscription

> Run Claude Code with an API key instead of Pro/Max: set ANTHROPIC_API_KEY or BASE_URL + AUTH_TOKEN, see how API billing works, and pay as you go.

- Canonical HTML: https://omniakey.com/blog/claude-code-api-without-subscription
- Markdown: https://omniakey.com/blog/claude-code-api-without-subscription.md
- Published: 2026-08-07 (updated 2026-10-24)
- Author: Kiki, COO at OmniaKey
- Language: en
- Category: Guide
- Reading time: 11 min
- All posts: https://omniakey.com/blog/llms.txt

---

**Short answer:** As of October 24, 2026, Claude Code runs without a Pro or Max plan as soon as you give it an API key. With an Anthropic Console key, set `ANTHROPIC_API_KEY` and Claude Code skips the login step once you approve the key. With an OmniaKey key, set `ANTHROPIC_BASE_URL=https://api.omniakey.com` and `ANTHROPIC_AUTH_TOKEN`, then start Claude Code from the same shell. At Anthropic's list price, Sonnet 5.5 costs $2 per million input tokens and $10 per million output tokens.

```bash
export ANTHROPIC_BASE_URL="https://api.omniakey.com"
export ANTHROPIC_AUTH_TOKEN="your-omniakey-api-key"
claude
```

Updated October 24, 2026: model names and prices now follow Anthropic's current catalog (Sonnet 5.5, Opus 5.5, Haiku 5.5, Fable 5.1), and the cost example is recalculated at the October 24 API rates.

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.

The local Claude Code CLI and the tools that wrap its credential path are the focus here. **Claude Code on the Web always uses subscription credentials**; environment API keys and gateway tokens do not override the hosted product.

## Set up Claude Code pay as you go with OmniaKey

### 1. Install Claude Code

Follow Anthropic's current [Claude Code setup instructions](https://code.claude.com/docs/en/setup), then confirm the command is available:

```bash
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](https://omniakey.com/dashboard/tokens). 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:

```bash
export ANTHROPIC_BASE_URL="https://api.omniakey.com"
export ANTHROPIC_AUTH_TOKEN="your-omniakey-api-key"
claude
```

For PowerShell:

```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](https://docs.omniakey.com/en/guides/claude-code-api-key) also covers Windows setup, model ids, and the endpoint it calls.

For the shortest product-specific path, keep the [OmniaKey Claude Code setup](https://omniakey.com/blog/claude-code-setup) beside your terminal while configuring the two variables.

### 4. Verify which billing path is active

Inside Claude Code, run:

```text
/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:

```bash
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.

Anthropic's API rates, checked October 24, 2026 on the official pricing page, are shown below in USD per million tokens. Prices can change, so check the live [model catalog](https://omniakey.com/models) before budgeting.

|Model|Input|Cache read|Output|100K input + 20K output|
|-|-:|-:|-:|-:|
|[Claude Haiku 5.5](https://omniakey.com/claude-haiku-5-5)|from $0.10|$0.01|from $0.50|**$0.02**|
|[Claude Sonnet 5.5](https://omniakey.com/claude-sonnet-5-5)|$2|$0.10|$10|**$0.40**|
|[Claude Opus 5.5](https://omniakey.com/claude-opus-5-5)|$4|$0.20|$20|**$0.80**|
|[Claude Fable 5.1](https://omniakey.com/claude-fable-5-1)|$10|$0.25|$50|**$2.00**|

For Sonnet 5.5 the arithmetic is 100K input × $2 per million = $0.20, plus 20K output × $10 per million = $0.20, so **$0.40** for that request. Opus 5.5 comes to $0.40 + $0.40 = $0.80, Fable 5.1 to $1.00 + $1.00 = $2.00, and Haiku 5.5 to $0.01 + $0.01 = $0.02 at its rate for prompts up to 100K tokens.

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 tasks. 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. Measure your own use before you assume either billing method is cheaper.

## Keep API spend under control

To reduce usage itself instead of only limiting the invoice, follow the [Claude Code token-reduction guide](https://omniakey.com/blog/reduce-claude-code-token-usage). It covers context, tool output, effort, and completed-task measurement.

### Start routine work on the right model

[Claude Sonnet 5.5](https://omniakey.com/claude-sonnet-5-5) is the balanced daily default: run `/model claude-sonnet-5-5` to pin it, or `/model sonnet` to follow the alias. Use [Claude Haiku 5.5](https://omniakey.com/claude-haiku-5-5) for narrow, repeatable tasks and [Claude Opus 5.5](https://omniakey.com/claude-opus-5-5) when ambiguity or the cost of an error justifies the higher rate. [Claude Fable 5.1](https://omniakey.com/claude-fable-5-1) is for agent sessions that run for hours. The [Claude Code model guide](https://omniakey.com/blog/best-model-for-claude-code) helps you pick.

### 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](https://omniakey.com/blog/transparent-billing).

## 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 tools, 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](https://code.claude.com/docs/en/authentication)
- [Anthropic: manage Claude Code costs](https://code.claude.com/docs/en/costs)
- [Anthropic: connect Claude Code to an LLM gateway](https://code.claude.com/docs/en/llm-gateway-connect)
- [Anthropic: Claude API pricing](https://platform.claude.com/docs/en/about-claude/pricing)
- [OmniaKey Claude Code API key guide](https://docs.omniakey.com/en/guides/claude-code-api-key)

_Fact-checked October 24, 2026. Authentication behavior, model availability, and rates can change; verify the linked first-party documentation and live catalog before relying on them._
