How do I set up Claude Code with a custom API base URL?
Last updated by the APIClaw team
Set the Anthropic base URL for Claude Code to https://apiclaw.biz, without any /v1 suffix, and use your APIClaw key as the auth token, in settings.json or shell exports. Plans start at $19 a month for 500 requests a day, with no per-token billing and no cap on tokens per request.
What you need before you start
Three things: Claude Code installed, an APIClaw account, and a model ID. Create an account at /ui/signup/. The free trial gives you 50 requests with no card, which is plenty to confirm the setup works. Copy your API key from the dashboard, where your keys and usage are listed.
Claude Code talks to the Anthropic Messages API. That detail decides the base URL. APIClaw serves the Messages API at the root of the site, so the address you give Claude Code is https://apiclaw.biz with nothing after it. The OpenAI-style address, https://apiclaw.biz/v1, is for clients such as Cursor, Kilo Code and the OpenAI SDKs. Claude Code adds its own Anthropic paths, so an extra path on your side breaks the request.
Step 1: edit settings.json
Open or create Claude Code's settings file. On macOS and Linux it is ~/.claude/settings.json. On Windows it is %USERPROFILE%\.claude\settings.json. If the folder does not exist yet, create it. Replace the contents with this, using your own key:
{
"env": {
"ANTHROPIC_BASE_URL": "https://apiclaw.biz",
"ANTHROPIC_AUTH_TOKEN": "sk-your-apiclaw-key",
"ANTHROPIC_MODEL": "claude-sonnet-5-5",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}Save the file and start Claude Code in your project folder. Do not commit this file with a real key in it. If you share a repository, keep the settings in your home directory rather than in the project.
Step 2 (alternative): shell exports
If you prefer environment variables, set the same values before launching claude.
export ANTHROPIC_BASE_URL="https://apiclaw.biz"
export ANTHROPIC_AUTH_TOKEN="sk-your-apiclaw-key"
export ANTHROPIC_MODEL="claude-sonnet-5-5"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"
claudeAdd the exports to ~/.bashrc or ~/.zshrc to make them permanent. On Windows PowerShell, use $env:ANTHROPIC_BASE_URL = "https://apiclaw.biz" and the same pattern for the other three variables, or use the settings file above, which works the same on every system.
What each setting does
| Setting | Value | Purpose |
|---|---|---|
| ANTHROPIC_BASE_URL | https://apiclaw.biz | Sends Claude Code's requests to APIClaw. Nothing after the domain. |
| ANTHROPIC_AUTH_TOKEN | Your APIClaw key | Authenticates every request. |
| ANTHROPIC_MODEL | claude-sonnet-5-5 | The model Claude Code uses by default. |
| CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC | 1 | Stops optional background calls that are not part of your coding work. |
Verify the connection
Run a small task from your project folder:
claude "List the top-level files in this project and say what each one is for."If Claude Code answers from your actual files, the connection works. Open your APIClaw dashboard afterwards and check the usage view to see the request counted against today's quota. That is also the quickest way to learn how many requests a typical task consumes.
Choose a model
Set ANTHROPIC_MODEL to any ID from the model hub. The Claude options and their request weights are below. Weight means how many requests a single call subtracts from your daily quota.
| Model ID | Weight | Good for |
|---|---|---|
| claude-sonnet-5-5 | 2 | Everyday coding, edits and test runs |
| claude-opus-5-5 | 3 | Harder refactors and long reasoning |
| claude-fable-5-1 | 3 | Heavy tasks where you want the largest model |
| deepseek-v4-flash | 1 | Cheap, fast drafts and simple edits |
Change the value in settings.json and restart Claude Code to switch models. The gateway does not switch models for you. If you set one ID, every request uses that ID.
How the quota works with an agent
Claude Code makes many API calls per task: reading files, planning, editing, running checks and summarizing. Each call counts as one request multiplied by the model weight. On the $19 Plus plan (500 requests a day) that is 250 Claude Sonnet calls. On the $39 Pro plan it is 500. On the $129 Ultimate Max plan (8,000 requests a day) it is 2,666 Claude Opus calls. Long context does not change the count: a call that carries 200,000 tokens counts the same as a call that carries 2,000.
The quota resets at 00:00 UTC. There is no 5-hour window and no weekly cap. Tokens per request are unlimited, but requests per day are not, so a plan still has a ceiling. For a deeper look at the agent case, read Claude Code without rate limits and the Claude Code docs page.
How this compares with other ways to run Claude Code
| Anthropic API per token | Claude subscription | APIClaw | |
|---|---|---|---|
| Price | Claude Sonnet 5.5: $2 input and $10 output per million tokens | Pro $20, Max 5x $100, Max 20x $200 | $19 to $129 a month |
| Limit | Credit balance | 5-hour session limits and a weekly limit | Daily request quota |
| Bill grows with tokens | Yes | No | No |
See Claude pricing for current subscription details. If the 5-hour or weekly limits are what stops you, the Claude Max alternative page explains how a request quota differs. One honest caveat: at low volume, paying per token is often cheaper than $19 a month. A plan pays off when an agent sends long contexts all day.
Use the Anthropic SDK with the same setup
If you build your own tool on the Anthropic Python SDK, the same base URL and key work:
import anthropic
client = anthropic.Anthropic(
base_url="https://apiclaw.biz",
api_key="sk-your-apiclaw-key",
)
message = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Review this function for bugs."}],
)
print(message.content[0].text)Troubleshooting
404 Not Found on every request. The base URL has an extra path. Set the Claude Code base URL to exactly https://apiclaw.biz, then restart Claude Code. Check that no shell export is overriding the value in settings.json, because exported variables take precedence in some setups.
401 Unauthorized. The key is wrong, has trailing whitespace or was pasted with quotes inside the quotes. Copy it again from the dashboard. Make sure you used ANTHROPIC_AUTH_TOKEN and that no leftover Anthropic account login is interfering. If you previously logged in with a Claude subscription, run the logout command inside Claude Code and start again.
Model not found. The model value must be an exact ID such as claude-sonnet-5-5. Old short names like "claude" are not valid. Copy the ID from the model hub.
429 Too Many Requests. Your daily quota is used up. It resets at 00:00 UTC. Either wait, set ANTHROPIC_MODEL to a lighter model such as deepseek-v4-flash for the rest of the day, or upgrade. The pricing plans list every tier up to 8,000 requests a day, and custom volume is available through Telegram support.
Nothing changes after editing settings.json. Claude Code reads the file at startup. Close the session and open a new one. Confirm the file is valid JSON, with no trailing commas.
Payment and independence
APIClaw takes cryptocurrency through NOWPayments, and no card is needed. See how to pay for an AI API with crypto. APIClaw is independent and not affiliated with Anthropic, OpenAI, Google or Cursor. APIClaw routes requests to models available through publicly available sources and provider APIs. For other editors, the Cursor guide and the Kilo Code guide cover the OpenAI-style setup.
Frequently asked questions
What base URL does Claude Code use with APIClaw?
https://apiclaw.biz with no /v1. Claude Code uses the Anthropic Messages format and appends its own paths. The /v1 address is for OpenAI-style clients.
Claude Code docsWhere is the Claude Code settings file?
On macOS and Linux it is ~/.claude/settings.json. On Windows it is %USERPROFILE%\.claude\settings.json. Put the four settings under an env object, or use shell exports instead.
Does Claude Code on APIClaw have a 5-hour or weekly limit?
No. The only limit is a daily request quota that resets at 00:00 UTC, from 500 requests a day on the $19 plan to 8,000 on the $129 plan. Tokens per request are unlimited.
Which model should I set in ANTHROPIC_MODEL?
Start with claude-sonnet-5-5, which counts as 2 requests. Use claude-opus-5-5 (3 requests) for harder tasks, or deepseek-v4-flash (1 request) for light edits.
Model hubCan I try it before paying?
Yes. The free trial gives 50 requests with no card, so you can confirm the setup works before you choose a plan.
Start the free trialReady to get started?
Every new account includes 50 free requests. No card required.
Create your free account