Suanlimao
← Back to all tutorials

Connect your tools

Claude Code

Use Claude Code in your terminal with requests going through our base URL.

About 8 minFor:Developers who already installed Claude Code

Before you start

  • Claude Code is installed per its official docs and claude starts
  • An API key (see Create an API key)
  • A Claude-family model on the model plaza that carries the Messages tag

Step 1 · STEP 0x01

Set two environment variables

Claude Code calls this kind of service an LLM gateway. Put the root address — without /v1 — in ANTHROPIC_BASE_URL, and the key in ANTHROPIC_AUTH_TOKEN (sent as a Bearer token).

bash
export ANTHROPIC_BASE_URL=https://api.suanlimao.shop
export ANTHROPIC_AUTH_TOKEN=<YOUR_API_KEY>
terminal
$ export ANTHROPIC_BASE_URL=https://api.suanlimao.shop$ export ANTHROPIC_AUTH_TOKEN=<YOUR_API_KEY>
This only applies to the current terminal window. For a permanent setup see step 4.
The full key is shown only once, at creation. Missed it? Revoke it and create a new one.

Create a key →

Step 2 · STEP 0x02

Check the address and key with one command

In the same terminal send a request that generates one token. Confirm it works before opening Claude Code — it tells you which side a problem is on.

terminal
$ curl -sS -i -X POST "$ANTHROPIC_BASE_URL/v1/messages" \    -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \    -H "anthropic-version: 2023-06-01" \    -H "content-type: application/json" \    -d '{"model": "<MODEL_NAME>", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}'HTTP/2 200…"content":[…]
Replace <MODEL_NAME> with a Claude model name copied from the plaza. 200 with JSON means address, key and model are right. 401 means the key is wrong; 404 is usually a wrong model name.

Open the model plaza →

Step 3 · STEP 0x03

Start Claude Code and confirm the route

terminal
$ claude> /statusAnthropic base URL: https://api.suanlimao.shopAuth token: ANTHROPIC_AUTH_TOKEN
  • /status should show an Anthropic base URL line with your address. If it is missing the variable did not reach the session; go back to step 1.
  • Then send a short message; a normal reply means it works.
With a gateway credential set, requests go through our service and are billed here, not against a claude.ai subscription.

Step 4 · STEP 0x04

Make it permanent

Put the variables in the user-level settings file ~/.claude/settings.json (Windows: %USERPROFILE%\.claude\settings.json) under env:

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.suanlimao.shop",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_API_KEY>"
  }
}
terminal
$ claude> /statusAnthropic base URL: https://api.suanlimao.shop
Never put the key in a project's .claude/settings.json: it gets committed and exposes your key.

The VS Code extension does not read your shell variables. Use claudeCode.environmentVariables in VS Code's user settings (JSON):

json
{
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_BASE_URL", "value": "https://api.suanlimao.shop" },
    { "name": "ANTHROPIC_AUTH_TOKEN", "value": "<YOUR_API_KEY>" }
  ]
}

Step 5 · STEP 0x05

Pick a model

terminal
> /model(在列表里选,或者用环境变量指定)$ export ANTHROPIC_MODEL=<MODEL_NAME>

If /model does not list our model names, set ANTHROPIC_MODEL to the name copied from the plaza. Models are priced differently — heavy use of an expensive model adds up quickly.

Anthropic states that Claude Code is not supported with non-Claude models through a gateway. Pick Claude models only.

✓ How to tell it worked

  • /status shows your address on the Anthropic base URL line.
  • A message gets a normal answer and the request appears on the Usage page.

FAQ

Claude Code still asks me to log in.

The variables did not reach Claude Code. Put them in ~/.claude/settings.json under env, or set them in the same terminal before running claude. If you were logged in to claude.ai and want the gateway instead, run /logout first.

I get 401.

Check the key first. A wrong variable can also give 401: ANTHROPIC_AUTH_TOKEN is sent as Bearer, ANTHROPIC_API_KEY as x-api-key. We accept both, but ANTHROPIC_AUTH_TOKEN avoids the extra “use this API key?” prompt.

400 with `Extra inputs are not permitted` or `context_management`?

A newer Claude Code sent experimental fields the model API rejects. Claude Code's troubleshooting table suggests setting CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 and retrying; if it still fails, open a ticket with the request_id.

Some features do not work (web search, MCP connector, huge context).

Server-side tools that the model vendor bills separately are not supported yet; see the Claude Code and Anthropic API page in the docs.

How do I see what it costs?

The Usage page summarizes by day and model. One Claude Code session makes many requests; that is normal.

Related tutorials

Still stuck?

Read the troubleshooting tutorials first. If that does not help, open a ticket with the request_id, time, model and the exact error (never paste your key).