AI News

Qwen 3.8 Max API Guide: Claude Code, Codex, OpenCode and More

The short version: the production Qwen 3.8 Max API is real, available through QwenCloud and regional Alibaba Model Studio endpoints, and compatible with both OpenAI-style and Anthropic-style clients. But it is not interchangeable with qwen3.8-max-preview, and “OpenAI-compatible” does not mean every OpenAI parameter behaves identically. The safest production default is the exact model ID qwen3.8-max, a region-matched endpoint, environment-based credentials and an explicit reasoning policy.

This guide was verified against current primary sources at 17:23 PDT on August 3, 2026. Only one route was live-tested through an existing authenticated account: the ChatLLM web app returned the requested canary response from its Qwen 3.8 Max model. QwenCloud, Alibaba Model Studio and OpenRouter availability are catalog- or documentation-verified because no authenticated API key was already available. Nebius did not list a matching public endpoint. That distinction matters: a vendor page proves listing, not that your key, region or subscription is ready.

If you want the architecture, specifications and Qwen-versus-Kimi-versus-DeepSeek analysis, read Kingy’s separate Qwen 3.8 Max evidence-led comparison. This article stays focused on API work.

Production and preview are different routes

Use these names literally:

Model ID Lifecycle Reasoning behavior Production recommendation
qwen3.8-max Production Hybrid thinking: reasoning can be enabled, constrained or disabled Use this for new production integrations
qwen3.8-max-preview Preview Thinking is always enabled and cannot be disabled Use only when you deliberately accept preview behavior and change risk

The difference is operational, not cosmetic. A request that works against the preview may produce a different latency and token bill after changing only the model name. Preview is also a separate deployment target, not a fallback alias for production. Pin the complete ID in configuration and record it in telemetry.

Qwen’s current Chat Completions reference supports reasoning_effort values low, medium and xhigh. The documented token-budget mappings are 4,096, 16,384 and 262,144 respectively. If neither reasoning_effort nor thinking_budget is supplied, the documented default thinking budget is 131,072 tokens. OpenAI-style aliases are accepted: minimal maps to low, high and max map to xhigh, and none disables reasoning on the production model.

Do not send both reasoning_effort and thinking_budget. For a production application, choose one policy and test its cost and latency on your workload.

Where the Qwen 3.8 Max API is actually available

Provider Production availability What we verified Exact identifier or route
QwenCloud Yes First-party model page and API references qwen3.8-max; international OpenAI base https://dashscope-intl.aliyuncs.com/compatible-mode/v1
Alibaba Model Studio Yes First-party catalog in Beijing, Singapore, Tokyo, Frankfurt and Virginia qwen3.8-max; regional workspace host required
OpenRouter Yes Exact entry in the public models API; no authenticated generation test qwen/qwen3.8-max; https://openrouter.ai/api/v1
ChatLLM Yes in the signed-in web app Live-tested: selected Qwen 3.8 Max and received exact canary QWEN38_OK Web app model; no current RouteLLM API ID was documented
Nebius Token Factory No public endpoint found Public catalog search for “Qwen 3.8” returned no endpoint; no authenticated session Do not invent a Nebius model ID

Two nuances prevent expensive mistakes.

First, QwenCloud and Alibaba Model Studio are two surfaces on Alibaba’s DashScope/MaaS stack, not independent inference providers. QwenCloud gives international-facing documentation and Token Plan routes; Model Studio exposes workspace- and region-scoped deployments. A key created for one region is not a universal credential.

Second, ChatLLM access does not prove RouteLLM API access. The signed-in ChatLLM interface worked in our test, but Abacus’s current public RouteLLM catalog did not document an exact Qwen 3.8 Max API ID. Until it does, use ChatLLM as a verified user-interface route—not a guessed OpenAI-compatible endpoint.

Choose the right QwenCloud or Model Studio endpoint

For the international QwenCloud pay-as-you-go OpenAI-compatible API:

https://dashscope-intl.aliyuncs.com/compatible-mode/v1

For a QwenCloud Token Plan in the Singapore service:

https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1

Regional Alibaba Model Studio OpenAI-compatible bases are:

Region Base URL
Beijing https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1
Singapore https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1
Tokyo https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/compatible-mode/v1
Frankfurt https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1
Virginia https://dashscope-us.aliyuncs.com/compatible-mode/v1

Replace {WorkspaceId} with the workspace identifier shown by Model Studio. The Anthropic-compatible base uses the same regional host with /apps/anthropic; the native DashScope base ends in /api/v1.

