cd /news/ai-tools/self-hosted-ai-coding-assistant-12-s… · home › topics › ai-tools › article
[ARTICLE · art-154122] src=shattered.io ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

Self-Hosted AI Coding Assistant: 12 Steps, 60 Min [2026]

Alibaba's open-source coding agent Qwen Code reached stable version 0.25.2 on October 15, 2026, followed by build 0.25.3 on October 19, both free under the Apache-2.0 license and installable with a single npm command. The releases are positioned for developers who pair Qwen Code with the MIT-licensed, provider-agnostic terminal runner OpenCode to self-host a coding assistant rather than route files through a single vendor's cloud, a setup the guide says takes 12 steps and about 60 minutes. The guide cites the 2025 Stack Overflow Developer Survey finding that 84% of developers already use or plan to use AI tools, and that 51% of professional developers use AI tools daily while 31% report using AI agents specifically.

by read29 min views1 publishedOct 20, 2026
Self-Hosted AI Coding Assistant: 12 Steps, 60 Min [2026]
Image: Shattered (auto-discovered)

Developers who want an AI coding assistant that does not route every keystroke through a single vendor’s cloud have more real options in October 2026 than they did a year ago. Qwen Code, Alibaba’s open-source coding agent, shipped stable version 0.25.2 on October 15, 2026, with a follow-up build, 0.25.3, landing just four days later on October 19. Both are free, Apache-2.0 licensed, and installable with a single npm command. Pair that agent with an open, provider-agnostic runner like OpenCode and you get a terminal-first coding setup where you choose the model, the host, and the price, instead of accepting whatever a single IDE vendor bundles.

According to the 2025 Stack Overflow Developer Survey, 84% of developers already use or plan to use AI tools in their workflow, so the local-model path below is not a fringe case. By the end you will have a working, reproducible, self-hosted coding agent and a troubleshooting reference for when it breaks.

Don't miss new tech stories on Google

Add Shattered once in the Google app and our stories show up in your news suggestions.

Add now

Why Self-Host an AI Coding Assistant in 2026 #

Commercial AI coding tools bill per seat, often lock a team into one model family, and send every file a developer opens through a third-party API. For regulated industries, air-gapped environments, or teams that simply want a predictable monthly cost, a self-hosted AI coding assistant removes those constraints. Qwen Code is Alibaba’s answer to that demand: an open-source coding agent, licensed under Apache-2.0, that runs in a terminal, a browser, a desktop app, or inside an editor through companion extensions. It is free to install, though model access through a hosted provider can carry its own charges.

The open-source angle also matters for anyone who has watched a commercial coding tool change its pricing or model lineup with little warning. When the agent itself is open source, a vendor’s business decision cannot strand your workflow: you can fork the project, pin an older version, or move to a different model provider without waiting on anyone’s roadmap. That is the practical difference between “open source” as a marketing label and “open source” as an actual operational safeguard, and it is the reason this guide treats self-hosting as a serious default rather than a hobbyist niche.

Pairing Qwen Code with an agent runner such as OpenCode (an MIT-licensed, provider-agnostic terminal coding agent) gives developers a layer that is not tied to any single model vendor. OpenCode’s own homepage FAQ states plainly: “OpenCode is 100% free to use. It also comes with a set of free models. There might be additional costs if you connect any other provider.” That framing matters for this tutorial, because the installation steps below treat the runner and the model as two separate decisions, which is the whole point of going open source instead of buying a bundled subscription.

There is also a procurement angle that engineering leads tend to underweight until a vendor renegotiation forces the issue. A commercial per-seat AI coding subscription is a recurring line item that scales with headcount, with pricing set by a vendor that can change terms on renewal. A self-hosted stack built on Apache-2.0 and MIT-licensed tooling has no seat count and no renewal negotiation; the only recurring cost is whatever model access you choose to pay for, and you can swap that provider without touching the rest of your workflow. For a platform team evaluating a dozen developers’ worth of tooling spend, that difference alone is often the deciding factor, independent of any feature comparison.

Stack Overflow’s 2025 survey also found that 51% of professional developers now use AI tools daily and 31% report using AI agents specifically, not just autocomplete. That shift toward agentic workflows, where the tool edits multiple files, runs shell commands, and iterates without a human approving every line, is exactly what Qwen Code and OpenCode are built for. The setup in this guide targets that agentic use case directly, rather than a simple inline-completion plugin.

