Skip to main content
Watch: I Built an AI App Without Leaving Databricks

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

Qwen Code environment variables
VariableDescriptionExample
QWEN_HOME

Customizes the global configuration directory (default: ~/.qwen).

Docs: QWEN_HOME
-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 true or 1 to enable usage statistics; any other value disables them.

Overrides the privacy.usageStatisticsEnabled setting.

Docs: QWEN_USAGE_STATISTICS_ENABLED
-no example
QWEN_TELEMETRY_ENABLED

Set to true or 1 to enable telemetry; any other value disables it.

Overrides the telemetry.enabled setting.

Docs: QWEN_TELEMETRY_ENABLED
-no example
QWEN_TELEMETRY_OTLP_ENDPOINT

Sets the OTLP endpoint for telemetry.

Overrides the telemetry.otlpEndpoint setting.

Docs: QWEN_TELEMETRY_OTLP_ENDPOINT
-no example
QWEN_TELEMETRY_OUTFILE

Sets the file path to write telemetry to. When set, overrides OTLP export.

Overrides the telemetry.outfile setting.

Docs: QWEN_TELEMETRY_OUTFILE
-no example
QWEN_SANDBOX

Alternative to the sandbox setting in settings.json; overrides the CLI flag and settings.

Accepts true, false, docker, podman, or a custom command string

Docs: QWEN_SANDBOX
-no example
QWEN_SANDBOX_IMAGE

Overrides sandbox image selection for Docker/Podman.

Takes precedence over tools.sandboxImage

Docs: QWEN_SANDBOX_IMAGE
-no example
SEATBELT_PROFILE

(macOS specific) Switches the Seatbelt (sandbox-exec) profile on macOS.

default permissive-open

Docs: SEATBELT_PROFILE
-no example
DEBUG

Set to true or 1 to enable verbose debug logging; excluded from project .env files by default.

Docs: DEBUG
-no example
DEBUG_MODE

Set to true or 1 to enable verbose debug logging; excluded from project .env files by default.

Docs: DEBUG_MODE
-no example
NO_COLOR

Set to any value to disable all color output in the CLI.

Docs: NO_COLOR
-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 true or 1 to retry transient 429/529 capacity errors indefinitely with backoff.

Docs: QWEN_CODE_UNATTENDED_RETRY
-no example
QWEN_CODE_PROFILE_STARTUP

Set to 1 to write a JSON startup timing report to ~/.qwen/startup-perf/.

Docs: QWEN_CODE_PROFILE_STARTUP
export QWEN_CODE_PROFILE_STARTUP=1
QWEN_CODE_LEGACY_MCP_BLOCKING

Set to 1 to wait synchronously for every MCP server's discover handshake at startup.

Docs: QWEN_CODE_LEGACY_MCP_BLOCKING
-no example
QWEN_CODE_MODELS_DEV

Set to off to ignore the bundled models.dev model catalog.

off

Docs: QWEN_CODE_MODELS_DEV
export QWEN_CODE_MODELS_DEV=off
QWEN_CODE_MODELS_DEV_REFRESH

Set to off to stop the daily models.dev download into ~/.qwen/model-registry.json.

off

Docs: QWEN_CODE_MODELS_DEV_REFRESH
-no example
OPENAI_API_KEY

API key for the OpenAI-compatible protocol; the default envKey for openai entries.

Docs: OPENAI_API_KEY
-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 (modelProviders key anthropic).

Docs: ANTHROPIC_API_KEY
-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 (modelProviders key gemini).

Docs: GEMINI_API_KEY
-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 to force the Workflow tool on (overrides tools.workflowsEnabled).

1

Docs: QWEN_CODE_ENABLE_WORKFLOWS
-no example
QWEN_CODE_ENABLE_AGENT_TEAM

Set to 1 to enable agent-team collaboration tools (same as experimental.agentTeam).

1

Docs: QWEN_CODE_ENABLE_AGENT_TEAM
-no example
QWEN_CODE_DISABLE_CRON

Set to 1 to disable the in-session cron/loop tools (experimental.cron).

1

Docs: QWEN_CODE_DISABLE_CRON
-no example
QWEN_CODE_API_TIMEOUT_MS

Sets the per-request API timeout in milliseconds; 0 disables the request timeout.

default 120000

Docs: QWEN_CODE_API_TIMEOUT_MS
-no example
QWEN_STREAM_IDLE_TIMEOUT_MS

Global idle timeout between streamed chunks; 0 disables the idle guard.

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 to suppress the stderr warning when --yolo runs headless without a sandbox.

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 to skip TLS certificate verification (same as --insecure).

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.

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.