Region choice controls more than latency. Alibaba’s region guide defines Beijing as the China-mainland service. Singapore is an international service that excludes China. Virginia deployments may be Global or US-only where a model-specific -us variant is offered. Frankfurt serves EU/global use cases, and Tokyo serves Japan/global use cases. Confirm the model list, deployment scope and data terms for the exact region before handling regulated data.

Qwen 3.8 Max API quick start with cURL

Store the credential outside source control:

export DASHSCOPE_API_KEY='replace-with-your-key'
export QWEN_BASE_URL='https://dashscope-intl.aliyuncs.com/compatible-mode/v1'

Then call Chat Completions with production qwen3.8-max:

curl --fail-with-body --silent --show-error \
  "$QWEN_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
    "model": "qwen3.8-max",
    "messages": [
      {"role": "system", "content": "Answer concisely and cite uncertainty."},
      {"role": "user", "content": "Explain idempotency in one paragraph."}
    ],
    "reasoning_effort": "low",
    "max_completion_tokens": 1200
  }'

Use max_completion_tokens, not the deprecated max_tokens: the new field covers both reasoning and visible answer tokens. Start at low reasoning for routine transformations, then move to medium or xhigh only when evaluation results justify it.

To disable reasoning on production:

curl --fail-with-body --silent --show-error \
  "$QWEN_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
    "model": "qwen3.8-max",
    "messages": [{"role": "user", "content": "Return only the ISO country code for Canada."}],
    "reasoning_effort": "none",
    "max_completion_tokens": 32
  }'

That same request is invalid as a “no thinking” guarantee against qwen3.8-max-preview, because preview reasoning cannot be disabled.

Python with the OpenAI SDK

Install a current SDK in an isolated environment, then read the key from the environment:

python -m pip install --upgrade openai
import os
from openai import OpenAI

api_key = os.environ.get("DASHSCOPE_API_KEY")
if not api_key:
    raise RuntimeError("Set DASHSCOPE_API_KEY; never commit API keys")

client = OpenAI(
    api_key=api_key,
    base_url=os.environ.get(
        "QWEN_BASE_URL",
        "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
    ),
    timeout=60.0,
    max_retries=2,
)

response = client.chat.completions.create(
    model="qwen3.8-max",
    messages=[
        {"role": "system", "content": "Be precise. Say when evidence is missing."},
        {"role": "user", "content": "List three properties of an idempotent API."},
    ],
    extra_body={"reasoning_effort": "low"},
    max_completion_tokens=800,
)

print(response.choices[0].message.content)

This is documentation-derived, not a live test from Kingy’s environment. In production, also log the provider request ID, latency, HTTP status, model ID and token usage—but never the bearer token or unredacted sensitive prompts.

Chat Completions, Responses or Anthropic Messages?

Qwen exposes three useful wire formats:

Interface Best for Important detail
OpenAI Chat Completions Broad client compatibility, multimodal messages and explicit function loops Endpoint /chat/completions; tool calls are returned for your code to execute
OpenAI Responses Stateful continuation and Qwen-hosted tools Endpoint /responses; previous_response_id is valid for seven days
Anthropic Messages Claude Code and clients built around Anthropic semantics Base ends /apps/anthropic; messages endpoint adds /v1/messages

A minimal Responses call is:

response = client.responses.create(
    model="qwen3.8-max",
    input="Propose a five-item API migration checklist.",
    reasoning={"effort": "medium"},
    max_output_tokens=1200,
)
print(response.output_text)

For a follow-up, pass the returned ID:

follow_up = client.responses.create(
    model="qwen3.8-max",
    previous_response_id=response.id,
    input="Condense that to the three highest-risk checks.",
)
print(follow_up.output_text)

That convenience has a data-governance consequence: Qwen documents a seven-day validity period for previous_response_id. Treat it as provider-side state and do not use it for sensitive conversations until your retention requirements and contract allow it.

Reasoning without surprise bills

Three settings deserve deliberate tests:

  1. Effort: low, medium and xhigh can create materially different hidden-token usage and latency.
  2. Thinking history: preserve_thinking defaults to true for both production and preview. When resending an assistant turn, keep prior reasoning in the dedicated reasoning_content field; do not concatenate it into visible content. Resent reasoning is billed as input.
  3. Temperature: Qwen recommends the model’s thinking-mode default rather than pushing it below 0.6. Low temperature is not a substitute for disabling reasoning.

For multi-turn agents, persist only the state you need. A compact, application-owned summary is often cheaper and easier to audit than replaying an entire reasoning trace.

Tool calling: let the model request, never execute blindly

The Chat API supports function tools, tool_choice and parallel tool calls. Thinking mode does not support forcing one specific tool. The model proposes a call; your application must validate and execute it.