Prerequisites and Supported Versions #

Confirm each of these before starting. Version mismatches are the single most common cause of a broken self-hosted coding assistant setup, and skipping this checklist is the fastest way to lose an afternoon to debugging a tool that was never going to work with your installed runtime.

  • Node.js 20 LTS or newer (Qwen Code’s npm package requires a current Node runtime; older LTS lines are not supported)
  • npm 10.x or newer, bundled with current Node.js installers
  • Qwen Code CLI, installed via the @qwen-code/qwen-code npm package, stable release 0.25.2 shipped October 15, 2026, with 0.25.3 following October 19, 2026
  • A terminal with SSH access if you plan to edit remote projects (Qwen Code added SSH project editing in its September 24, 2026 update cycle)
  • Git, installed and configured with a working identity (git config user.name / user.email)
  • Optional: Ollama, for fully local model inference with no outbound API calls
  • Optional: Docker, if you want to run the agent inside a sandboxed execution backend (note: Qwen Code’s documented Docker backend disables workflows, Agent Team, MCP, and LSP features, and does not yet support Windows)
  • An account with a model provider if you are not running local-only: this can be Alibaba Cloud Model Studio, a third-party API key, or any OpenAI-compatible endpoint
  • At least 8GB of free RAM if running a local model via Ollama; 16GB or more recommended for anything beyond a small quantized model
  • macOS, Linux, or Windows with WSL2 (native Windows support for some advanced execution backends remains incomplete as of this writing)

One clarification worth making up front: OpenCode’s own release history is genuinely confusing right now. Some third-party trackers describe an OpenCode 2.x line, while OpenCode’s official changelog and GitHub Releases page were still showing 1.x version numbers as recently reported. OpenCode’s own documentation advises treating GitHub Releases as the authoritative source for the current version rather than any third-party summary, including this one. Check https://github.com/opencode-ai/opencode/releases (or whichever fork you are installing) before you commit to a specific version number in a CI pipeline.

Here is roughly what to expect for time investment if you follow all twelve steps below in order, assuming you already have a terminal open and admin rights on your machine:

Step What it covers Approx. time
1–2 Node.js setup and Qwen Code CLI install 5–10 min
3–4 Authentication, hosted provider, or local Ollama model 10–20 min (longer if pulling a large local model)
5–6 First session, worktree isolation, steering 5–10 min
7–8 OpenCode runner and multi-tool collaboration 10–15 min
9–10 Background jobs and security hardening 10–15 min
11–12 Benchmarking and upgrade automation 5–10 min

Total hands-on time runs close to an hour for a first-time setup, most of it spent waiting on a local model download in Step 4 if you choose that path. Skipping the local-model steps and going hosted-only cuts that closer to 30 minutes.

Step 1: Install Node.js and Verify Your Environment #

Start clean. If you already have Node.js installed, verify the version before doing anything else, this single check prevents most of the installation failures covered in the troubleshooting section further down.

node --version
npm --version

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20

Expected output after the version checks succeed:

v20.18.1
10.8.2

If npm –version returns an error about a missing command, your Node installation is incomplete; reinstall rather than trying to patch npm separately.

Step 2: Install the Qwen Code CLI #

Qwen Code’s official installation and upgrade path is a global npm install of the @qwen-code/qwen-code package. This is the same command the Qwen Code team publishes in its own weekly update posts, so it is safe to script into a provisioning pipeline.

npm i -g @qwen-code/qwen-code@latest

qwen --version

Running qwen –version should return something close to the current stable line (0.25.2 or 0.25.3 as of October 2026, depending on when you install). If you need to pin to a specific version for reproducibility across a team, install with an explicit version tag instead of @latest:

npm i -g @qwen-code/[email protected]

Qwen Code also ships a desktop application and a VS Code companion extension as separate release lines, so a CLI install does not automatically give you the desktop GUI. If your team wants both, install each separately and keep their versions in sync when you upgrade, since the desktop build and CLI build are versioned independently.

Step 3: Authenticate and Choose a Model Access Path #

