QwenCloud's official OpenCode documentation sets a default per-response output limit of 32,000 tokens for the GA model qwen4-max (not qwen4-max-preview). To request longer responses, set OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX when launching OpenCode and set the client-side limit.output in the OpenCode model definition within the model's allowed range.
Suitable tasks: Connecting QwenCloud Token Plan to OpenCode and generating long-form text or longer code outputs
Unsuitable tasks: Mistaking the OpenCode client-side limit for the model service's generation limit, or mixing the Individual Token Plan endpoint with keys from other billing plans
Applicable model version: GA model qwen4-max; excludes qwen4-max-preview
Applicable client, agent, or API: OpenCode and the QwenCloud Token Plan Individual Anthropic-compatible endpoint
Recommended reasoning tier and parameters: Official defaults are reasoning_effort=high and thinking_budget=131072; this article does not cover additional reasoning parameters
Save the following configuration to ~/.config/opencode/opencode.json on macOS/Linux (Windows: %USERPROFILE%\.config\opencode\opencode.json). It reads the API key through OpenCode's environment-variable substitution, so the key is not written to the file:
{
"$schema": "https://opencode.ai/config.json",
"model": "qwencloud-token-plan-personal/qwen4-max",
"provider": {
"qwencloud-token-plan-personal": {
"npm": "@ai-sdk/anthropic",
"name": "QwenCloud Token Plan Individual",
"options": {
"baseURL": "https://token-plan.maas.qwencloudapi.com/apps/anthropic/v1",
"apiKey": "{env:QWENCLOUD_API_KEY}"
},
"models": {
"qwen4-max": {
"name": "Qwen4 Max",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"limit": {
"context": 1000000,
"output": 262144
}
}
}
}
}
}Securely set the Individual Token Plan API key in the current terminal, then launch OpenCode with a client-side limit of 262,144 tokens:
read -s QWENCLOUD_API_KEY
export QWENCLOUD_API_KEY
OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX=262144 opencodeAfter OpenCode starts, run /models and select Qwen4 Max under QwenCloud Token Plan Individual. Use the following command to make a test request:
OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX=262144 opencode run "用简明中文解释缓存,并列出三个常见失效场景。"limit.output declares the model's output limit in the OpenCode configuration. OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX overrides the 32,000-token default per-response limit described in the OpenCode documentation. Neither can exceed the model service's limit.
Create or view an API key for QwenCloud Token Plan Individual; do not substitute a key from the pay-as-you-go or Team plan.
Save the configuration to the user-level opencode.json, then securely set QWENCLOUD_API_KEY in the current shell.
Launch OpenCode with OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX=262144 opencode, run /models, and select Qwen4 Max.
Make a short request containing only non-sensitive content and confirm the connection succeeds. A long output limit sets the maximum allowed for a request; it does not require the model to generate that many tokens every time.
QwenCloud's OpenCode documentation gives the Individual configuration's provider ID qwencloud-token-plan-personal, @ai-sdk/anthropic, and the Anthropic-compatible endpoint https://token-plan.maas.qwencloudapi.com/apps/anthropic/v1, and lists qwen4-max.
The same page states that the GA qwen4-max has a default per-response output limit of 32,000 tokens; setting OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX allows longer outputs.
The same page lists a context window of 1,000,000 tokens and a maximum output of 131,072 tokens in non-thinking mode; thinking content and the final answer together can total up to 262,144 tokens. Defaults are reasoning_effort=high and thinking_budget=131072.
The OpenCode configuration example on the same page gives limit.output=262144 in the qwen4-max model metadata. The OpenCode configuration documentation says model uses the provider/model format and supports environment-variable references in the form {env:VARIABLE_NAME}.
This configuration uses the QwenCloud Token Plan Individual endpoint and key. For Team and pay-as-you-go configurations, use the corresponding provider, endpoint, and key specified in their respective official documentation.
limit.output=262144 defines the client-side model limit; changing it alone does not remove the 32,000-token default per-response limit stated in QwenCloud's documentation. The environment variable also cannot raise the server-side model limit.
The server-side limit in non-thinking mode is 131,072 tokens; the combined limit for thinking content and the final answer is 262,144 tokens. Actual available output for a request is also constrained by input length and server-side rules.
The environment variable name includes EXPERIMENTAL and is the OpenCode configuration method documented by QwenCloud. This article did not make an online request with a real key; confirm account plan, quota, and service availability in the QwenCloud account.
On 2026-11-17, the QwenCloud integration documentation was checked through Tabbit, along with OpenCode's configuration path, provider/model format, and environment-variable syntax. The example uses the Individual Token Plan and was not tested with a real API key. OpenCode configuration documentation
Qwen4-Max