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:

    1. winget install OpenJS.NodeJS
    2. winget install Git.Git

    After installation, reopen the terminal and verify:

    1. node --version
    2. npm --version
    3. git --version

    On macOS, install Homebrew first, then execute in the terminal:

    1. brew install node
    2. brew 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:

    1. npm install -g @anthropic-ai/claude-code
    2. claude --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:

    1. {
    2. "env": {
    3. "ANTHROPIC_BASE_URL": "The compatible endpoint URL from the provider's documentation",
    4. "ANTHROPIC_AUTH_TOKEN": "The API Key generated in the provider's console",
    5. "ANTHROPIC_MODEL": "The model name from the provider's documentation"
    6. }
    7. }

    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:

    1. mkdir -p ~/.claude/profiles
    2. cp ~/.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:

    1. chmod 600 ~/.claude/profiles/*.json

    Add the switching function to your ~/.zshrc or ~/.bashrc:

    1. use-model() {
    2. cp ~/.claude/profiles/"$1".json ~/.claude/settings.json && echo "Switched to $1, please restart claude"
    3. }

    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:

    1. New-Item -ItemType Directory -Force "$HOME\.claude\profiles" | Out-Null
    2. icacls "$HOME\.claude\profiles" /inheritance:r /grant:r "$($env:USERNAME):(OI)(CI)F"

    Open the PowerShell profile, or create one if it doesn’t exist:

    1. if (!(Test-Path $PROFILE)) { New-Item -ItemType File -Force $PROFILE | Out-Null }
    2. notepad $PROFILE

    Add the switching function to the file:

    1. function Use-Model($name) {
    2. Copy-Item "$HOME\.claude\profiles\$name.json" "$HOME\.claude\settings.json" -Force
    3. Write-Host "Switched to $name, please restart claude"
    4. }

    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:

    1. Get-FileHash .\InstallerFileName -Algorithm SHA256

    Verify the checksum on macOS and Linux:

    1. 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:

    1. Completely exit claude after switching, then restart it. Running sessions will not read the new configuration.
    2. 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.
    3. 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

    1. claude command not found: Run npm config get prefix to view the global installation directory. On macOS and Linux, the executable is located in the bin subdirectory 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.

    2. 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:

    1. 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.

    1. Network request failed: Confirm the endpoint URL is spelled correctly and starts with https://. On Windows, use curl.exe -I EndpointURL to check connectivity, as curl in PowerShell is an alias with different behavior. If a company network requires a proxy, execute export HTTPS_PROXY=http://proxy_address:port on macOS/Linux, or $env:HTTPS_PROXY="http://proxy_address:port" in PowerShell. If your intranet uses self-signed certificates, set NODE_EXTRA_CA_CERTS to point to the certificate file.

    2. Windows global installation failed: Re-execute using an administrator PowerShell. If it still fails, confirm that both node --version and npm --version output normally.

    3. 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.json must 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:
    1. 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.