Paying $100 a month for Claude Code Max stings when you're not a power user. The good news: Claude Code has supported BYOK (Bring Your Own Key) from day one. You're not locked into Anthropic's subscription — you can point Claude Code at any API endpoint that implements the Anthropic Messages protocol, pay per token, and only pay for what you use.
Here's how to set this up with HiAPI in five minutes, what it saves you, and which model to pick for your workflow.
Why Claude Code Users Are Looking for Third-Party Keys
Claude Code is Anthropic's terminal-based coding agent — it reads your codebase, edits files, runs commands, and handles multi-step refactors. It's excellent software. The pricing, however, is built for two extremes.
Max costs $100/month (or $200/month for the top tier) and bundles Claude Code usage. That makes sense if Claude Code is your primary development tool and you're churning through millions of tokens daily — heavy users report saving $500+/month versus API pay-as-you-go. But if you use Claude Code a few times a week for code review, debugging, or the occasional refactor, you're paying $100 for a fraction of that value.
Pro ($20/month) includes limited Claude Code usage, but the caps are tight enough that they're more of a sampler than a daily driver.
API pay-as-you-go solves this: you pay only for the tokens you consume. The catch is that Anthropic's direct API pricing for high-tier models like Opus ($15/$75 per million input/output tokens) can add up fast. This is where third-party providers come in — they offer the same Claude models at lower per-token rates, and Claude Code works with any of them through two environment variables.
How Claude Code BYOK Works
Claude Code looks for two environment variables at startup:
ANTHROPIC_BASE_URL— the base URL of the API endpoint to use (defaults tohttps://api.anthropic.com)ANTHROPIC_API_KEY— the API key for authentication
That's it. Claude Code sends Anthropic Messages API requests to whatever endpoint you point it at. HiAPI's /v1/messages endpoint implements the Anthropic Messages protocol including tool use, streaming, and extended thinking. Note that Claude Code + HiAPI end-to-end compatibility hasn't been stress-tested yet — verify with a simple task after configuring.
Under the hood, Claude Code uses a standard Anthropic client. The ANTHROPIC_BASE_URL override is a built-in escape hatch, not a hack. Anthropic designed it this way to support enterprise deployments that route through internal proxies and cloud marketplace integrations (AWS Bedrock, Google Cloud Vertex AI). Third-party API providers like HiAPI sit on the same mechanism.
Why Choose HiAPI for Claude Code
HiAPI hosts four Claude models (prices as of 2026-10) at rates that make pay-as-you-go viable for individual developers:
| Model | Input $/M tokens | Output $/M tokens | Context | Cache Input |
|---|---|---|---|---|
| claude-sonnet-4-6 | $3.00 | $15.00 | 200K | $0.30 |
| claude-opus-4-8 | $2.29 | $11.47 | 200K | $0.23 |
| claude-opus-4-8@aws | $5.74 | $28.70 | 1M | $0.57 |
| claude-opus-5-5 | $2.02 | $10.08 | 1M | $0.10 |
The standout is claude-opus-5-5: $2.02/$10.08 per million tokens, roughly 87% less than typical Opus-class pricing ($15/$75). You get a 1M-token context window and dirt-cheap cache reads ($0.10/M) — ideal for large codebase sessions where most of the context gets cached across turns.

All four models support the full Anthropic Messages protocol: tool use, streaming, and extended thinking. HiAPI uses the standard Authorization: Bearer sk-<key> header and the /v1/messages endpoint path — the same contract Claude Code expects.
One limitation worth noting: Claude Code only works with Claude models. You can't use GPT, DeepSeek, or Grok inside Claude Code even if your provider offers them. HiAPI's non-Claude models remain available for other tools that speak the OpenAI Chat Completions protocol (Codex CLI, Cursor, and most AI coding assistants).
Setup Guide (5 Minutes)
Step 1: Get a HiAPI API Key
Sign up at www.hiapi.ai and grab an API key from your dashboard. Top up your account with whatever amount you're comfortable starting with — $20 is plenty for a week of testing.
Step 2: Set the Environment Variables
export ANTHROPIC_BASE_URL=https://api.hiapi.ai
export ANTHROPIC_API_KEY=sk-<your-hiapi-key>
Add these to your shell config (.zshrc, .bashrc, or .bash_profile) so they persist across terminal sessions.
Step 3: Launch Claude Code
claude
Claude Code will pick up the environment variables automatically. Run a quick test — ask it to explain a function or make a small edit — and check your HiAPI dashboard to confirm tokens are flowing.
Step 4: Verify Billing
After a few coding sessions, head back to your HiAPI dashboard and check your usage. You should see token consumption for the Claude model you selected, billed at exactly the rates listed above. No surprises, no monthly minimums.
Which Model to Pick: Sonnet vs Opus
The model you choose changes your cost more than anything else. Here's a practical guide:
Pick claude-sonnet-4-6 for daily coding. At $3/$15 per million tokens, it's the workhorse. Use it for code review, generating boilerplate, writing tests, explaining unfamiliar code, and routine edits. Sonnet is fast, affordable, and handles most development tasks without breaking a sweat.
Pick claude-opus-5-5 for complex work. Large-scale refactors, debugging across multiple files, system design discussions, and any task where you'd normally reach for Opus. At $2.02/$10.08, it's cheaper than Sonnet on input and only slightly more on output — but with a 1M context window and stronger reasoning. The ultra-low cache read price ($0.10/M) makes a real difference in long sessions where context gets reused across turns.
Pick claude-opus-4-8 for a middle ground. $2.29/$11.47 with 200K context. Comparable reasoning quality to opus-5-5 on most tasks, lower context ceiling, slightly higher cache prices. Solid if you want Opus-level reasoning without the full context breadth.
Pick claude-opus-4-8@aws for massive codebases. $5.74/$28.70 with 1M context. More expensive, but the only option if you need Opus reasoning on a codebase that won't fit in 200K tokens.
A practical strategy: Default to claude-sonnet-4-6 for everyday work. Switch to claude-opus-5-5 when you hit a problem that Sonnet struggles with — you'll know pretty quickly. The context switching is seamless: just re-export the environment variables (or set them per-session) and restart Claude Code.
If you're unsure where your usage lands, run with HiAPI for a week without changing your workflow. Check your token consumption, multiply by the model rates, and compare against $100/month. That gives you a real number, not a guess.
FAQ
Does Claude Code actually work with HiAPI's endpoint?
Claude Code uses the standard Anthropic Messages API. HiAPI implements this protocol at /v1/messages with bearer token auth — the same contract that Anthropic's own API uses. The integration relies on Anthropic's built-in ANTHROPIC_BASE_URL override, not a third-party shim.
Will I lose any Claude Code features?
The feature set depends on the endpoint's protocol support. HiAPI's Claude endpoint supports tool use, streaming, and extended thinking — the core building blocks Claude Code needs. If you notice unexpected behavior, it's worth comparing against Anthropic's direct endpoint in the same session to isolate provider-specific quirks.
Can I switch between models without changing providers?
Yes. All four Claude models are available through the same HiAPI endpoint. Just change which model name you pass. You don't need separate API keys, separate accounts, or separate billing — it's one key, one dashboard, one balance.
What about Anthropic's rate limits?
HiAPI has its own rate limits independent of Anthropic's. Check your HiAPI dashboard for your tier's limits. If you hit them, upgrade your plan or reach out to HiAPI support — you're not subject to Anthropic's per-account API caps.
Is this against Anthropic's terms?
Anthropic designed the ANTHROPIC_BASE_URL override for exactly this use case — enterprise deployments, cloud marketplace integrations, and third-party API providers. It's a documented feature, not a loophole.
How do I know which model Claude Code is using?
Claude Code shows the model name in its interface. You can also check your HiAPI dashboard — every request is logged with the model name, token count, and cost.
Can I use HiAPI's GPT or DeepSeek models in Claude Code?
No. Claude Code is built by Anthropic for Claude models only. HiAPI's GPT, DeepSeek, Grok, and other non-Claude models work with any tool that supports the OpenAI Chat Completions protocol — Codex CLI, Cursor, Windsurf, and most AI coding assistants.
I'm a heavy user. Should I still switch?
Benchmark first. Run a week of your normal workload through HiAPI, check the token totals, and do the math. If your consumption would cost more than $100/month at HiAPI's rates, the Max subscription is the better deal. Some power users save $500+/month with Max versus API pay-as-you-go — don't leave that on the table just because BYOK exists.
Using HiAPI as your Claude Code backend means you're not paying a subscription for one tool. One API key covers Claude Code and any other dev tool that speaks OpenAI or Anthropic protocols — pay for what you use, nothing more.
Claude Sonnet 4.6 model details · Claude Opus 5.5 model details





