Skip to main content
This site is an independent third-party technical service provider. Claude™ and Anthropic® are trademarks of Anthropic, PBC. This site has no affiliation, endorsement, or partnership with Anthropic.

Claude Code with cc-switch: One-Click API Configuration Guide

A practical 2026 guide to using cc-switch to manage Claude Code API settings with ClaudeAPI, including import, testing, key rotation, and common commands.

Getting Startedclaudeclaude-codetutorialapiEst. read
2026.04.05 published
Claude Code with cc-switch: One-Click API Configuration Guide

This guide shows how to connect Claude Code to ClaudeAPI with cc-switch, a configuration manager for switching Claude Code API profiles.

The idea is simple: instead of manually editing Claude Code environment settings every time you change an API key or endpoint, you store multiple profiles in cc-switch, test them, and activate the one you want.

For ClaudeAPI users, the key values are:

ANTHROPIC_AUTH_TOKEN = your ClaudeAPI key
ANTHROPIC_BASE_URL   = https://gw.claudeapi.com
ANTHROPIC_AUTH_TOKEN = your ClaudeAPI key
ANTHROPIC_BASE_URL   = https://gw.claudeapi.com

If you need the OpenAI-compatible endpoint for other tools, use:

https://gw.claudeapi.com/v1
https://gw.claudeapi.com/v1

Claude Code itself uses the Anthropic-style endpoint, so do not add /v1 to the Claude Code base URL.

Quick start

If you already have a ClaudeAPI account, the fastest path is:

  1. Install Claude Code and cc-switch.
  2. Import the ClaudeAPI profile from the ClaudeAPI console.
  3. Activate the profile and start Claude Code.
cc-switch use default && claude
cc-switch use default && claude

After that, Claude Code should route requests through the ClaudeAPI endpoint configured by cc-switch.

Step 1: Install Claude Code and cc-switch

Install Claude Code using Anthropic’s current official installation instructions for your system. Claude Code installation methods may change, so check the official Claude Code documentation before writing this into team onboarding docs.

For cc-switch, follow the project README:

https://github.com/farion1231/cc-switch/blob/main/README_ZH.md
https://github.com/farion1231/cc-switch/blob/main/README_ZH.md

Some setups use npm global installation:

npm install -g @hobeeliu/cc-switch
npm install -g @hobeeliu/cc-switch

If your environment still installs Claude Code through npm, you may see examples like:

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

Treat the Claude Code install command as version-sensitive. The cc-switch configuration steps below are the main part of this guide.

Step 2: Import the ClaudeAPI profile

In the ClaudeAPI console:

  1. Create or open an API key.
  2. Set the key name, balance, and access restrictions as needed.
  3. In the API key usage area, choose the CC Switch option.
  4. Import the provider configuration into cc-switch.

Review the imported provider in cc-switch, then click import.

After import, you should see the ClaudeAPI profile in cc-switch.

Step 3: Activate the profile and start Claude Code

Activate the profile:

cc-switch use default
cc-switch use default

Then start Claude Code:

claude
claude

Or combine both:

cc-switch use default && claude
cc-switch use default && claude

Test the configuration

In the cc-switch UI, click the test-model button. If the status shows that the model is running normally, the API key and endpoint are configured correctly.

You can also test from the command line:

cc-switch test -c
cc-switch test -c

If the test fails, check:

  • API key spelling
  • account balance
  • whether the base URL is https://gw.claudeapi.com
  • whether you accidentally added /v1
  • local network or proxy settings

Manual setup with the web UI

cc-switch includes a visual web management interface. This is often easier than editing config files by hand, especially when you are adding your first profile or rotating keys.

Start it:

cc-switch web
cc-switch web

Your browser should open the cc-switch dashboard.

cc-switch web dashboard

To add a profile manually:

  1. Click the orange + button.
  2. Choose a custom configuration.
  3. Fill in the provider name, API key, and request URL.
Field Value
Provider name ClaudeAPI.com or any name you prefer
API Key Your sk-... ClaudeAPI key
Request URL https://gw.claudeapi.com

Do not add a trailing slash.

After saving, return to the main screen and activate the new profile.

What cc-switch changes

Claude Code reads API configuration from Claude settings. cc-switch manages those settings for you.

The relevant environment fields look like this:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your-api-key",
    "ANTHROPIC_BASE_URL": "https://gw.claudeapi.com"
  }
}
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your-api-key",
    "ANTHROPIC_BASE_URL": "https://gw.claudeapi.com"
  }
}

When you run:

cc-switch use default
cc-switch use default

cc-switch writes the selected profile into the Claude Code settings file. The switch takes effect for future Claude Code API calls.

