VS Code Integration
Use the Claude Code extension and GitHub Copilot custom endpoints in VS Code: installing the extension, the primaryApiKey config, and connecting QCode through chatLanguageModels.json
On This Page
Last verified: 2026-09-18 · 📄 Per official docs (VS Code 1.138.0, released 2026-09-16)
At a glance¶
| Item | Details |
|---|---|
| Models you can use | Claude ✅ (extension via Anthropic protocol / Copilot via Messages) · GPT ✅ · Chinese models ✅ (Copilot custom endpoint) · Gemini ❌ |
| Protocol & Base URL | Claude Code extension: environment variables at https://api.qcode.cc/api · Copilot: full URLs in chatLanguageModels.json |
| Where to configure | ~/.claude/config.json + environment variables; Copilot uses chatLanguageModels.json |
| Official docs | Claude Code extension · language models |
Using Trae IDE? Trae is a VS Code fork, so most steps here apply directly. For Trae-specific details — marketplace differences, offline
.vsixinstallation, coexisting with Trae's built-in AI — see the Trae Integration Guide.
In addition to using Claude Code CLI in the terminal, you can use the VS Code extension to access Claude Code directly in the editor for a more convenient development experience.
Prerequisites¶
Before configuring the VS Code extension, ensure:
-
Claude Code CLI is installed and working
-
See Installation Guide to complete installation
-
See Environment Configuration to complete setup
-
VS Code version >= 1.98.0
Installation Steps¶
Step 1: Install VS Code¶
If VS Code is not installed, visit the VS Code website to download and install.
Step 2: Install Claude Code Extension¶
In VS Code:
-
Open the Extensions panel (
Ctrl+Shift+X/Cmd+Shift+X) -
Search for "Claude Code for VS Code"
-
Click Install
Or install via command line:
code --install-extension anthropic.claude-code
Step 3: Configure primaryApiKey¶
This is a critical step! The Claude Code extension requires primaryApiKey in the configuration file.
Windows¶
Edit or create the config file C:\Users\YourUsername\.claude\config.json:
{
"primaryApiKey": "qcode"
}
macOS¶
Edit or create the config file ~/.claude/config.json:
# Create directory (if it doesn't exist)
mkdir -p ~/.claude
# Create config file
cat > ~/.claude/config.json << 'EOF'
{
"primaryApiKey": "qcode"
}
EOF
Linux¶
Edit or create the config file ~/.claude/config.json:
# Create directory (if it doesn't exist)
mkdir -p ~/.claude
# Create config file
cat > ~/.claude/config.json << 'EOF'
{
"primaryApiKey": "qcode"
}
EOF
Note: The value of
primaryApiKeycan be anything (likeqcode). You just need to have this field configured. The actual API authentication still uses theANTHROPIC_AUTH_TOKENyou configured in environment variables.Important: The config file is
config.json, NOTsettings.json. Please distinguish between these two files carefully.
Step 4: Restart VS Code¶
After configuration, restart VS Code for changes to take effect.
Usage¶
Keyboard Shortcuts¶
| Shortcut | Function |
|---|---|
Cmd+Esc / Ctrl+Esc |
Open/Close Claude Code panel |
Cmd+Shift+P / Ctrl+Shift+P |
Open command palette, search for Claude commands |
Common Features¶
-
Code Explanation
-
Select code
- Right-click and choose "Ask Claude" or use shortcut
-
Enter your question, e.g., "Explain this code"
-
Code Generation
-
Open Claude panel
- Describe the feature you need
-
Claude will generate code with insert options
-
Code Refactoring
-
Select code to refactor
- Ask Claude to help refactor
-
Preview and apply changes
-
Error Fixing
-
When code has errors
- Select the error code or message
- Ask Claude to analyze and provide fixes
Configuration Options¶
In VS Code settings, you can configure Claude Code extension behavior:
-
Open Settings (
Ctrl+,/Cmd+,) -
Search for "Claude Code"
-
Adjust options as needed
Common Settings¶
{
"claude-code.autoSuggest": true,
"claude-code.inlineChat": true
}
Using with Terminal CLI¶
The VS Code extension and terminal CLI can be used together:
| Scenario | Recommended Tool |
|---|---|
| Quick code edits | VS Code extension |
| Complex project analysis | Terminal CLI |
| Code review | Either |
| Git operations | Terminal CLI |
| File generation | Either |
GitHub Copilot custom endpoints¶
Since VS Code 1.122 the built-in Copilot Custom Endpoint lets you plug QCode's protocol legs straight into Copilot (Claude only via messages, url takes the full path). Minimal config:
[
{ "name": "QCode Claude", "vendor": "customendpoint", "apiKey": "cr_your-QCode-key",
"apiType": "messages",
"url": "https://api.qcode.cc/api/v1/messages",
"toolCalling": true,
"models": [ { "id": "claude-sonnet-5" } ] }
]
The complete three-leg setup, Copilot CLI BYOK and known limits (inline completions still run through GitHub) are on the dedicated page: GitHub Copilot Integration.
Troubleshooting¶
Extension Won't Start¶
-
Confirm Claude Code CLI is properly installed
-
Check environment variable configuration
-
Verify
config.jsonfile format is correct
primaryApiKey Error¶
-
Confirm file path is correct:
-
Windows:
C:\Users\YourUsername\.claude\config.json -
macOS/Linux:
~/.claude/config.json -
Confirm it's
config.jsonnotsettings.json -
Confirm JSON format is valid
Connection Timeout¶
-
Check network connection
-
Verify
ANTHROPIC_BASE_URLenvironment variable -
Try running
claudein terminal to confirm CLI works
Next Steps¶
-
Explore CLI Tips to boost efficiency
-
Learn Workflow Tips to optimize development flow