Back to Blog

Install Claude Code on Windows with WSL & DeepSeek API

Tutorials and Guides3281
Install Claude Code on Windows with WSL & DeepSeek API

Abstract

Claude Code is Anthropic’s official CLI AI coding agent, which can run natively on Windows through the Windows Subsystem for Linux (WSL 2). This complete tutorial covers the full deployment workflow: enabling Windows virtualization features, installing Ubuntu WSL 2 subsystem, configuring Node.js runtime, global installation of the Claude Code binary, DeepSeek API environment variable setup, VS Code extension integration, and validation troubleshooting. All terminal commands, system configuration parameters and common error handling logic are reproduced from real Windows 11 Enterprise testing environments, with standardized WSL, Node.js and LLM API terminology. Teams managing multi-model API traffic can centralize endpoint routing with an API gateway such as 4sapi to unify DeepSeek and other LLM service access.

1. Pre-Environment Preparation on Windows

1.1 System Requirement Check

WSL 2 virtualization functions are only available on Windows professional/enterprise editions; home editions lack support. The tutorial test environment is Windows 11 Enterprise 25H2, build version 26200.8655. Three core Windows features must be enabled simultaneously via the Turn Windows features on or off panel (Win + Q shortcut search):

  1. Hyper-V: Core virtualization layer
  2. Windows Subsystem for Linux: WSL host service
  3. Virtual Machine Platform: Required WSL 2 runtime dependency

After checking the three boxes, reboot the operating system to activate the virtualization stack.

1.2 Install & Initialize WSL 2 Ubuntu Subsystem

Launch PowerShell with Administrator privileges and execute the official WSL installation command:

bash
wsl --install -d Ubuntu-22.04

This single command automates three tasks: enabling WSL platform, downloading Ubuntu 22.04 distribution, and setting WSL version to WSL 2 by default. Reboot the PC after execution completes.

WSL Version Validation & Upgrade

Run wsl -l -v to check the running WSL version. If the version number shows 1, execute these two commands to upgrade to WSL 2:

bash
wsl --set-default-version 2
wsl --set-version Ubuntu-22.04 2

1.3 Ubuntu Initialization & Base Dependency Update

After reboot, the Ubuntu terminal launches automatically, requiring manual setup of a standard Linux user account:

  1. Input custom username
  2. Input login password (input text is hidden, enter twice for confirmation)

Once the user session is created, run the system package update command to synchronize the latest software source:

bash
sudo apt update && sudo apt upgrade -y

Enter the Ubuntu user password when prompted to authorize system modification.

1.4 Install Node.js 20 Runtime

Claude Code CLI depends on Node.js v20+, add the official Node.js repository and install the runtime:

bash
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
sudo apt install -y nodejs

Verify successful installation with node --version and npm --version; valid outputs will display v20.x.x version numbers.

1.5 Global Install Claude Code CLI

Use npm to deploy the official Anthropic Claude Code package globally within the WSL Ubuntu environment:

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

After installation, run claude --version to confirm the binary is registered to the system PATH.

2. Configure DeepSeek API Backend for Claude Code

Claude Code supports custom OpenAI-compatible API endpoints to route requests to DeepSeek’s model series, configured via Linux environment variables.

2.1 Retrieve DeepSeek API Key

  1. Log into the DeepSeek developer open platform
  2. Navigate to the API Keys management page
  3. Create a new secret key, copy the generated key string (format starts with sk-)

2.2 Temporary Environment Variable Setup (Single Session Only)

Define two core environment variables in the current Ubuntu terminal session:

bash
export ANTHROPIC_AUTH_TOKEN="Your DeepSeek API Key"
export ANTHROPIC_BASE_URL="https://api.deepseek.com/v1/anthropic"

This configuration resets after closing the terminal window, suitable for temporary testing.

2.3 Persistent Permanent Environment Variables

Write the variable definitions into the ~/.bashrc shell configuration file to retain settings across system restarts:

bash
echo 'export ANTHROPIC_AUTH_TOKEN="Your DeepSeek API Key"' >> ~/.bashrc
echo 'export ANTHROPIC_BASE_URL="https://api.deepseek.com/v1/anthropic"' >> ~/.bashrc
source ~/.bashrc

The source command loads the updated config without rebooting Ubuntu.

2.4 API Connectivity Validation

Send a test POST request via curl to verify the DeepSeek backend responds normally:

bash
curl https://api.deepseek.com/v1/anthropic/v1/messages \
-H "Authorization: Bearer Your API Key" \
-H "Content-Type: application/json" \
-d '{
    "model": "claude-3-haiku-20240307",
    "messages": [{"role": "user", "content": "Hello"}]
}'

A valid JSON chat completion response confirms the API routing is functional.

2.5 Launch Claude Code CLI

Simply input the claude command in the WSL terminal to start the interactive coding agent, which will automatically forward all inference requests to the DeepSeek API endpoint defined in environment variables.

3. Integrate Claude Code VS Code Extension

To use the agent within the graphical IDE, complete VS Code installation and extension configuration.

3.1 Install Visual Studio Code

Download the Windows installer from the official VS Code website, complete the graphical installation wizard, and launch the editor after setup finishes. The claude CLI command remains usable in VS Code’s integrated WSL terminal.

3.2 Localize VS Code to Chinese (Optional)

  1. Open the Extensions panel via Ctrl + Shift + X
  2. Search for the Chinese (Simplified) language pack extension and install it
  3. Press Ctrl + Shift + P, input Configure Display Language, select zh-cn, and restart the editor to apply Chinese UI.

3.3 Install Official Claude Code VS Code Extension

  1. In the Extensions marketplace, search for Claude Code for VS Code (publisher: Anthropic)
  2. Click Install, then select Reload Window to activate the extension.

3. Critical Configuration Note for Custom API Routing

The default login button on the VS Code Claude Code extension connects to Anthropic’s official native endpoint, which is isolated from the DeepSeek API environment variables configured in WSL. Clicking the built-in login button will return no response when using third-party compatible gateways — this behavior is expected and not a fault. To bind the VS Code extension to the DeepSeek backend, modify the workspace settings.json file:

  1. Open command palette: Ctrl + Shift + P
  2. Input Preferences: Open Settings (JSON) to open the raw configuration file
  3. Inject custom environment routing parameters matching the WSL environment variables
  4. Save the file and fully restart VS Code for changes to take effect

3. Final Functional Verification

After reloading the editor, input natural language development requirements into the Claude Code sidebar chat box. The extension will route inference traffic through the WSL-defined DeepSeek compatible endpoint, completing end-to-end local IDE coding workflow deployment.

4. Summary

This tutorial establishes a complete cross-stack deployment pipeline: Windows WSL 2 virtualization layer → Ubuntu Linux runtime → Node.js environment → Claude Code CLI agent → DeepSeek compatible API backend → VS Code graphical extension integration. The core advantage of this deployment scheme is separating the CLI runtime environment from the native Anthropic service, allowing developers to replace the official model backend with third-party open-source LLM platforms like DeepSeek via standardized OpenAI-compatible API mappings. For enterprise teams running multiple LLM backends simultaneously, unified traffic management through platforms such as 4sapi simplifies centralized key management and request monitoring across Claude Code and other AI agent clients. Key operational reminders: WSL environment variables must be persistently written to .bashrc for long-term use; the VS Code extension cannot rely on the built-in login flow when using third-party API proxies and requires manual settings.json customization to match custom gateway endpoints.

Tags:Claude CodeDeepSeek APIWSL 2VS CodeAI Coding Agent

Recommended reading

Explore more frontier insights and industry know-how.