This is the step where most of the “self-hosted” decision actually happens. Qwen Code itself is free and open source, but it needs a model to talk to, and you have three realistic routes: a hosted provider API key, Alibaba Cloud Model Studio’s Coding Plan, or a fully local model through Ollama or a compatible local server. Model Studio access is reported by third parties to include tiers such as a Coding Plan Pro priced around $50 per month with stated request quotas, though you should confirm current pricing directly with Alibaba Cloud before committing a budget, since quoted third-party prices can lag official changes.

Option A: A Hosted Provider API Key

This is the fastest path and the one most developers start with. You supply any OpenAI-compatible or Qwen-compatible provider key, and Qwen Code routes requests through that provider’s API. It is billed per token by whichever provider you choose, so your monthly cost scales directly with usage rather than being fixed up front.

qwen auth login

export QWEN_API_KEY="your-api-key-here"
export QWEN_MODEL="qwen3-max"

Option B: Alibaba Cloud Model Studio

Model Studio is Alibaba’s own access route for Qwen Code, offering the Coding Plan and separate token-based team usage rather than one bundled flat-rate subscription. This path suits teams standardizing specifically on Qwen models who want a predictable monthly cost on the Coding Plan rather than usage-based billing that can spike during a heavy sprint.

qwen auth login --provider model-studio

export DASHSCOPE_API_KEY="your-model-studio-key"

Worth noting for teams evaluating cost: Qwen Code previously offered a free OAuth tier that let developers try the agent without an API key, but third-party reports indicate that free OAuth tier was discontinued around April 15, 2026. Treat any guide (including older versions of this one) that promises a no-cost OAuth login as outdated, and budget for either a provider key or local inference instead. Independent setup walkthroughs, such as Developer’s Digest’s guide to wiring Qwen into multiple coding tools, are worth cross-checking against the official docs before you standardize a team on one auth path.

Step 4: Run Qwen Code Fully Local With Ollama #

If the goal of self-hosting is zero outbound API calls, point Qwen Code at a local Ollama server instead of a cloud provider. This is the configuration most relevant to regulated environments and to professional developers who want model inference to stay entirely on infrastructure they control.

curl -fsSL https://ollama.com/install.sh | sh

ollama pull qwen2.5-coder:32b

ollama serve

export OPENAI_BASE_URL="http://localhost:11434/v1"
export OPENAI_API_KEY="ollama"
export QWEN_MODEL="qwen2.5-coder:32b"

Local inference trades raw capability for privacy and cost control. A 32-billion-parameter quantized model on consumer hardware will not match a frontier hosted model on the hardest refactoring tasks, but for routine code review, test generation, and boilerplate, it is frequently good enough, and it never leaves your machine.

Step 5: Initialize a Project and Run Your First Session #

With authentication sorted, start the agent inside a real project directory, not an empty scratch folder. Qwen Code reads the surrounding repository for context, so running it from the project root matters.

cd ~/projects/my-app
qwen

> Explain what src/auth/session.ts does and flag any obvious race conditions

Expected output resembles a normal chat turn, followed by the agent reading the referenced file and returning a structured explanation, typically with specific line references. If the agent returns a generic answer with no file-specific detail, it likely failed to index the project; check that you launched it from inside the repository and that your provider key or local model path is reachable.

Step 6: Use Real-Time Steering and Session Continuity #

Qwen Code added real-time steering, letting a developer correct the agent’s direction mid-stream instead of waiting for a full response and then re-prompting, along with isolated worktree sessions, in its July 23, 2026 update cycle. These two features change how you should work with the tool day to day.

To interrupt and redirect a running task, press the documented steering key combination mid-response rather than killing the session. To keep a long-running feature branch isolated from your main working tree, launch a worktree-scoped session:

git worktree add ../my-app-feature-x feature/x
cd ../my-app-feature-x
qwen --worktree

This keeps the agent’s edits scoped to the worktree, so a long agentic task on a feature branch cannot accidentally touch files you are actively editing on main in a separate terminal tab. It is a small habit that pays off disproportionately once you start running multiple agent sessions at once, since each worktree gives the agent its own clean checkout to operate on without stepping on a sibling session’s uncommitted changes.

Step 7: Connect an Open Agent Runner (OpenCode) #

