Claude Code with an Anthropic API key — set up in 2 minutes
How to connect Claude Code to an Anthropic API key through LiteAI. Environment variables, opencode setup, base URL configuration.
Claude Code with an Anthropic API key — set up in 2 minutes
Claude Code is Anthropic's official CLI for agentic programming. Out of the box it connects to the Anthropic API using an sk-ant-… key, which has to be issued from your account and paid for in dollars. For developers outside the US this is friction: you can't issue the key without a foreign card, and the payment won't go through with most local BIN codes.
LiteAI solves this with no code changes: you paste our sk-bf-… key and route requests through our endpoint. The Anthropic SDK inside Claude Code sees an ordinary Anthropic API, the same Opus 4.8, Sonnet 4.6 and Haiku 4.5 models respond — but you pay with USDT, without a VPN, without anyone else's account.
What you'll need
- An installed Claude Code (Node.js 18+).
- A LiteAI API key in the
sk-bf-…format — buy Claude API tokens at $1 per 1M.
Then you have two setup options: quick (per terminal session) and persistent (via settings.json).
Option 1: Quick — environment variables per session
export ANTHROPIC_BASE_URL="https://api.liteai.tech/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-bf-..."
export ANTHROPIC_MODEL="claude-opus-4-8"
claude
After that claude launches as usual, but the requests flow through LiteAI. Good for one-off runs and experiments.
Option 2: Persistent — settings.json
If you don't want to export variables every time, write them into ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.liteai.tech/anthropic",
"ANTHROPIC_AUTH_TOKEN": "sk-bf-...",
"ANTHROPIC_MODEL": "claude-opus-4-8"
}
}
After saving, run claude from any terminal — the settings are picked up automatically.
Which endpoint to use
LiteAI exposes two base URLs:
| Format | URL | When to use |
|---|---|---|
| Anthropic-compatible | https://api.liteai.tech/anthropic |
Claude Code, the official Anthropic SDK, apps using x-api-key |
| OpenAI-compatible | https://api.liteai.tech/v1 |
Cursor, Zed, opencode, Cline, Kilo Code, the OpenAI SDK |
Claude Code uses the first one — it returns the native Anthropic SSE events and supports tool use out of the box.
What models are available
Once connected, Claude Code pulls the model list through our endpoint automatically:
- claude-opus-4-8 — the flagship, 200K context. For hard tasks: refactoring a large codebase, system architecture design, long reasoning chains.
- claude-opus-4-8-1m — the same Opus with a 1M-token context. Useful for working with an entire repository: you can fit all project files in a single request.
- claude-sonnet-4-6 — the main model for most tasks. We recommend it as the default.
- claude-haiku-4-5 — the fastest. Good for simple operations: renames, formatting, template generation.
Switch between models with claude --model claude-opus-4-8 or interactively via /model.
How many tokens does Claude Code spend
A typical working session — 30 minutes of agentic work: reading files, searching the project, generating patches, validating. That's ~200K–500K tokens total (input + output).
At LiteAI's pricing:
- 200K → $0.20
- 500K → $0.50
- 1M → $1
For comparison: the same session on Claude Max 5x at $100 gives you 500 fixed message slots, not tokens. If an active agent makes dozens of calls per minute, Max runs out in 2 hours. With LiteAI you pay only for what you actually sent.
How to verify the key works
curl https://api.liteai.tech/anthropic/v1/messages \
-H "x-api-key: sk-bf-..." \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-haiku-4-5",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Reply with the single word: hello"}]
}'
If you get a response, the key is valid. If you get 401 Invalid API Key, double-check that you copied the key with no spaces or line breaks.
If Claude Code complains about region or VPN
It shouldn't: LiteAI keys aren't bound to an IP, and our infrastructure works from anywhere without a VPN. If the CLI does throw a region error, update Claude Code (npm i -g @anthropic-ai/claude-code@latest) and restart the terminal.
What else the same key plugs into
A single sk-bf-… key works across all of these tools:
- Cursor — provider
OpenAI Compatible, base URLhttps://api.liteai.tech/v1, keysk-bf-…. - Zed — the
api_urlflag inlanguage_models.anthropic. - opencode — the
liteaiprovider in~/.config/opencode/opencode.jsonc. - Cline / Kilo Code / Continue — OpenAI Compatible with the same base URL.
- Python / Node SDKs —
anthropic.Anthropic(api_key="sk-bf-…", base_url="https://api.liteai.tech/anthropic")oropenai.OpenAI(api_key="sk-bf-…", base_url="https://api.liteai.tech/v1").
The full set of configs lives on the Documentation page.
Bottom line
Connecting Claude Code to an Anthropic API key through LiteAI takes about 2 minutes:
- Buy Claude API tokens at $1 per 1M.
- Copy the
sk-bf-…key from the @liteaitech_bot. - Set the two env variables or add the block in
~/.claude/settings.json. - Run
claude— it works with the same Opus 4.8, Sonnet 4.6 and Haiku 4.5 models.
No VPN, no foreign card, no waiting for account approval.
Ready to try LiteAI?
An Anthropic API key for Claude Opus, Sonnet and Haiku — in 30 seconds, paid with USDT.