DocsClient setupClaude Code

Claude Code

Install Claude Code CLI and connect it to SoleAPI permanently through its configuration file.

Claude Code

This guide explains how to install Claude Code CLI and connect it to SoleAPI permanently through its settings.json file. If you prefer a graphical setup, you can use the more convenient CC Switch. Before you begin, create an API Key in the console.

This guide applies only to Claude Code CLI, not Claude Desktop. Claude Code and Claude Desktop use separate configuration methods.

Install Claude Code

This guide uses npm, which is included with Node.js, to install Claude Code CLI.

  1. Check your Node.js version

The current npm version of Claude Code requires Node.js v18 or later (v22 or later is recommended). Run the following command in a terminal:

bash
node -v

If the command is not found or the version is below v22, install or update Node.js from the Node.js download page.

  1. Install Claude Code with npm
bash
npm install -g @anthropic-ai/claude-code
  1. Verify the installation

After installation, run:

bash
claude --version

If the terminal prints a Claude Code version, the installation succeeded. You can also run claude doctor to check the installation and configuration files.

Connect Claude Code to SoleAPI

  1. Open the Claude Code configuration directory
  • Windows: C:\Users\your-username\.claude
  • macOS: /Users/your-username/.claude
  • Linux: /home/your-username/.claude

On Windows, press Win + R, enter explorer %userprofile%\.claude, and press Enter to open the directory in File Explorer.

On Linux / macOS, run cd ~/.claude in a terminal to enter the configuration directory.

  1. Confirm that the configuration file exists

The file to edit is settings.json. Create it if it does not exist. If it already exists, make a backup first.

  1. Edit the configuration file

Write or merge the following into settings.json, replacing sk-sole-your-key with your own API Key:

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://soleapi.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-sole-your-key"
  }
}

ANTHROPIC_BASE_URL must be https://soleapi.com without a trailing /. Do not use https://soleapi.com/v1; Claude Code appends /v1/messages itself.

If settings.json already contains other settings, keep the existing fields and merge or update only the env object. Keep only one copy of duplicate fields, and remember to separate JSON properties with English commas.

Set a default model (optional)

To assign SoleAPI models to Claude Code model tiers, add the corresponding fields under env:

json2
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://soleapi.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-sole-your-key",
    "ANTHROPIC_DEFAULT_FABLE_MODEL": "optional model ID",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "optional model ID",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "optional model ID",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "optional model ID",
    "CLAUDE_CODE_SUBAGENT_MODEL": "optional model ID"
  }
}

Copy the model ID from the Model Catalog, and confirm that the current API Key includes the model's dispatch group. Omit these optional fields if you do not need to pin a model.

Verify the configuration

Save settings.json, completely quit Claude Code, and restart it. Run the following command in a terminal:

bash
claude

Send a message after Claude Code starts. A normal reply confirms that the connection works. If Claude Code was already open, the old configuration may not refresh automatically; quit and restart it.

Frequently asked questions

  • The request path contains /v1/v1/messages: /v1 was added to ANTHROPIC_BASE_URL by mistake. Change it to https://soleapi.com.
  • The request path contains double slashes: remove the trailing / from ANTHROPIC_BASE_URL.
  • The change did not take effect: confirm that the file is .claude/settings.json, validate the JSON, then completely quit and restart Claude Code. You can run claude doctor to inspect the configuration.
  • The server returns 401: check that ANTHROPIC_AUTH_TOKEN is complete and that the API Key has not been disabled or expired.
  • The server returns 403: check that the API Key includes the target model's dispatch group. If an IP allowlist is enabled, make sure the current device IP is included.
  • The model does not exist or has no available endpoint: check that the model ID matches the Model Catalog and is available to the current API Key.
  • npm reports insufficient permissions: check how Node.js and npm were installed and whether the global installation directory is writable. Do not change SoleAPI settings to work around an installation error.