OpenCode is a separate, MIT-licensed project that acts as a provider-agnostic runner: instead of being built around one model, it is designed to plug into many. Current documentation describes support for a large number of model providers, native LSP support for language-aware edits, and multi-agent functionality for splitting a task across cooperating agents.

npm i -g @opencode/cli

opencode --version
opencode init

Because OpenCode’s own release numbering has been reported inconsistently across its homepage, changelog, and GitHub Releases page during October 2026, do not hardcode a version number into a Dockerfile or CI script. Instead, pin to a commit SHA or a tag you have personally verified against the live Releases page at install time.

OpenCode also ships a pay-as-you-go hosted model gateway, which recent documentation refers to as OpenCode Console (older material calls the same feature Zen). It is not required for the self-hosted setup in this guide, you can point OpenCode at Qwen Code, a local Ollama endpoint, or any other provider you already configured in Step 3. Third-party tooling roundups like QCode’s coding tools and integrations guide track which editors and runners support which providers, which is useful if your stack includes more than Qwen Code and OpenCode.

Step 8: Configure Multi-Tool Collaboration #

One of the more unusual features to ship in October 2026 is direct agent-to-agent collaboration. Qwen Code’s October 15, 2026 update added the ability to invoke Claude Code or Codex as teammates inside a Qwen Code conversation using an @ mention, so answers from those tools can enter the current session instead of requiring a context switch to a separate terminal window.

> @claude-code review the diff in this session for security issues

qwen --disable-mcp-server filesystem-extended

The same October 15 update introduced a single-page view for managing multiple connected Qwen Code projects and sessions simultaneously, which is useful if you run several agent sessions against different repositories and want one dashboard instead of juggling terminal tabs.

Step 9: Set Up Background and Batch Jobs #

Not every agentic task needs a human watching. Qwen Code added persistent background agents in its July 30, 2026 update, letting a long task keep running after you close the terminal, and later documentation describes a batch API that runs approved jobs asynchronously at roughly half the real-time rate, typically completing within 24 hours.

qwen --background "Migrate all class components in src/components to functional components with hooks"

qwen jobs list

Batch pricing is meant for non-urgent work: large-scale refactors, bulk documentation generation, or dependency upgrades across many files, where waiting a few hours for a lower rate is an easy tradeoff. Confirm current batch pricing and eligibility directly in your provider’s billing console before scheduling large jobs, since documented rates can change between releases.

Step 10: Harden Your Self-Hosted Setup #

A self-hosted AI coding assistant is only as secure as the keys and permissions you hand it. Agentic tools that can run shell commands and write files need the same scrutiny you would give a CI runner with repo write access, not the casual trust you might give a read-only autocomplete plugin.

Credential Hygiene

  • Never commit QWEN_API_KEY, OPENAI_API_KEY, or provider tokens to version control; use a .env file excluded via .gitignore, or a secrets manager for team setups
  • Scope API keys to the minimum provider permissions available, rather than reusing an account-wide key across every tool on your machine
  • Rotate provider keys on a schedule, and immediately after any laptop loss, contractor offboarding, or shared-terminal incident
  • Keep separate keys for local experimentation versus anything wired into CI, so a leak in one place does not force you to rotate credentials used everywhere

Sandbox and Audit Controls

  • Run the agent’s Docker execution backend when working with untrusted repositories, accepting that workflows, Agent Team, MCP, and LSP features are disabled in that mode
  • Audit which MCP servers are enabled by default; disable any you do not actively use with the –disable-mcp-server flag shown in Step 8
  • Review session logs periodically for commands the agent ran autonomously, especially in background or batch mode where no human approved each step in real time
  • Restrict the agent’s working directory to the specific repository it needs, rather than launching it from a home directory where it can see every project on the machine

Teams that skip this step are not hypothetical. AI coding agents sit near the top of credential-exposure risk precisely because they are designed to run commands and read files broadly; a leaked key paired with broad filesystem access is a materially worse incident than a leaked key for a read-only API.

Step 11: Benchmark Local vs. Hosted Model Performance #

Before standardizing a team on one configuration, run the same representative task through both a hosted model and your local Ollama model, and compare completion time, correctness, and cost. Pick a task that resembles your actual day-to-day work, not a toy example: a real bug fix, a real test file, or a real small feature, since synthetic benchmarks tend to flatter whichever model you already expect to win. The table below reflects the structural differences between the common configuration paths covered in this guide; exact latency and cost will vary by your hardware, provider, and workload.