import json

tools = [{
    "type": "function",
    "function": {
        "name": "get_order_status",
        "description": "Read the status of an order owned by the signed-in user.",
        "parameters": {
            "type": "object",
            "properties": {
                "order_id": {"type": "string", "pattern": "^[A-Z0-9-]{6,24}$"}
            },
            "required": ["order_id"],
            "additionalProperties": False,
        },
    },
}]

first = client.chat.completions.create(
    model="qwen3.8-max",
    messages=[{"role": "user", "content": "Where is order AB12-CD34?"}],
    tools=tools,
    tool_choice="auto",
    extra_body={"reasoning_effort": "low"},
)

message = first.choices[0].message
for call in message.tool_calls or []:
    if call.function.name != "get_order_status":
        raise ValueError("Tool is not allowlisted")
    args = json.loads(call.function.arguments)
    order_id = args.get("order_id", "")
    if not (6 <= len(order_id) <= 24 and all(c.isalnum() or c == "-" for c in order_id)):
        raise ValueError("Invalid order_id")
    # Authorize this order against the signed-in user before any database lookup.

Do not expose a general shell, raw SQL or arbitrary URL fetcher. Validate the schema again server-side, apply user authorization and idempotency controls, and require confirmation before any destructive action.

The Responses API also documents Qwen-hosted tools including web search, web extraction, code interpreter, image search, file search and MCP. Those are not the same as local function calls: provider-hosted execution changes trust boundaries, data flows and cost. Enable only the capabilities required by the product.

Caching: three mechanisms, one documentation discrepancy

Qwen’s context-cache guide documents:

  • Implicit caching: automatic and not disableable. General guidance says a hit is 20% of normal input price and usually requires at least 256 reusable tokens.
  • Explicit caching: mark up to four reusable prompt blocks with cache_control: {"type":"ephemeral"}. Minimum 1,024 tokens; five-minute time-to-live.
  • Responses session cache: send the header x-dashscope-session-cache: enable. It uses a five-minute lifetime and a 1,024-token minimum.

The production model page currently gives exact Qwen 3.8 Max rates of $0.25 per million implicit-cached input tokens, $2.50 per million explicit-cache creation tokens and $0.17 per million explicit-cache-read tokens. Those figures do not perfectly match the generic percentage examples in the caching guide. Use the model page’s dollar prices for budgets, then verify a small billed request before committing to a cost model.

Pricing and rate limits

QwenCloud’s production model page lists:

Meter Price per million tokens
Uncached input $2.00
Output, including reasoning tokens $6.00
Implicit cached input $0.25
Explicit cache creation $2.50
Explicit cache read $0.17

OpenRouter’s catalog listed the same $2 input and $6 output headline rates at the evidence cutoff, plus $0.25 cache reads and $2.50 cache writes. OpenRouter can add routing choices and its own accounting, so check the live model page and provider selection before treating prices as identical.

QwenCloud also displayed 15,000 requests per minute and 2,000,000 tokens per minute for the model. These are not promises that every new key receives those ceilings. Qwen’s rate-limit guide says quotas are shared across an Alibaba Cloud account and its workspaces, custom workspace limits can be lower, and per-second RPS/TPS enforcement can return HTTP 429 even when the minute counter appears healthy.

For realistic budgets, put your prompt length, cache hit rate, reasoning usage and output length into the Kingy AI Workload Cost Calculator. Reasoning tokens belong in output cost.

Multimodal support—and where not to assume parity

Qwen’s production model page lists text, image and video input with text output. OpenRouter’s catalog describes the same input modalities. Qwen’s Claude Code, Codex, OpenCode and OpenClaw integration metadata generally advertises text and image input.

But interface parity is incomplete. The Qwen Responses reference currently documents text and message-array input; it does not document a video-input schema. Use the Chat/DashScope multimodal examples for images and video, and validate file limits and formats on the exact endpoint. Do not infer that a video request accepted by native DashScope will work unchanged in Responses, Anthropic Messages or a third-party coding client.

Claude Code setup

QwenCloud’s Claude Code guide officially documents production qwen3.8-max for Token Plan Personal and Team editions through its Anthropic-compatible service. In ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_TOKEN_PLAN_KEY",
    "ANTHROPIC_BASE_URL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
    "ANTHROPIC_MODEL": "qwen3.8-max",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-max",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8-max",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "983616"
  }
}

The literal key is shown because Claude Code’s documented file-based configuration requires it; lock down file permissions and never commit the file. Better still, inject the value from an OS secret manager in environments where Claude Code supports that workflow. Qwen’s pay-as-you-go examples may not list the same production models as Token Plan, so do not mix plan-specific base URLs.

