Claude Code CLI

Connect Claude Code to Token Share

Install Claude Code from scratch on macOS, Linux or Windows and point it at Token Share with one paste. Includes the common errors and their fixes.

Before you start

  1. 1Sign in to Token Share and open the API Keys page.
  2. 2Click Create key, choose the Inference type, and copy the key that starts with sk-token-. It is shown in full only once.
  3. 3Top up with USDT on the Billing page. Claude models are paid from topped-up balance only.

Not comfortable with a terminal? Use the Claude desktop app instead, or set things up by clicking in CC Switch. Claude Code already installed? Skip to Connect to Token Share.

Install Claude Code

Claude Code installs with npm, which comes with Node.js. Install Node.js 22 or newer first and open a terminal.

  1. 1Download Node.js from nodejs.org: pick the LTS version and click macOS Installer (.pkg), then run it. Linux users can install it with their package manager.
  1. 2Open Terminal: press ⌘ + Space, type “Terminal” and press Enter, or find it in Launchpad under Other.
  1. 1Download Node.js from nodejs.org: pick the LTS version and click Windows Installer (.msi), then click through the installer with the defaults.
  1. 2Open a terminal: press Win + S, search for Terminal (on Windows 10, PowerShell) and open it. Every command below is typed there.

If PowerShell says a script such as npm.ps1 “cannot be loaded because running scripts is disabled on this system”, run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned, answer Y, and run the command again.

In the terminal, run:

npm install -g @anthropic-ai/claude-code

If it fails with EACCES (permission denied), run it again as sudo npm install -g @anthropic-ai/claude-code and type your Mac’s login password. Nothing shows while you type; that is normal.

  1. 3Claude Code on Windows also needs Git. Download Git for Windows and install it with the defaults.

Then close the terminal, open a new one so it sees Node.js and Git, and run:

npm install -g @anthropic-ai/claude-code

If the download stalls, add --registry=https://registry.npmmirror.com to the end of the install command.

Check it installed: claude --version should print a version number followed by (Claude Code).

Connect to Token Share

This saves the address, your key and the model so that every new terminal picks them up. You only do it once.

Change one thing only: replace <your-pool-api-key> with your key, keeping the quotes around it. Then paste the whole block into the terminal and press Enter.

SHELL_RC="$HOME/.zshrc"; case "$SHELL" in *bash*) SHELL_RC="$HOME/.bashrc";; esac
cat >> "$SHELL_RC" <<'EOF'
export ANTHROPIC_API_KEY="<your-pool-api-key>"
export ANTHROPIC_BASE_URL="https://token-share.app"
export ANTHROPIC_MODEL="claude-sonnet-5-5"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-sonnet-5-5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-5-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-sonnet-5-5"
export CLAUDE_CODE_SUBAGENT_MODEL="claude-sonnet-5-5"
export CLAUDE_CODE_MAX_CONTEXT_TOKENS="260000"
export CLAUDE_CODE_ATTRIBUTION_HEADER="0"
EOF
source "$SHELL_RC"
$vars = [ordered]@{
  ANTHROPIC_API_KEY = "<your-pool-api-key>"
  ANTHROPIC_BASE_URL = "https://token-share.app"
  ANTHROPIC_MODEL = "claude-sonnet-5-5"
  ANTHROPIC_DEFAULT_OPUS_MODEL = "claude-sonnet-5-5"
  ANTHROPIC_DEFAULT_SONNET_MODEL = "claude-sonnet-5-5"
  ANTHROPIC_DEFAULT_HAIKU_MODEL = "claude-sonnet-5-5"
  CLAUDE_CODE_SUBAGENT_MODEL = "claude-sonnet-5-5"
  CLAUDE_CODE_MAX_CONTEXT_TOKENS = "260000"
  CLAUDE_CODE_ATTRIBUTION_HEADER = "0"
}
foreach ($name in $vars.Keys) {
  [Environment]::SetEnvironmentVariable($name, $vars[$name], "User")
  Set-Item "env:$name" $vars[$name]
}

To use another model, replace claude-sonnet-5-5 with any Claude id from the model list and run the block again; the newer lines win.

Start Claude Code

Go to your project folder and start it:

claude
  1. 1The first launch asks you to pick a colour theme; press Enter.
  2. 2When it asks Do you want to use this API key?, choose Yes. That is your Token Share key.
  3. 3Type /status inside Claude Code: the base URL should read https://token-share.app. Requests and their cost then show up on the Billing page.

Alternative: the token CLI

The token CLI saves the setup as a profile instead of environment variables, so it never touches your shell profile and can hold several setups side by side. Sign in with a CLI key when it asks.

npm install -g @token-share/cli

# Paste a CLI key from the dashboard when prompted
token login

token profile add claude-code \
  --name token-share \
  --base-url "https://token-share.app" \
  --all-models "claude-sonnet-5-5" \
  --default

token profile launch token-share

Troubleshooting

What you seeFix
claude: command not found, or “claude is not recognized”Close the terminal and open a new one. If it persists, check node -v works and install again.
“running scripts is disabled on this system”Run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned, answer Y, and try again.
It asks you to sign in to an Anthropic accountThe settings did not load. On macOS / Linux run source ~/.zshrc (or ~/.bashrc); on Windows open a new terminal. Then start claude again.
401 invalid api keyThe key was pasted wrong. Copy it again and rerun the setup block.
402 claude_minimum_balanceClaude is paid from topped-up balance only. Top up and retry.

Other status codes are explained under Rate limits.

Ready? Three steps to start

  1. 1Sign in to the console
  2. 2Top up your balance
  3. 3Create an API key