Configuration Model access Outbound network calls Typical cost model Best for
Qwen Code + hosted API key Any OpenAI-compatible or Qwen provider Yes, per request Per-token billing via provider Teams wanting frontier model quality with minimal setup
Qwen Code + Alibaba Model Studio Qwen model family via Coding Plan Yes, per request Flat monthly tier, reportedly near $50/mo for Pro Teams standardizing on Qwen models specifically
Qwen Code + Ollama (local) Open-weight model on local hardware None One-time hardware cost only Regulated environments, air-gapped work, cost-sensitive teams
Qwen Code + OpenCode runner Whichever provider OpenCode is configured for Depends on configured provider Depends on configured provider; OpenCode CLI itself is free Teams wanting a provider-agnostic agent layer across multiple models
Qwen Code Docker sandbox Any configured provider Depends on configured provider Same as underlying provider Running the agent against untrusted or third-party repositories

Step 12: Automate Upgrades Without Breaking Your Pipeline #

Qwen Code ships new stable releases roughly every week; two releases, v0.25.1 and v0.25.2, shipped in a single week in mid-October 2026 alone, with 371 merged pull requests behind them according to the project’s own weekly update post. That pace is good for features and bad for anyone who pins @latest in an automated build.

npm i -g @qwen-code/[email protected]

npm i -g @qwen-code/qwen-code@latest

Treat the CLI the way you would treat any fast-moving dependency: pin it in anything reproducible, and read the weekly update notes before bumping the pinned version in a shared team configuration, since new releases have introduced behavior changes like the MCP server disable flag and the Docker backend’s feature restrictions without much advance notice.

Common Pitfalls When Self-Hosting an AI Coding Assistant #

These mistakes show up repeatedly in self-hosted agent setups, and most of them are avoidable with a five-minute check before you start a real project.

  • Assuming “free CLI” means “free inference.” Qwen Code and OpenCode are both free, open-source tools, but the model behind them is a separate billing relationship unless you run fully local. Teams that skip this distinction often discover the real bill only when a provider invoice arrives at the end of the month.
  • Hardcoding a version number from a blog post into a Dockerfile. OpenCode’s release numbering has been inconsistent across sources in October 2026; always check the live GitHub Releases page before pinning, since a version string copied from a tutorial can already be stale by the time you deploy it.
  • Running the Docker execution backend and expecting full feature parity. Workflows, Agent Team, MCP, and LSP are documented as disabled in that sandboxed mode, so a task that worked fine outside the sandbox can fail with a confusing error once moved inside it.
  • Leaving background or batch jobs unattended with broad repo write access. A background agent can run for hours; scope its target directory narrowly so an unsupervised multi-hour job cannot wander into parts of the codebase it was never meant to touch.
  • Expecting the discontinued OAuth free tier to still work. Guides written before April 2026 may reference a no-cost login path that third-party reports say was retired; following an outdated tutorial here wastes time on an auth flow that no longer exists.
  • Skipping the worktree isolation step on long feature branches. Without it, a long agentic task and your own manual edits on the same branch can collide, producing merge conflicts that are harder to untangle than if the work had simply been isolated from the start.
  • Under-provisioning RAM for a local model and blaming the agent for slow or wrong answers. A 32B model that is swapping to disk will produce worse completions than the same model with adequate memory, and the apparent quality drop has nothing to do with the model itself.
  • Treating every MCP server as safe by default. Audit what is enabled; disable servers you are not actively using, the same way you would review third-party dependencies before adding them to a production build.
  • Mixing pinned and @latest installs across a team. If half your engineers run a pinned CLI version and the other half track @latest, bug reports become inconsistent and hard to reproduce, since nobody is actually running the same tool.

Troubleshooting Guide #

