Qwen Code CLI reference - Environment variables
Qwen Code environment variables
Qwen Code documents 56 environment variables, including QWEN_HOME, QWEN_RUNTIME_DIR and QWEN_USAGE_STATISTICS_ENABLED. Qwen Code reads these from your shell environment. Each row gives the docs' description, accepted values and an example where one is documented.
Last verified 9 official pagesFull Qwen Code reference
| Variable | Description | Example |
|---|---|---|
QWEN_HOME | Customizes the global configuration directory (default: | -no example |
QWEN_RUNTIME_DIR | Overrides the runtime output directory (conversations, logs, todos); defaults to QWEN_HOME. Docs: QWEN_RUNTIME_DIR | -no example |
QWEN_USAGE_STATISTICS_ENABLED | Set to Overrides the | -no example |
QWEN_TELEMETRY_ENABLED | Set to Overrides the | -no example |
QWEN_TELEMETRY_OTLP_ENDPOINT | Sets the OTLP endpoint for telemetry. Overrides the | -no example |
QWEN_TELEMETRY_OUTFILE | Sets the file path to write telemetry to. When set, overrides OTLP export. Overrides the | -no example |
QWEN_SANDBOX | Alternative to the Accepts | -no example |
QWEN_SANDBOX_IMAGE | Overrides sandbox image selection for Docker/Podman. Takes precedence over | -no example |
SEATBELT_PROFILE | (macOS specific) Switches the Seatbelt ( default permissive-open Docs: SEATBELT_PROFILE | -no example |
DEBUG | Set to | -no example |
DEBUG_MODE | Set to | -no example |
NO_COLOR | Set to any value to disable all color output in the CLI. Docs: NO_COLOR | -no example |
FORCE_HYPERLINK | Override the OSC 8 clickable-link detection in the markdown renderer. 1 to force-enable; 0 to disable Docs: FORCE_HYPERLINK | -no example |
QWEN_DISABLE_HYPERLINKS | Set to 1 Docs: QWEN_DISABLE_HYPERLINKS | -no example |
CLI_TITLE | Set to a string to customize the title of the CLI. Docs: CLI_TITLE | -no example |
QWEN_CODE_MAX_OUTPUT_TOKENS | Overrides the default maximum output tokens per response; disables automatic escalation. Docs: QWEN_CODE_MAX_OUTPUT_TOKENS | export QWEN_CODE_MAX_OUTPUT_TOKENS=16000 |
QWEN_CODE_UNATTENDED_RETRY | Set to | -no example |
QWEN_CODE_PROFILE_STARTUP | Set to | export QWEN_CODE_PROFILE_STARTUP=1 |
QWEN_CODE_LEGACY_MCP_BLOCKING | Set to | -no example |
QWEN_CODE_MODELS_DEV | Set to off Docs: QWEN_CODE_MODELS_DEV | export QWEN_CODE_MODELS_DEV=off |
QWEN_CODE_MODELS_DEV_REFRESH | Set to off Docs: QWEN_CODE_MODELS_DEV_REFRESH | -no example |
OPENAI_API_KEY | API key for the OpenAI-compatible protocol; the default envKey for | -no example |
OPENAI_BASE_URL | Base URL for the OpenAI-compatible protocol. Docs: OPENAI_BASE_URL | -no example |
OPENAI_MODEL | Model ID for the OpenAI-compatible protocol (alias: QWEN_MODEL). Docs: OPENAI_MODEL | -no example |
QWEN_MODEL | Alias of OPENAI_MODEL for the OpenAI-compatible protocol. Docs: QWEN_MODEL | -no example |
ANTHROPIC_API_KEY | API key for the Anthropic protocol ( | -no example |
ANTHROPIC_BASE_URL | Base URL for the Anthropic protocol. Docs: ANTHROPIC_BASE_URL | -no example |
ANTHROPIC_MODEL | Model ID for the Anthropic protocol. Docs: ANTHROPIC_MODEL | -no example |
GEMINI_API_KEY | API key for the Google GenAI protocol ( | -no example |
GEMINI_MODEL | Model ID for the Google GenAI protocol. Docs: GEMINI_MODEL | -no example |
GOOGLE_API_KEY | API key for Vertex AI; used with GOOGLE_MODEL and sets GOOGLE_GENAI_USE_VERTEXAI=true. Docs: GOOGLE_API_KEY | -no example |
GOOGLE_MODEL | Model ID for Vertex AI entries. Docs: GOOGLE_MODEL | -no example |
GOOGLE_CLOUD_PROJECT | Google Cloud project for keyless Vertex AI access via Application Default Credentials. Docs: GOOGLE_CLOUD_PROJECT | -no example |
DASHSCOPE_API_KEY | Alibaba Cloud DashScope API key, commonly used as the envKey of Qwen model provider entries. Docs: DASHSCOPE_API_KEY | -no example |
QWENCLOUD_API_KEY | API key for QwenCloud used in headless or scripted setup. Docs: QWENCLOUD_API_KEY | export QWENCLOUD_API_KEY="sk-your-api-key" |
BAILIAN_CODING_PLAN_API_KEY | API key for the Alibaba Cloud Coding Plan in headless or scripted setup. Docs: BAILIAN_CODING_PLAN_API_KEY | export BAILIAN_CODING_PLAN_API_KEY="sk-sp-xxxxxxxxx" |
OPENROUTER_API_KEY | OpenRouter API key; used with OPENAI_BASE_URL=https://openrouter.ai/api/v1. Docs: OPENROUTER_API_KEY | -no example |
QWEN_CODE_SYSTEM_SETTINGS_PATH | Overrides the path of the system settings file (highest-precedence settings file). Docs: QWEN_CODE_SYSTEM_SETTINGS_PATH | -no example |
QWEN_CODE_SYSTEM_DEFAULTS_PATH | Overrides the path of the system defaults settings file (lowest-precedence settings file). Docs: QWEN_CODE_SYSTEM_DEFAULTS_PATH | -no example |
QWEN_UPDATE_BASE_URL | Custom HTTPS release root for standalone updates (qwen update, /update, automatic updates). HTTPS URL without credentials, query string or fragment Docs: QWEN_UPDATE_BASE_URL | export QWEN_UPDATE_BASE_URL="https://downloads.example.com/qwen-code" |
QWEN_DISABLED_SLASH_COMMANDS | Denylist of slash commands; unioned with slashCommands.disabled and --disabled-slash-commands. Comma-separated command names Docs: QWEN_DISABLED_SLASH_COMMANDS | -no example |
QWEN_CODE_ENABLE_WORKFLOWS | Set to 1 Docs: QWEN_CODE_ENABLE_WORKFLOWS | -no example |
QWEN_CODE_ENABLE_AGENT_TEAM | Set to 1 Docs: QWEN_CODE_ENABLE_AGENT_TEAM | -no example |
QWEN_CODE_DISABLE_CRON | Set to 1 Docs: QWEN_CODE_DISABLE_CRON | -no example |
QWEN_CODE_API_TIMEOUT_MS | Sets the per-request API timeout in milliseconds; default 120000 Docs: QWEN_CODE_API_TIMEOUT_MS | -no example |
QWEN_STREAM_IDLE_TIMEOUT_MS | Global idle timeout between streamed chunks; default 240000 Docs: QWEN_STREAM_IDLE_TIMEOUT_MS | -no example |
QWEN_CODE_SAFE_MODE | Equivalent of --safe-mode: disables all customizations to isolate problems. true Docs: QWEN_CODE_SAFE_MODE | -no example |
QWEN_CODE_SIMPLE | Equivalent of --bare; among other effects it turns off all hooks. Docs: QWEN_CODE_SIMPLE | -no example |
QWEN_CODE_SUPPRESS_YOLO_WARNING | Set to 1 Docs: QWEN_CODE_SUPPRESS_YOLO_WARNING | -no example |
QWEN_PROJECT_DIR | Set to the project directory in the environment of every command hook. Docs: QWEN_PROJECT_DIR | "$QWEN_PROJECT_DIR/.qwen/hooks/security-check.sh" |
QWEN_CODE_LANG | Highest-priority source for UI language auto-detection. Docs: QWEN_CODE_LANG | -no example |
QWEN_TLS_INSECURE | Set to 1 Docs: QWEN_TLS_INSECURE | -no example |
SANDBOX_FLAGS | Injects custom flags into the docker or podman command for container-based sandboxing. Space-separated flags Docs: SANDBOX_FLAGS | export SANDBOX_FLAGS="--security-opt label=disable" |
SANDBOX_SET_UID_GID | On Linux, forces (true) or disables (false) UID/GID mapping so the sandbox runs as your user. true or false Docs: SANDBOX_SET_UID_GID | export SANDBOX_SET_UID_GID=true |
QWEN_SERVER_TOKEN | Bearer token for qwen serve when --token is not passed. Docs: QWEN_SERVER_TOKEN | QWEN_SERVER_TOKEN=secret qwen serve |
QWEN_CODE_MERMAID_IMAGE_RENDERING | Controls Mermaid image rendering in the terminal markdown renderer. Documented value: 1 Docs: QWEN_CODE_MERMAID_IMAGE_RENDERING | QWEN_CODE_MERMAID_IMAGE_RENDERING=1 |
The rest of the Qwen Code reference
FAQ
How many environment variables does Qwen Code have?
The official Qwen Code docs list 56 environment variables, including QWEN_HOME, QWEN_RUNTIME_DIR and QWEN_USAGE_STATISTICS_ENABLED. All of them are in the table above, in the docs' order.
What does QWEN_HOME do in Qwen Code?
Customizes the global configuration directory (default: ~/.qwen).
Where are Qwen Code environment variables documented?
On 9 official docs pages at qwenlm.github.io, last read on October 17, 2026. Every row in the table links the exact section it came from.
Sources
Last verified . Names and examples are copied verbatim from the 9 official pages below, and every row above links the exact section it came from.
- qwenlm.github.io/qwen-code-docs/en/users/configuration/settings/30 items
- qwenlm.github.io/qwen-code-docs/en/users/configuration/auth/16 items
- qwenlm.github.io/qwen-code-docs/en/users/features/headless/2 items
- qwenlm.github.io/qwen-code-docs/en/users/features/hooks/2 items
- qwenlm.github.io/qwen-code-docs/en/users/features/language/1 item
- qwenlm.github.io/qwen-code-docs/en/users/support/troubleshooting/1 item
- qwenlm.github.io/qwen-code-docs/en/users/features/sandbox/2 items
- qwenlm.github.io/qwen-code-docs/en/users/qwen-serve/1 item
- qwenlm.github.io/qwen-code-docs/en/users/features/markdown-rendering/1 item
Newsletter
Know when your tools change
One email per week. New coding agent releases, the flags and commands they add, and what they mean for how you work.