← Blog
By the apillms team · Published 2026-09-30 · Claude Code · API setup · developer tools

Claude Code setup with ANTHROPIC_BASE_URL: step by step

Claude Code works with any Anthropic-compatible endpoint. apillms exposes one, so switching over is mostly a matter of setting two environment variables. Here's the full walkthrough, from sign-up to your first request.

1. Sign up and get starter credits

Create an account at apillms.com. New accounts get 50 free credits, which is enough to test the setup before you decide whether to add a paid pack. Credits never expire, so there's no rush to use them.

If you want to fund the account right away, packs are Starter $5, Builder $20, Pro $50, and Scale $100, payable by PayPal or card on the Billing page. You can also check /pricing for per-pack token estimates before choosing one.

2. Get your API key

Log in and go to the API keys page. Click Show key to reveal your key, or Roll key if you ever need to rotate it (rolling disables the old key immediately, so update your environment variables right after).

This page also lists the two base URLs you'll need:

Claude Code speaks the Anthropic API, so you'll use the second one.

3. Use the Claude Code setup tab

The API keys page has a setup tab specifically for Claude Code, with the exact environment variables and a code example already filled in with your key. If you'd rather browse integration guides for other tools first, they're all listed at /integrations, and the Claude Code one specifically is at /integrations?app=claude-code.

4. Set the environment variables

Claude Code reads its API base and key from environment variables. Set them in your shell config (or export them for the current session):

export ANTHROPIC_BASE_URL="https://apillms.com"
export ANTHROPIC_API_KEY="your_apillms_key_here"

On Windows with PowerShell:

$env:ANTHROPIC_BASE_URL="https://apillms.com"
$env:ANTHROPIC_API_KEY="your_apillms_key_here"

If you're adding these permanently, put them in your shell profile (.bashrc, .zshrc, or your PowerShell profile) so they persist across terminal sessions.

5. Choose a model

The Models & API page in your console lists every available model with capability filters, so you can see what's supported before picking one. For Claude Code, the natural choice is a Claude model since that's what the tool is built around.

Two options worth knowing the cost difference on:

ModelInput (per 1M)Output (per 1M)Cache read (per 1M)
$0.274

That table got confusing to render inline, so here's the same data as plain comparison instead. On apillms, $0.274 per 1M input tokens and $1.37 per 1M output tokens for claude-sonnet-5, with cache reads at $0.046 per 1M. For comparison, OpenRouter lists claude-sonnet-5 at $2 input / $10 output per 1M. If you want a heavier model, claude-opus-5-5 is $0.639 input / $3.19 output, versus $4 / $20 on OpenRouter.

Set the model in Claude Code's config, or just let it use the default and switch later. If you're unsure which model fits your workflow, the Claude vs GPT vs DeepSeek vs Grok comparison walks through tradeoffs for coding tasks specifically.

6. Run your first request

Open a project folder and start Claude Code as usual:

claude

Ask it something simple first, like explaining a file in your repo. If the environment variables are set correctly, you'll get a normal response. If you get an authentication error, double check the key was copied without extra whitespace and that ANTHROPIC_BASE_URL has no trailing /v1.

Because prompt caching is on automatically with per-user cache keys, repeated context in your agent turns (like the same system prompt or file contents) gets billed at the lower cache-read price instead of full input price on the next call. You don't need to configure anything for this, it just works in the background. For a deeper look at how much that saves in practice, see prompt caching explained.

7. Check the Usage page

After a few requests, go to Usage in your console. It breaks down spend by today, 7 days, and 30 days, with filters by product type and status, plus an Export CSV option if you want to review it outside the dashboard.

This is the easiest way to confirm Claude Code is actually routing through apillms: you should see chat completions or messages activity appear shortly after your first run. The Overview page also shows today's spend and recent activity if you want a quicker glance without digging into filters.

What it costs in practice

Using claude-sonnet-5, one typical agent turn (100,000 cache-read tokens + 5,000 fresh input tokens + 1,000 output tokens) costs $0.026 on apillms. Over 1,000 such turns, that's $26.23. If you're comparing models, deepseek-v4-flash runs the same turn at $0.006, or $5.88 for 1,000 turns, though it's a different model with different capabilities, not a drop-in substitute for Claude's behavior in an agentic coding loop.

If your bill is already higher than expected from a previous Claude Code setup, this breakdown of where Claude Code tokens go is worth reading, and /compare shows a live comparison against OpenRouter pricing if you want to see the gap for your specific model.

Takeaway

The whole setup is two environment variables and a key. Sign up, grab your key from the API keys page, point ANTHROPIC_BASE_URL at https://apillms.com, set ANTHROPIC_API_KEY, and run claude. Check the Usage page after your first session to confirm requests are landing, and you're done.

Try apillms

One API key for Claude, GPT, Grok, DeepSeek and Kimi. OpenAI- and Anthropic-compatible, prompt caching included, pay-as-you-go from $5 with PayPal or card. Credits never expire.

Get an API key Compare prices

FAQ

Do I need the /v1 suffix for Claude Code's base URL?

No. Claude Code uses the Anthropic-compatible endpoint, which is https://apillms.com with no /v1 suffix. The /v1 suffix is only for the OpenAI-compatible endpoint used by other tools.

What happens if a request fails partway through?

Failed requests are not billed, so a network error or a rejected call won't cost you credits.

Can I switch models without changing my API key?

Yes. The API key stays the same; you just change the model name in your Claude Code config or pick a different one from the Models & API page in your console.

How do I know Claude Code is actually using apillms and not some other endpoint?

Check the Usage page in your console after running a request. If the environment variables are set correctly, you'll see the activity show up there within moments.