Work through these in order when something breaks. Most self-hosted agent issues trace back to one of eight root causes.

  • qwen: command not found after install. Your global npm bin directory is probably not on PATH. Run npm config get prefix and add /bin to your shell profile, then open a new terminal so the updated PATH actually takes effect.
  • Agent returns generic answers with no file-specific detail. You likely launched the session outside the project root. cd into the repository root and restart; the agent needs to see your actual file tree to give grounded answers instead of generic boilerplate.
  • Authentication fails with a valid-looking API key. Check for a stray newline or quote character copied into the key; re-export the variable cleanly with export QWEN_API_KEY=”key” and no trailing whitespace. Keys copied from a browser often pick up an invisible trailing newline.
  • Local Ollama model responds extremely slowly. Check available RAM with free -h (Linux) or Activity Monitor (macOS); a model that exceeds available memory will swap to disk and crawl. Dropping to a smaller quantized model is usually faster than waiting out the swap.
  • npm i -g fails with a permissions error. Avoid sudo npm install; instead fix npm’s default directory ownership or use a Node version manager like nvm, which installs to a user-owned path and sidesteps the permissions issue entirely.
  • OpenCode cannot find the configured provider. Confirm the provider’s environment variables are exported in the same shell session where you launched OpenCode, not just set in a different terminal tab; environment variables do not persist across separate shell sessions unless written to your profile.
  • Background job appears to hang indefinitely. Run qwen jobs list to check actual status before assuming it crashed; some long refactors legitimately take 20+ minutes, and killing a healthy job mid-run can leave a partially edited codebase.
  • Docker execution backend rejects a workflow command. This is expected; workflows are documented as unsupported in the Docker backend. Run that specific task outside the sandbox, on a repository you trust.
  • Version mismatch between CLI and desktop app causes sync errors. The CLI and desktop builds are versioned independently; upgrade both together rather than assuming one auto-updates the other, and check each tool’s own version command separately.
  • MCP server fails to start on launch. Check the server’s own logs first; if it is not needed for the current task, disable it with –disable-mcp-server and move on rather than debugging a dependency you were not actually planning to use.

Advanced Tips for Production Use #

Once the basic setup is stable, a few refinements make a real difference for teams running this in production rather than on a single developer’s laptop.

First, separate your provider keys by environment. A key used for exploratory local development should not be the same key wired into a CI pipeline that runs batch refactors against your entire codebase; if one leaks, you want to revoke it without taking down the other.

Second, use the /learn style skill-capture functionality documented in Qwen Code’s July 30, 2026 update to turn a recorded walkthrough into a reusable skill, rather than re-explaining the same multi-step task to the agent every time a new team member needs it done. This turns tribal knowledge about your codebase’s quirks into something the agent can apply consistently.

Third, if your team is already invested in Claude Code or Codex for specific tasks, use the agent-collaboration feature from Step 8 rather than running three separate, uncoordinated agent sessions against the same repository. Having one agent invoke another as a reviewer inside a single session reduces the chance of conflicting edits.

Fourth, budget realistically for batch work. The roughly half-price asynchronous batch rate documented for non-urgent jobs is meaningful at scale: a large dependency migration that would cost real money at real-time rates becomes substantially cheaper if you can tolerate a same-day turnaround instead of an immediate one.

Fifth, decide on a model-switching policy before you need one, not during an incident. Because this entire setup is deliberately provider-agnostic, switching from a hosted API key to a local Ollama model, or from one hosted provider to another, should be a configuration change, not a re-architecture. Document the exact environment variables your team uses for each path (hosted, Model Studio, local) in a shared internal wiki page, so that if a provider has an outage or a price change forces a switch, any engineer on the team can flip the configuration in minutes rather than reverse-engineering a teammate’s personal setup under time pressure.

Complete Working Project: A Self-Hosted Coding Agent Stack #

Putting every step together, here is a minimal provisioning script that installs Qwen Code, sets up a local Ollama fallback model, and configures environment variables for both a hosted provider and a local path, so you can switch between them per task.

#!/usr/bin/env bash
set -euo pipefail

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 20
nvm use 20

npm i -g @qwen-code/[email protected]

curl -fsSL https://ollama.com/install.sh | sh
ollama pull qwen2.5-coder:32b &

cat >> ~/.bashrc <<'EOF'
export QWEN_API_KEY="your-provider-key-here"
export QWEN_MODEL="qwen3-max"
EOF


echo "Setup complete. Run 'qwen' inside a project directory to start a session."

Save this as setup-qwen-code.sh, review the provider key placeholder before running it on a shared machine, and run bash setup-qwen-code.sh from a clean shell. On a typical cloud development VM, the full script completes in under five minutes excluding the time to pull the local model, which depends on your connection speed and the model's file size.

