Skip to content

DocsCoding agents

Qwen Code

Run Qwen Code, the coding agent built for Qwen models, on your own Osarai GPU through its OpenAI-compatible auth.

Qwen Code is the Qwen team's coding agent for the terminal. It is tuned for Qwen models, so it pairs well with qwen3.8-27b on your instance, and it talks to Osarai over Chat Completions.

Qwen Code answering on qwen3.8-27b served by Osarai
Qwen Code running on an Osarai instance.

Install

Terminal
npm install -g @qwen-code/qwen-code

Qwen Code needs Node.js 22 or newer.

Configure

Qwen Code uses its OpenAI-compatible auth when three variables are set. Put them in your shell for one session, or in ~/.qwen/.env to keep them:

Terminal
export OPENAI_API_KEY="$OSARAI_API_KEY"
export OPENAI_BASE_URL="https://osarai.xyz/v1"
export OPENAI_MODEL="qwen3.8-27b"

So that the interactive interface skips the sign-in choice and knows the real context window, add ~/.qwen/settings.json:

~/.qwen/settings.json
{
  "security": { "auth": { "selectedType": "openai" } },
  "model": {
    "name": "qwen3.8-27b",
    "generationConfig": { "contextWindowSize": 131072 }
  }
}

A .qwen/settings.json in your project overrides the one in your home directory, but keep the key in ~/.qwen/.env, not in the project.

Run

Terminal
cd your-project
qwen

To run one prompt without the interface:

Terminal
qwen -p "Explain what src/math.ts does"

Inside the interface, /stats shows the tokens used so far and /compress summarises the conversation to free context.

Troubleshooting

SymptomFix
Qwen Code asks how to sign inSet the three OPENAI_* variables, or pick OpenAI once; selectedType keeps the choice
401OPENAI_API_KEY holds a key other than your qck_… key, for example an older OpenAI key in your shell
It crashes on start in a containerQwen Code writes to ~/.qwen: make sure HOME points to a directory that exists and is writable
503 … not ready yetThe instance is still starting; wait for Ready on the instance page