Set Up an AI Coding Assistant in 10 Minutes with One-Click Multi-Model Switching
This guide explains how to set up the Claude Code AI assistant in about 10 minutes. It covers installing Node.js and Git, configuring the CLI tool, and managing multiple model providers. By using configuration profiles, developers can seamlessly switch between different models for various coding tasks with a single command.
1. Define Goals and Boundaries
When using AI coding assistants, developers often encounter two common issues. First, different models excel at different tasks. Long context reading, stable code generation, and low-cost daily Q&A often require different models. Second, switching providers usually requires modifying environment variables or configuration files, which is time-consuming and error-prone.
This article will help you complete three tasks in about 10 minutes: install Node.js and Git; install the Claude Code CLI assistant and log in; and manage multiple model providers through configuration profiles, enabling a one-command switch when needed.
Let’s clarify the boundaries first. The switching method in this article requires the provider to offer an endpoint compatible with the Anthropic API protocol. If a provider only offers an OpenAI-compatible interface, you will need a protocol-converting proxy gateway, which is beyond the scope of this article.
2. Prepare the Runtime Environment
Claude Code runs on Node.js, requiring version 18 or higher (LTS is recommended). Git is used for version management and helps the tool check project status.
On Windows, open PowerShell as an administrator and execute:
winget install OpenJS.NodeJSwinget install Git.Git
After installation, reopen the terminal and verify:
node --versionnpm --versiongit --version
On macOS, install Homebrew first, then execute in the terminal:
brew install nodebrew install git
The verification commands are the same as Windows. If node --version shows a version lower than 18, please upgrade Node.js before continuing.
3. Install Claude Code
Claude Code is installed globally via npm, and the official package name is @anthropic-ai/claude-code. Both Windows and macOS use the same commands:
npm install -g @anthropic-ai/claude-codeclaude --version
If Windows prompts insufficient permissions, re-execute using an administrator PowerShell. After installation, run claude in your project directory and follow the prompts to log in or authorize. If you only use a third-party provider’s API Key, you can skip the account login and proceed directly to Section 4 for configuration.
4. Connect Model Providers
Claude Code reads the following three configurations:
ANTHROPIC_BASE_URL: The provider’s API endpoint;ANTHROPIC_AUTH_TOKEN: The API Key issued by the provider;ANTHROPIC_MODEL: The name of the model to use.
These three items can be written in environment variables or in the env field of a configuration file. This article uses a configuration file because it is saved in the user directory and remains valid after restarting the terminal. The configuration file locations are as follows:
- macOS and Linux:
~/.claude/settings.json - Windows:
%USERPROFILE%\.claude\settings.json, i.e.,C:\Users\Username\.claude\settings.json
Here is the configuration format. The three values need to be obtained from the provider’s official documentation; do not guess fields not provided in the documentation:
{"env": {"ANTHROPIC_BASE_URL": "The compatible endpoint URL from the provider's documentation","ANTHROPIC_AUTH_TOKEN": "The API Key generated in the provider's console","ANTHROPIC_MODEL": "The model name from the provider's documentation"}}
If a specific project needs to use a separate model, you can create .claude/settings.local.json in the project root directory, which only applies to the current project. Please add this file to .gitignore to prevent keys from being committed to the code repository.
5. Implement Multi-Model Switching with Profiles
Manually copying and pasting configurations every time can lead to missing fields or typos. A more robust approach is to save a complete configuration profile for each provider, and copy the selected profile to settings.json when switching. Note that switching will overwrite the entire settings.json, so the profile must include all fields you want to keep.
Here are the steps for macOS and Linux. First, create the profiles directory and back up the current configuration:
mkdir -p ~/.claude/profilescp ~/.claude/settings.json ~/.claude/settings.json.bak 2>/dev/null
Save configuration profiles under ~/.claude/profiles/, such as main.json (primary model) and budget.json (low-cost model). Tighten permissions to prevent other users from reading your keys:
chmod 600 ~/.claude/profiles/*.json
Add the switching function to your ~/.zshrc or ~/.bashrc:
use-model() {cp ~/.claude/profiles/"$1".json ~/.claude/settings.json && echo "Switched to $1, please restart claude"}
After reopening the terminal, execute use-model main to switch.
For Windows, execute the following commands in PowerShell to create the profiles directory and restrict access permissions, allowing only the current user to read and write:
New-Item -ItemType Directory -Force "$HOME\.claude\profiles" | Out-Nullicacls "$HOME\.claude\profiles" /inheritance:r /grant:r "$($env:USERNAME):(OI)(CI)F"
Open the PowerShell profile, or create one if it doesn’t exist:
if (!(Test-Path $PROFILE)) { New-Item -ItemType File -Force $PROFILE | Out-Null }notepad $PROFILE
Add the switching function to the file:
function Use-Model($name) {Copy-Item "$HOME\.claude\profiles\$name.json" "$HOME\.claude\settings.json" -ForceWrite-Host "Switched to $name, please restart claude"}
Save and reopen PowerShell, then execute Use-Model main to switch. If prompted that scripts are disabled, execute Set-ExecutionPolicy -Scope CurrentUser RemoteSigned as the current user, then try again.
6. Optional: Use a GUI Switching Tool
The community offers open-source tools, such as cc-switch, which can manage multiple providers and switch with one click via a GUI. Before use, download the installer from the project’s official GitHub Releases page and verify the SHA256 checksum to ensure the file has not been tampered with.
Verify the checksum on Windows:
Get-FileHash .\InstallerFileName -Algorithm SHA256
Verify the checksum on macOS and Linux:
shasum -a 256 ./InstallerFileName
Compare the output character by character with the checksum provided on the release page. The GUI tool and the profile method in Section 5 will modify the same settings.json file. Choose one method and do not mix them.
7. Verify the Switch is Effective
Follow these steps to verify:
- Completely exit
claudeafter switching, then restart it. Running sessions will not read the new configuration. - Send a fixed command, such as “List the main file structure of the current directory and explain the purpose of each directory in one sentence,” to confirm it returns results normally.
- Log in to the provider’s console and verify in the usage or call logs that the request comes from the target model.
It is not recommended to determine the current model based on the model’s self-introduction. The name reported by the model may be inaccurate; the console’s call logs are more reliable.
8. Choose Models Based on Tasks
| Task Type | Recommended Model Type | Main Trade-offs |
|---|---|---|
| Complex refactoring, cross-file architecture design | Models with strong reasoning and coding capabilities | Slower response, higher cost per call |
| Reading long files, analyzing long logs | Models with a large context window | Need to confirm the context limit specified by the provider first |
| Code completion, explaining small code snippets, simple Q&A | Models with fast response and low unit price | Prone to errors on complex tasks, results require review |
Before switching, you can run the same code snippet on two different models to compare result quality and time consumed, then decide on your default daily model.
9. Troubleshooting Common Issues
claudecommand not found: Runnpm config get prefixto view the global installation directory. On macOS and Linux, the executable is located in thebinsubdirectory of that directory, while on Windows, it is directly in that directory. Add the corresponding path to the PATH environment variable, then reopen the terminal.Switch does not take effect: First, confirm that you have completely exited and restarted
claude. Then check if the configuration file is valid JSON; a common cause is extra commas or missing quotes. On macOS and Linux, execute the following command to validate:
node -e "JSON.parse(require('fs').readFileSync(require('path').join(require('os').homedir(),'.claude','settings.json'),'utf8')); console.log('Format is correct')"
If it outputs an error message, fix the file according to the indicated location.
Network request failed: Confirm the endpoint URL is spelled correctly and starts with
https://. On Windows, usecurl.exe -I EndpointURLto check connectivity, ascurlin PowerShell is an alias with different behavior. If a company network requires a proxy, executeexport HTTPS_PROXY=http://proxy_address:porton macOS/Linux, or$env:HTTPS_PROXY="http://proxy_address:port"in PowerShell. If your intranet uses self-signed certificates, setNODE_EXTRA_CA_CERTSto point to the certificate file.Windows global installation failed: Re-execute using an administrator PowerShell. If it still fails, confirm that both
node --versionandnpm --versionoutput normally.Authentication failed or 401 error: Check if there are extra spaces before or after
ANTHROPIC_AUTH_TOKEN, and confirm the key is still valid and has sufficient balance. If the key has expired or been revoked, regenerate it in the provider’s console.
10. Security and Rollback
- Do not commit keys to code repositories. The project-level
.claude/settings.local.jsonmust be added to.gitignore. - Configuration profiles are saved in the user directory and have restricted access permissions. Do not copy profiles to shared drives or chat logs.
- If you suspect a key has been leaked, immediately revoke it in the provider’s console, then generate a new key and update the profile.
- A backup file was saved before switching. If the new configuration causes issues, execute the following command to roll back:
cp ~/.claude/settings.json.bak ~/.claude/settings.json
On Windows, you can execute Copy-Item "$HOME\.claude\settings.json.bak" "$HOME\.claude\settings.json" -Force.
11. Summary
The core sequence of this workflow is: runtime environment, Claude Code, provider configuration, and profile switching. The first three steps are done once; afterwards, you only need to execute a single switching command. The choice of model should be based on task difficulty, response speed, and cost, and the switching result should be confirmed via the console’s call logs.