For a team provisioning multiple developer machines, wrap this same script in your existing configuration-management tool (Ansible, a Docker base image, or a simple cloud-init script for new VMs) rather than having each engineer run it manually. The script is deliberately idempotent-friendly: re-running it after an upgrade just reinstalls the pinned CLI version and leaves your existing Ollama models and shell configuration untouched. If you standardize on a specific pinned version across the team, bump the version string in one place in this script and redistribute it, rather than asking each developer to remember to update their own local install.

Comparing Qwen Code to Other Open-Source Options #

Qwen Code is not the only open-source agent in this space, and picking the right one depends on how your team already works. The table below summarizes the licensing and access model for the tools referenced throughout this guide.

Tool License Interface Latest stable version referenced Model flexibility
Qwen Code Apache-2.0 Terminal, desktop app, VS Code companion v0.25.2 (Oct. 15, 2026); v0.25.3 reported Oct. 19, 2026 Qwen models by default; configurable to other providers
OpenCode MIT Terminal, desktop, web Version numbering inconsistent across sources; check GitHub Releases directly Provider-agnostic by design; large number of supported providers documented
Ollama (inference layer, not an agent) MIT CLI, local API server Actively maintained; check ollama --version for your install Any open-weight model you choose to pull locally

If your team wants a Qwen-first setup with the option to fall back to local inference, start with Qwen Code directly, as shown throughout this guide. If you want a single runner that can swap between many model providers without changing your daily workflow, layer OpenCode on top, but verify its exact current version against GitHub Releases rather than any single blog post, including this one, given how much its release numbering has shifted during 2026. For a broader survey of free and local-first alternatives beyond the two tools covered here, AtomicAgent's roundup of open-source coding-agent alternatives is a useful starting point for comparison shopping.

Frequently Asked Questions #

Is Qwen Code actually free?

The CLI itself is free and Apache-2.0 licensed. Model access is separate: a local model through Ollama costs nothing beyond your own hardware, while a hosted provider or Alibaba Cloud Model Studio access is billed by the provider.

What happened to Qwen Code's free OAuth login?

Third-party reports indicate the free OAuth tier was discontinued around April 15, 2026. If you are following an older tutorial that references a no-cost OAuth login, expect it to no longer work and plan for a provider key or local model instead.

Can I run Qwen Code entirely offline?

Yes, by pointing it at a local Ollama server instead of a hosted provider, as covered in Step 4. You lose access to the largest hosted models, but you gain full data privacy and no per-token cost.

Do I need OpenCode if I already have Qwen Code working?

No. OpenCode is an optional, separate runner useful if you want one interface that can switch between many model providers. Qwen Code works standalone without it.

Why does OpenCode's version number look different depending on where I check?

OpenCode's homepage, changelog, and GitHub Releases page have shown inconsistent version numbers during October 2026 according to multiple third-party trackers. Treat the live GitHub Releases page as the authoritative source, and avoid hardcoding a specific version into automated deployment scripts.

Is the Docker execution backend safe for untrusted repositories?

It is the documented safer option for that use case, but it comes with real feature tradeoffs: workflows, Agent Team, MCP, and LSP support are disabled in that sandboxed mode, and Windows is not yet supported for it.

How often should I upgrade the Qwen Code CLI?

Qwen Code has shipped roughly weekly stable releases throughout 2026, including two in a single week in mid-October. Pin a specific version in any reproducible environment like CI, and upgrade deliberately after reading the weekly release notes rather than always tracking @latest.

What is the biggest security risk in a self-hosted agent setup like this?

Broad, unscoped provider API keys combined with an agent that can run shell commands and write files. Scope keys narrowly, rotate them on a schedule, and audit which MCP servers are enabled by default, as covered in Step 10.

Can Qwen Code and Claude Code or Codex run in the same session?

Yes. Qwen Code's October 15, 2026 update added agent collaboration, letting you invoke Claude Code or Codex as teammates inside a Qwen Code conversation with an @ mention, as shown in Step 8, instead of switching between separate terminal windows.

── more in #ai-tools 4 stories · sorted by recency
── more on @qwen code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/self-hosted-ai-codin…] indexed:0 read:29min 2026-10-20 · —