Claude Code settings managed by cc-switch

Settings file location

Claude settings are typically stored here:

Windows:      C:\Users\<username>\.claude\settings.json
macOS/Linux:  ~/.claude/settings.json
Windows:      C:\Users\<username>\.claude\settings.json
macOS/Linux:  ~/.claude/settings.json

You usually do not need to edit this file directly if you use cc-switch.

If you do edit it manually, back it up first. JSON syntax errors can break the configuration.

Rotate or replace an API key

When a key expires or you create a new key:

  1. Open cc-switch web.
  2. Click the edit icon for the profile.
  3. Replace the API key.
  4. Save the profile.
  5. Activate it again.
  6. Run a test.

Command-line option:

cc-switch edit default --field env.ANTHROPIC_AUTH_TOKEN
cc-switch use default
cc-switch test -c
cc-switch edit default --field env.ANTHROPIC_AUTH_TOKEN
cc-switch use default
cc-switch test -c

Common cc-switch commands

Command What it does
cc-switch init Initialize the first profile
cc-switch list List saved profiles; the active one is marked
cc-switch current Show the active profile name
cc-switch use <name> Activate a profile
cc-switch view <name> View profile details
cc-switch new <name> -i Create a profile interactively
cc-switch test -c Test the current profile
cc-switch test --all Test all profiles
cc-switch edit <name> --field env.ANTHROPIC_AUTH_TOKEN Edit a profile’s API key
cc-switch edit -c Edit the active profile
cc-switch import <file> Import profiles from a backup file
cc-switch web Open the web management UI
cc-switch update Check for and install cc-switch updates
cc-switch rm <name> Delete a profile
cc-switch cp <src> <dst> Copy a profile
cc-switch --version Show the installed version

FAQ

Do I need to restart Claude Code after cc-switch use?

Usually no. cc-switch use updates the selected configuration, and future Claude Code API calls should use the active profile.

If Claude Code was already running and still appears to use the old key, restart the Claude Code session to remove any uncertainty.

Should the base URL include /v1?

For Claude Code through Anthropic-style settings, use:

https://gw.claudeapi.com
https://gw.claudeapi.com

Do not use:

https://gw.claudeapi.com/v1
https://gw.claudeapi.com/v1

The /v1 endpoint is for OpenAI-compatible tools.

Does cc-switch support OpenAI-compatible tools?

cc-switch is designed for Claude Code configuration. It manages Claude Code settings such as ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL.

For OpenAI-compatible tools, ClaudeAPI still provides:

https://gw.claudeapi.com/v1
https://gw.claudeapi.com/v1

but those tools usually have their own configuration systems.

How do I know which profile is active?

Run:

cc-switch current
cc-switch current

Example output:

Current configuration: default
Current configuration: default

Can I keep multiple profiles?

Yes. That is the main reason to use cc-switch. You can keep separate profiles for:

  • ClaudeAPI production key
  • ClaudeAPI test key
  • direct Anthropic key
  • team-specific keys
  • different projects or budgets

Why use ClaudeAPI with Claude Code

ClaudeAPI provides a Claude-compatible API endpoint and account system that can be convenient for teams that want a configurable Claude Code setup.

Item Direct Anthropic endpoint ClaudeAPI
Claude Code protocol Native Compatible Anthropic-style endpoint
Base URL Anthropic official endpoint https://gw.claudeapi.com
Profile switching Manual or external tooling Works with cc-switch profile management
Billing and access Anthropic account ClaudeAPI account and console

Avoid over-reading this table: ClaudeAPI is an independent third-party technical service provider, not Anthropic. Always check your account, console, pricing, and availability before production use.

Troubleshooting

Problem Likely cause Fix
401 Unauthorized Wrong key or key copied with whitespace Copy the key again from the ClaudeAPI console
404 Not Found Base URL includes /v1 or has a malformed path Use https://gw.claudeapi.com
cc-switch test fails Wrong profile is active Run cc-switch current and cc-switch use <name>
Claude Code still uses old key Running session cached old settings Restart Claude Code
JSON config error Manual edit broke settings.json Restore backup or validate JSON
Network timeout Proxy, firewall, or DNS issue Test from the same terminal and network

Conclusion

cc-switch is useful because it turns Claude Code API configuration into profiles:

  • initialize once
  • store multiple configurations
  • switch with one command
  • test connectivity before working
  • avoid manual edits to settings.json

For ClaudeAPI users, the key detail is the base URL:

https://gw.claudeapi.com
https://gw.claudeapi.com

Use cc-switch to manage the key and endpoint, run cc-switch test -c, then start Claude Code with:

cc-switch use default && claude
cc-switch use default && claude

Sources

Related Articles