Codex setup

QwenCloud’s current Codex guide uses the Responses API and a local model catalog. In ~/.codex/config.toml:

model_catalog_json = "~/.codex/model-catalog.local.json"
model_provider = "Model_Studio_Token_Plan_Personal"
model = "qwen3.8-max"

[model_providers.Model_Studio_Token_Plan_Personal]
name = "Model_Studio_Token_Plan_Personal"
base_url = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"

Export the dedicated Token Plan key as OPENAI_API_KEY; do not place it in TOML. The accompanying model catalog entry should use slug qwen3.8-max, context window 983616, text and image input modalities, and documented reasoning levels low, medium and xhigh. Follow the official QwenCloud Codex guide for the complete catalog schema, which can change as Codex evolves.

The minimum production-only ~/.codex/model-catalog.local.json is:

{
  "models": [{
    "slug": "qwen3.8-max",
    "display_name": "qwen3.8-max",
    "description": "DashScope model: qwen3.8-max",
    "default_reasoning_level": "xhigh",
    "supported_reasoning_levels": [
      {"effort": "low", "description": "Fast responses with lighter reasoning"},
      {"effort": "medium", "description": "Greater reasoning depth for complex problems"},
      {"effort": "xhigh", "description": "Extra high reasoning depth for complex problems"}
    ],
    "context_window": 983616,
    "effective_context_window_percent": 95,
    "supports_parallel_tool_calls": false,
    "supports_image_detail_original": true,
    "input_modalities": ["text", "image"],
    "shell_type": "default",
    "visibility": "list",
    "supported_in_api": true,
    "priority": 1,
    "base_instructions": "",
    "support_verbosity": false,
    "supports_reasoning_summaries": false,
    "experimental_supported_tools": [],
    "truncation_policy": {"mode": "bytes", "limit": 10000}
  }]
}

Qwen Code setup

Qwen Code offers interactive /auth configuration or ~/.qwen/settings.json. Its current QwenCloud integration guide lists both production and preview for Token Plan Personal. A minimal production provider entry is:

{
  "env": {
    "BAILIAN_TOKEN_PLAN_API_KEY": "YOUR_TOKEN_PLAN_KEY"
  },
  "modelProviders": {
    "openai": [{
      "id": "qwen3.8-max",
      "name": "[Token Plan Personal] qwen3.8-max",
      "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
      "envKey": "BAILIAN_TOKEN_PLAN_API_KEY",
      "generationConfig": {
        "extra_body": {"enable_thinking": true}
      }
    }]
  }
}

Use the /model command to confirm that the active identifier is production qwen3.8-max before an agent edits a repository.

OpenCode setup

QwenCloud’s OpenCode guide documents OpenCode through its Anthropic-compatible provider. In ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "model-studio-token-plan": {
      "npm": "@ai-sdk/anthropic",
      "name": "Model Studio Token Plan",
      "options": {
        "baseURL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1",
        "apiKey": "YOUR_TOKEN_PLAN_KEY"
      },
      "models": {
        "qwen3.8-max": {
          "name": "Qwen 3.8 Max",
          "reasoning": true,
          "limit": {"context": 983616, "output": 131072}
        }
      }
    }
  },
  "model": "model-studio-token-plan/qwen3.8-max"
}

This official configuration places a key in JSON. Keep the file out of backups and repositories, restrict its permissions, and prefer environment substitution if the installed OpenCode version supports it.

OpenClaw setup

QwenCloud’s current OpenClaw guide lists production qwen3.8-max for Token Plan and configures it under a bailian-token-plan provider. A focused production-only merge for ~/.openclaw/openclaw.json is:

{
  "models": {
    "mode": "merge",
    "providers": {
      "bailian-token-plan": {
        "baseUrl": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
        "apiKey": "YOUR_TOKEN_PLAN_KEY",
        "api": "anthropic-messages",
        "models": [{
          "id": "qwen3.8-max",
          "name": "qwen3.8-max",
          "reasoning": true,
          "input": ["text", "image"],
          "contextWindow": 983616,
          "maxTokens": 131072,
          "cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0},
          "compat": {"thinkingFormat": "openai"}
        }]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {"primary": "bailian-token-plan/qwen3.8-max"},
      "models": {"bailian-token-plan/qwen3.8-max": {}}
    }
  }
}

The zero cost fields reflect the Token Plan accounting example; they are not a claim that usage is free. Merge the object into the existing file—do not overwrite channels or security settings. Keep the credential out of source control and use environment substitution if your installed version supports it. Qwen’s example warns that auth.mode: none is suitable only for a single-machine local gateway. For shared or remote use, run OpenClaw’s security repair flow and require token authentication.

Privacy, retention and credential safety

QwenCloud documents TLS 1.2+ in transit and AES-256 at rest for account and key data. Alibaba’s Model Studio privacy notice says customer data is not used to train its models. Those statements are meaningful, but neither is a universal zero-retention guarantee for every API payload, hosted tool, log and region. Qwen’s seven-day previous_response_id period is explicit evidence that some Responses state persists.

For sensitive workloads:

  • choose a region and deployment scope deliberately;
  • confirm the current DPA, retention controls, subprocessors and abuse-monitoring terms with Alibaba;
  • disable unnecessary hosted tools and conversation state;
  • redact secrets and personal data before prompting;
  • use separate development and production keys, minimum privilege, rotation and spend limits;
  • log request IDs and usage, not raw credentials or unredacted prompts.

OpenRouter’s privacy documentation says it does not store prompts and responses unless users opt in, while request metadata is retained. Downstream inference providers can have different policies. Use per-request provider: {"zdr": true} routing where applicable, then verify which endpoints remain eligible rather than assuming every route is zero-data-retention.

Troubleshooting the Qwen 3.8 Max API

Symptom Likely cause What to check
HTTP 401 Wrong key type, missing bearer header or key from another service/region Match the key to pay-as-you-go, Token Plan or regional workspace; never reuse a ChatLLM credential
HTTP 404 or model not found Wrong base URL, region or model ID Confirm qwen3.8-max, not qwen/qwen3.8-max except on OpenRouter; verify regional catalog
HTTP 429 despite low minute usage Per-second burst limit or shared account/workspace quota Add exponential backoff with jitter; cap concurrency; inspect RPS/TPS and sibling workspaces
Unexpectedly high token bill Default/high reasoning, replayed thinking history or cache miss Log usage; set effort explicitly; trim reasoning_content; verify stable cache prefixes
max_tokens behaves strangely Deprecated field does not represent total thinking plus answer budget Use max_completion_tokens in Chat or max_output_tokens in Responses
Tool is not forced Thinking mode does not support forcing a specific function tool Use tool_choice: "auto", disable thinking when appropriate, or validate the control flow in your app
Multi-turn answer loses context Reasoning history was merged into content, dropped, or malformed Preserve historical thinking in reasoning_content; keep roles and tool-call IDs intact
Cache never hits Prefix changed, prompt too short or five-minute TTL expired Keep reusable blocks byte-stable; meet 256/1,024-token thresholds; measure billed cache fields
Video input fails The chosen compatibility layer does not document video parity Use a documented Chat/DashScope multimodal route and validate supported format/size
Claude Code or OpenCode cannot connect Anthropic base path is missing or duplicated Claude base ends /apps/anthropic; OpenCode’s documented base ends /apps/anthropic/v1
Codex returns schema/config errors Missing local catalog metadata or wrong wire API Use wire_api = "responses" and the current Qwen Codex catalog schema
ChatLLM works but RouteLLM does not Web-app availability was mistaken for API availability Wait for an exact first-party RouteLLM model ID; do not guess one
Nebius route cannot be found No matching public Token Factory endpoint was listed at cutoff Recheck the official catalog later; do not substitute a similarly named Qwen model

Which route should you choose?

  • Choose QwenCloud pay-as-you-go for a direct international OpenAI-compatible integration and model-specific metering.
  • Choose Model Studio regional endpoints when data location, workspace isolation or Alibaba Cloud deployment controls drive the architecture.
  • Choose QwenCloud Token Plan when its included coding-tool integrations and billing model fit your team.
  • Choose OpenRouter when multi-provider routing and unified billing are worth an additional data-policy and routing layer.
  • Choose ChatLLM for interactive access today; do not claim a RouteLLM API until Abacus publishes an exact Qwen 3.8 model ID.
  • Do not design around Nebius Token Factory unless a current endpoint appears in its first-party catalog.

The production checklist is simple: pin qwen3.8-max; pin the complete regional base URL; keep keys outside code; set reasoning explicitly; bound total output; validate tools; measure cache hits, latency and billed tokens; and record the evidence date. Re-run that checklist before any provider, plan or region migration.

Editorial disclosure: Kingy.ai did not run a QwenCloud, Model Studio, OpenRouter or Nebius generation request because no authenticated API route for those services was already available in the working environment. The ChatLLM web-app canary was live-tested. All other availability and behavior statements above are catalog- or documentation-derived from the linked first-party sources.