Qwen Code setup
Qwen Code is an open-source coding agent that can understand a project, edit files, run commands, and invoke tools from a terminal. Its OpenAI-compatible provider support lets those requests run through Lumoswitch.
The API configuration must enable OpenAI-compatible output, and the target model should support streaming and Tool / Function Calling. The CLI commands below target Bash or Zsh on macOS and Linux. Before continuing, confirm that qwen --version returns a version number.
Choose a setup method
| Method | Best for | Local writes | Still active after exit? |
|---|---|---|---|
| One-time launch | Testing a URL, Key, or model | Temporary Lumoswitch settings file | No |
| Persistent use | Everyday terminal use | Native configuration + optional launcher and settings file | Yes |
| IDE Companion | Connecting an editor to the current Qwen Code CLI | Reuses the current CLI process | Depends on the CLI method |
| Native VS Code sidebar | Running the agent directly in the extension | User-level Qwen Code provider configuration | Yes |
Qwen Code has no standalone official desktop app. Its official VS Code Extension Beta can either connect to a current CLI process or start a native sidebar agent. Those two paths have different configuration boundaries, as explained below.
Prepare the connection values
| Placeholder | Value |
|---|---|
{{api_base_url}} | The OpenAI-compatible request URL shown by the API configuration; it should end in /v1 |
{{access_key}} | The API configuration's Access Key |
{{model}} | The client-facing model name shown by the API configuration |
{{qwen_settings_json}} | Complete Qwen Code settings generated from effective reasoning capabilities |
Commands copied from the console already contain real values. Each model receives its own generationConfig.reasoning: adjustable models get a safe default effort, known non-reasoning models are disabled, and unknown or fixed-reasoning models receive no control field.
One-time launch
Run this command in the project where you want to use Qwen Code. It creates a temporary provider catalog for that process and passes the Key through its environment. The catalog is deleted on exit and does not change user-level or project-level Qwen Code configuration.
(
set -e
LUMOSWITCH_QWEN_SETTINGS="$(mktemp "${TMPDIR:-/tmp}/lumoswitch-qwen.XXXXXX")"
trap 'rm -f "$LUMOSWITCH_QWEN_SETTINGS"' EXIT
printf '%s\n' '{{qwen_settings_json}}' > "$LUMOSWITCH_QWEN_SETTINGS"
chmod 600 "$LUMOSWITCH_QWEN_SETTINGS"
env \
LUMOSWITCH_QWEN_API_KEY="{{access_key}}" \
QWEN_CODE_SYSTEM_SETTINGS_PATH="$LUMOSWITCH_QWEN_SETTINGS" \
qwen --auth-type openai --model "{{model}}"
)Persistent use
Run the complete command during initial setup and whenever the Lumoswitch URL, Access Key, or model changes. It writes Qwen Code-supported system settings and a managed environment without overwriting existing configuration, then saves an optional Lumoswitch maintenance launcher.
Persistent import stores the Access Key in an owner-only managed environment or Agent configuration file. Use it only on a trusted personal device.
set -e
LUMOSWITCH_ROOT="$HOME/.config/lumoswitch/agents/qwen-code"
LUMOSWITCH_ENV="$LUMOSWITCH_ROOT/env.sh"
LUMOSWITCH_LAUNCHER="$HOME/.local/bin/lumoswitch-qwen-code"
mkdir -p "$LUMOSWITCH_ROOT" "$(dirname "$LUMOSWITCH_LAUNCHER")"
umask 077
if [ -f "$LUMOSWITCH_LAUNCHER" ]; then
LUMOSWITCH_BACKUP="$LUMOSWITCH_LAUNCHER.backup.$(date +%Y%m%d-%H%M%S)-$$"
cp "$LUMOSWITCH_LAUNCHER" "$LUMOSWITCH_BACKUP"
chmod 600 "$LUMOSWITCH_BACKUP"
fi
LUMOSWITCH_QWEN_SETTINGS="$LUMOSWITCH_ROOT/settings.json"
printf '%s\n' '{{qwen_settings_json}}' > "$LUMOSWITCH_QWEN_SETTINGS"
cat > "$LUMOSWITCH_ENV" <<'LUMOSWITCH_ENV_EOF'
export QWEN_CODE_SYSTEM_SETTINGS_PATH="$HOME/.config/lumoswitch/agents/qwen-code/settings.json"
export LUMOSWITCH_QWEN_API_KEY="{{access_key}}"
export LUMOSWITCH_QWEN_MODEL="{{model}}"
LUMOSWITCH_ENV_EOF
case "$SHELL" in
*/zsh) LUMOSWITCH_PROFILE="$HOME/.zshrc" ;;
*/bash) LUMOSWITCH_PROFILE="$HOME/.bashrc" ;;
*) LUMOSWITCH_PROFILE="$HOME/.profile" ;;
esac
touch "$LUMOSWITCH_PROFILE"
LUMOSWITCH_PROFILE_MARKER='# Lumoswitch Agent: qwen-code'
LUMOSWITCH_SOURCE_LINE='[ -f "$HOME/.config/lumoswitch/agents/qwen-code/env.sh" ] && . "$HOME/.config/lumoswitch/agents/qwen-code/env.sh"'
if ! grep -Fqx "$LUMOSWITCH_SOURCE_LINE" "$LUMOSWITCH_PROFILE"; then
printf '\n%s\n%s\n' "$LUMOSWITCH_PROFILE_MARKER" "$LUMOSWITCH_SOURCE_LINE" >> "$LUMOSWITCH_PROFILE"
fi
printf '%s\n' "$LUMOSWITCH_PROFILE" > "$LUMOSWITCH_ROOT/profile-path"
cat > "$LUMOSWITCH_LAUNCHER" <<'LUMOSWITCH_LAUNCHER_EOF'
#!/usr/bin/env bash
set -e
LUMOSWITCH_ROOT="$HOME/.config/lumoswitch/agents/qwen-code"
LUMOSWITCH_ENV="$LUMOSWITCH_ROOT/env.sh"
LUMOSWITCH_LAUNCHER="$HOME/.local/bin/lumoswitch-qwen-code"
if [ "$1" = "--lumoswitch-clean" ]; then
if [ -f "$LUMOSWITCH_ROOT/profile-path" ]; then
LUMOSWITCH_PROFILE="$(cat "$LUMOSWITCH_ROOT/profile-path")"
if [ -f "$LUMOSWITCH_PROFILE" ]; then
LUMOSWITCH_PROFILE_MARKER='# Lumoswitch Agent: qwen-code'
LUMOSWITCH_SOURCE_LINE='[ -f "$HOME/.config/lumoswitch/agents/qwen-code/env.sh" ] && . "$HOME/.config/lumoswitch/agents/qwen-code/env.sh"'
LUMOSWITCH_PROFILE_TMP="$LUMOSWITCH_PROFILE.lumoswitch.$$"
awk -v marker="$LUMOSWITCH_PROFILE_MARKER" -v source="$LUMOSWITCH_SOURCE_LINE" '$0 != marker && $0 != source' "$LUMOSWITCH_PROFILE" > "$LUMOSWITCH_PROFILE_TMP"
mv "$LUMOSWITCH_PROFILE_TMP" "$LUMOSWITCH_PROFILE"
fi
fi
if [ -d "$LUMOSWITCH_ROOT" ]; then
find "$LUMOSWITCH_ROOT" -depth \( -type f -o -type l \) -delete
find "$LUMOSWITCH_ROOT" -depth -type d -exec rmdir {} \; 2>/dev/null || true
fi
find "$(dirname "$LUMOSWITCH_LAUNCHER")" -maxdepth 1 -type f -name 'lumoswitch-qwen-code.backup.*' -delete
rm -f "$LUMOSWITCH_LAUNCHER"
printf '%s\n' 'Lumoswitch native setup and optional launcher removed. Open a new terminal to refresh the environment.'
exit 0
fi
if [ -f "$LUMOSWITCH_ENV" ]; then . "$LUMOSWITCH_ENV"; fi
exec qwen "$@"
LUMOSWITCH_LAUNCHER_EOF
chmod 600 "$LUMOSWITCH_ENV"
find "$LUMOSWITCH_ROOT" -type f -exec chmod 600 {} \;
chmod 700 "$LUMOSWITCH_LAUNCHER"
. "$LUMOSWITCH_ENV"
printf '%s\n' 'Native Lumoswitch setup saved. Future command: qwen'
printf '%s\n' 'Optional maintenance launcher: ~/.local/bin/lumoswitch-qwen-code'
qwenFor later sessions, run:
qwenYou can append normal Qwen Code arguments. Before an update, the installer keeps a timestamped copy of the old launcher with 0600 permissions.
Native Windows PowerShell import
These commands run natively in Windows PowerShell without WSL and use the same connection values as the macOS/Linux templates on this page.
One-time use on Windows
& {
$ErrorActionPreference = 'Stop'
$lumoswitchConfig = Join-Path ([IO.Path]::GetTempPath()) ('lumoswitch-' + [Guid]::NewGuid().ToString('N') + '.json')
$lumoswitchConfigContent = @'
{{qwen_settings_json}}
'@
[IO.File]::WriteAllText($lumoswitchConfig, $lumoswitchConfigContent, [Text.UTF8Encoding]::new($false))
$lumoswitchEnvironmentNames = @('LUMOSWITCH_QWEN_API_KEY', 'QWEN_CODE_SYSTEM_SETTINGS_PATH')
$lumoswitchPreviousEnvironment = @{}
foreach ($lumoswitchName in $lumoswitchEnvironmentNames) {
$lumoswitchPreviousEnvironment[$lumoswitchName] = [Environment]::GetEnvironmentVariable($lumoswitchName, 'Process')
}
$lumoswitchExitCode = 0
try {
[Environment]::SetEnvironmentVariable('LUMOSWITCH_QWEN_API_KEY', '{{access_key}}', 'Process')
[Environment]::SetEnvironmentVariable('QWEN_CODE_SYSTEM_SETTINGS_PATH', $lumoswitchConfig, 'Process')
$lumoswitchArguments = @('--auth-type', 'openai', '--model', '{{model}}')
$lumoswitchExecutable = Get-Command 'qwen.cmd' -CommandType Application -ErrorAction SilentlyContinue
if ($null -eq $lumoswitchExecutable) { $lumoswitchExecutable = Get-Command 'qwen' -CommandType Application -ErrorAction Stop }
& $lumoswitchExecutable.Path @lumoswitchArguments
if ($null -ne $LASTEXITCODE) { $lumoswitchExitCode = $LASTEXITCODE }
} finally {
foreach ($lumoswitchName in $lumoswitchEnvironmentNames) {
[Environment]::SetEnvironmentVariable($lumoswitchName, $lumoswitchPreviousEnvironment[$lumoswitchName], 'Process')
}
Remove-Item -LiteralPath $lumoswitchConfig -Force -ErrorAction SilentlyContinue
}
if ($lumoswitchExitCode -ne 0) { throw 'qwen exited with code ' + $lumoswitchExitCode }
}Persistent use on Windows
This command backs up existing Lumoswitch-owned files and restricts access to the configuration and launcher for the current user.
& {
$ErrorActionPreference = 'Stop'
$lumoswitchRoot = Join-Path $env:LOCALAPPDATA 'Lumoswitch\agents\qwen-code'
$lumoswitchLauncher = Join-Path $env:LOCALAPPDATA 'Lumoswitch\bin\lumoswitch-qwen-code.ps1'
$lumoswitchBackupSuffix = (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + $PID
function Protect-LumoswitchFile([string] $Path) {
$lumoswitchSid = [Security.Principal.WindowsIdentity]::GetCurrent().User.Value
& icacls.exe $Path '/inheritance:r' '/grant:r' ('*' + $lumoswitchSid + ':(F)') '*S-1-5-18:(F)' '*S-1-5-32-544:(F)' | Out-Null
if ($LASTEXITCODE -ne 0) { throw "Could not restrict access to $Path" }
}
function Install-LumoswitchFile([string] $Path, [string] $Content) {
[IO.Directory]::CreateDirectory((Split-Path -Parent $Path)) | Out-Null
if (Test-Path -LiteralPath $Path) {
$lumoswitchItem = Get-Item -LiteralPath $Path -Force
if ($lumoswitchItem.PSIsContainer -or ($lumoswitchItem.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
throw "Lumoswitch refused to replace a directory or link: $Path"
}
$lumoswitchBackup = $Path + '.backup.' + $lumoswitchBackupSuffix
Copy-Item -LiteralPath $Path -Destination $lumoswitchBackup
Protect-LumoswitchFile $lumoswitchBackup
}
$lumoswitchTemporary = $Path + '.' + [Guid]::NewGuid().ToString('N') + '.tmp'
try {
[IO.File]::WriteAllText($lumoswitchTemporary, $Content, [Text.UTF8Encoding]::new($false))
Move-Item -LiteralPath $lumoswitchTemporary -Destination $Path -Force
Protect-LumoswitchFile $Path
} finally {
Remove-Item -LiteralPath $lumoswitchTemporary -Force -ErrorAction SilentlyContinue
}
}
[IO.Directory]::CreateDirectory($lumoswitchRoot) | Out-Null
$lumoswitchQwenSettings = Join-Path $lumoswitchRoot 'settings.json'
Install-LumoswitchFile $lumoswitchQwenSettings '{{qwen_settings_json}}'
$lumoswitchEnvironment = [ordered]@{}
$lumoswitchEnvironment['QWEN_CODE_SYSTEM_SETTINGS_PATH'] = (Join-Path $lumoswitchRoot 'settings.json')
$lumoswitchEnvironment['LUMOSWITCH_QWEN_API_KEY'] = '{{access_key}}'
$lumoswitchEnvironment['LUMOSWITCH_QWEN_MODEL'] = '{{model}}'
foreach ($lumoswitchEntry in $lumoswitchEnvironment.GetEnumerator()) {
[Environment]::SetEnvironmentVariable($lumoswitchEntry.Key, $lumoswitchEntry.Value, 'User')
[Environment]::SetEnvironmentVariable($lumoswitchEntry.Key, $lumoswitchEntry.Value, 'Process')
}
$lumoswitchLauncherContent = @'
param([Parameter(ValueFromRemainingArguments = $true)][string[]] $AgentArgs)
$ErrorActionPreference = 'Stop'
$lumoswitchRoot = Join-Path $env:LOCALAPPDATA 'Lumoswitch\agents\qwen-code'
$lumoswitchLauncher = Join-Path $env:LOCALAPPDATA 'Lumoswitch\bin\lumoswitch-qwen-code.ps1'
function Remove-LumoswitchFile([string] $Path) {
if (-not (Test-Path -LiteralPath $Path)) { return }
$lumoswitchItem = Get-Item -LiteralPath $Path -Force
if ($lumoswitchItem.PSIsContainer -or ($lumoswitchItem.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
throw "Lumoswitch refused to remove a directory or link: $Path"
}
Remove-Item -LiteralPath $Path -Force
}
if ($AgentArgs.Count -gt 0 -and $AgentArgs[0] -eq '--lumoswitch-clean') {
foreach ($lumoswitchName in @('QWEN_CODE_SYSTEM_SETTINGS_PATH', 'LUMOSWITCH_QWEN_API_KEY', 'LUMOSWITCH_QWEN_MODEL')) {
[Environment]::SetEnvironmentVariable($lumoswitchName, $null, 'User')
[Environment]::SetEnvironmentVariable($lumoswitchName, $null, 'Process')
}
if (Test-Path -LiteralPath $lumoswitchRoot -PathType Container) {
$lumoswitchRootItem = Get-Item -LiteralPath $lumoswitchRoot -Force
if ($lumoswitchRootItem.Attributes -band [IO.FileAttributes]::ReparsePoint) { throw 'Lumoswitch refused to clean through a linked directory.' }
foreach ($lumoswitchFile in @(Get-ChildItem -LiteralPath $lumoswitchRoot -File -Recurse -Force)) { Remove-LumoswitchFile $lumoswitchFile.FullName }
foreach ($lumoswitchDirectory in @(Get-ChildItem -LiteralPath $lumoswitchRoot -Directory -Recurse -Force | Sort-Object FullName -Descending)) {
if ($null -eq (Get-ChildItem -LiteralPath $lumoswitchDirectory.FullName -Force | Select-Object -First 1)) { Remove-Item -LiteralPath $lumoswitchDirectory.FullName -Force }
}
if ($null -eq (Get-ChildItem -LiteralPath $lumoswitchRoot -Force | Select-Object -First 1)) { Remove-Item -LiteralPath $lumoswitchRoot -Force }
}
$lumoswitchBin = Split-Path -Parent $lumoswitchLauncher
if (Test-Path -LiteralPath $lumoswitchBin -PathType Container) {
foreach ($lumoswitchBackup in @(Get-ChildItem -LiteralPath $lumoswitchBin -Filter 'lumoswitch-qwen-code.ps1.backup.*' -File -Force)) { Remove-LumoswitchFile $lumoswitchBackup.FullName }
}
Remove-LumoswitchFile $lumoswitchLauncher
Write-Host 'Lumoswitch native setup and optional launcher removed. Open a new terminal to refresh the environment.'
exit 0
}
$lumoswitchEnvironment = [ordered]@{}
$lumoswitchEnvironment['QWEN_CODE_SYSTEM_SETTINGS_PATH'] = (Join-Path $lumoswitchRoot 'settings.json')
$lumoswitchEnvironment['LUMOSWITCH_QWEN_API_KEY'] = '{{access_key}}'
$lumoswitchEnvironment['LUMOSWITCH_QWEN_MODEL'] = '{{model}}'
foreach ($lumoswitchEntry in $lumoswitchEnvironment.GetEnumerator()) {
[Environment]::SetEnvironmentVariable($lumoswitchEntry.Key, $lumoswitchEntry.Value, 'Process')
}
$lumoswitchExecutable = Get-Command 'qwen.cmd' -CommandType Application -ErrorAction SilentlyContinue
if ($null -eq $lumoswitchExecutable) { $lumoswitchExecutable = Get-Command 'qwen.exe' -CommandType Application -ErrorAction SilentlyContinue }
if ($null -eq $lumoswitchExecutable) { $lumoswitchExecutable = Get-Command 'qwen' -CommandType Application -ErrorAction Stop }
$lumoswitchArguments = @()
& $lumoswitchExecutable.Path @lumoswitchArguments @AgentArgs
if ($null -ne $LASTEXITCODE) { exit $LASTEXITCODE }
'@
Install-LumoswitchFile $lumoswitchLauncher $lumoswitchLauncherContent
Write-Host 'Native Lumoswitch setup saved. Future command: qwen'
Write-Host 'Optional maintenance launcher:' $lumoswitchLauncher
$lumoswitchExecutable = Get-Command 'qwen.cmd' -CommandType Application -ErrorAction SilentlyContinue
if ($null -eq $lumoswitchExecutable) { $lumoswitchExecutable = Get-Command 'qwen.exe' -CommandType Application -ErrorAction SilentlyContinue }
if ($null -eq $lumoswitchExecutable) { $lumoswitchExecutable = Get-Command 'qwen' -CommandType Application -ErrorAction Stop }
$lumoswitchArguments = @()
& $lumoswitchExecutable.Path @lumoswitchArguments
if ($null -ne $LASTEXITCODE -and $LASTEXITCODE -ne 0) { throw 'qwen exited with code ' + $LASTEXITCODE }
}The import writes the Agent-supported persistent configuration and starts qwen directly. The saved Lumoswitch maintenance script is not required to start the Agent; run it with --lumoswitch-clean when you need to restore or remove this setup.
Remove the CLI setup
Windows PowerShell
Exit every Lumoswitch session for this Agent, then run the command below. The optional maintenance launcher removes the managed native configuration, restores any preserved shared file, clears Lumoswitch user environment values, and removes itself.
& {
$lumoswitchLauncher = Join-Path $env:LOCALAPPDATA 'Lumoswitch\bin\lumoswitch-qwen-code.ps1'
if (-not (Test-Path -LiteralPath $lumoswitchLauncher -PathType Leaf)) {
throw 'The optional Lumoswitch maintenance launcher is missing. Run persistent import again before cleanup.'
}
& powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File $lumoswitchLauncher --lumoswitch-clean
}macOS / Linux
This command removes the managed Qwen settings path, environment hook, optional launcher, and backups. It does not remove ~/.qwen/settings.json, Qwen Code sign-in state, history, or other user configuration.
"$HOME/.local/bin/lumoswitch-qwen-code" --lumoswitch-cleanThe one-time command deletes its temporary settings file on exit and leaves nothing in the current terminal. If you manually exported LUMOSWITCH_QWEN_API_KEY, close that terminal window; it is not unset automatically because another Lumoswitch tool in the same terminal may share it.
VS Code and IDE Companion
Connect the current CLI
Start Qwen Code with this page's command, then follow the official IDE Integration flow to connect the Companion to the current CLI process. It continues using the current Lumoswitch URL, Key, and model without storing a second credential. A one-time setup expires when that CLI process exits.
Native VS Code sidebar
The native extension sidebar starts Qwen Code itself and does not guarantee that it will invoke ~/.local/bin/lumoswitch-qwen-code. To use Lumoswitch directly in the sidebar, merge this model entry into the openai array in user-level ~/.qwen/settings.json. Do not replace existing model entries or the whole settings file.
{
"modelProviders": {
"openai": [
{
"id": "{{model}}",
"name": "Lumoswitch · {{model}}",
"envKey": "LUMOSWITCH_QWEN_API_KEY",
"baseUrl": "{{api_base_url}}"
}
]
},
"security": {
"auth": {
"selectedType": "openai"
}
},
"model": {
"name": "{{model}}"
}
}Then provide LUMOSWITCH_QWEN_API_KEY={{access_key}} in the user environment read by Qwen Code or in ~/.qwen/.env, and fully restart the extension. Never place a real Key in a project file that can be committed to Git.
The native sidebar has persistent setup only. There is no reliable one-time launch command because the extension reads a stored provider and its own launch environment. Removing the CLI launcher also does not edit this user-owned configuration. To remove sidebar access, delete only the Lumoswitch entry you added to modelProviders.openai, remove the matching LUMOSWITCH_QWEN_API_KEY line, and select another model. No automatic removal command is provided here because a generic script could corrupt shared JSON, .env, or unrelated providers.
See Qwen Code VS Code integration, IDE Integration, and model provider configuration.
Verify and troubleshoot
- Start with a simple request, then test file reads and tool calls. Confirm the model and Access Key in Lumoswitch request logs.
404: check whether/v1is missing or duplicated in the downstream URL.- The IDE uses its default model: verify that the Companion is attached to the current CLI; the native sidebar needs the separate user-level provider entry.
- A project-level
.qwen/settings.jsoncan override user-level settings. Fully restart the extension after a change.
Maintainer publishing fields
- Platform ID:
qwen-code - Display name:
Qwen Code CLI - Downstream protocol:
openai-compatible commandTemplate: copy the complete code block under "One-time launch"- Persistence strategy:
native persistentCommandTemplate: copy the complete setup command under "Persistent use"futureCommand:qwen- Display order:
60 - Last verified:
2026-08-27