How to Use the Qwen4-35B-A3B API: Keys, Base URLs, Thinking Mode and Tool Calls
To use the Qwen4-35B-A3B API, create a pay-as-you-go key on Qwen Cloud, point any OpenAI SDK at https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1, and send model: "qwen4-35b-a3b". The same key also works with the Anthropic-compatible endpoint.
What is the Qwen4-35B-A3B API?
The Qwen4-35B-A3B API is Alibaba’s hosted endpoint for its first open-weight Qwen4 model, served on Qwen Cloud under the id qwen4-35b-a3b. It takes text, images and video, returns text, and supports thinking mode, streaming, function calling, JSON output and context caching through OpenAI, Anthropic and DashScope protocols.
New to the model itself? Start with what Qwen4-35B-A3B is. Here’s what the Qwen Cloud docs page and the model page listed when I checked them on December 4, 2026:
| Item | Value |
|---|---|
| Model id | qwen4-35b-a3b |
| Inputs / output | Text, image, video / text |
| Context window | 1,000,000 tokens |
| Max input | 991K (983K in thinking mode) |
| Max output | 128K (256K in thinking mode) |
| Price, Singapore | $0.06 input, $0.36 output per 1M tokens |
| Cached input | $0.003 per 1M tokens |
| Rate limit shown | 5,000,000 tokens per minute |
How to get a Qwen Cloud API key
Keys belong to a region and a workspace. A key from one region can’t call another region’s endpoint, so pick the region first.
- Sign in to Qwen Cloud and choose a region with the selector in the top-right corner of the console.
- Open the API Keys page and pick a workspace from the switcher at the bottom of the sidebar.
- Click Create API key, add a description, then click Generate Key. Pay-as-you-go keys start with
sk-ws-. - Export it as
DASHSCOPE_API_KEY, the variable name every Qwen Cloud sample reads.
export DASHSCOPE_API_KEY="sk-ws-..."
Don’t confuse it with a Token Plan key: that subscription has its own key and endpoint, token-plan.maas.qwencloudapi.com.
Qwen4-35B-A3B API base URLs by region
Every pay-as-you-go endpoint follows the pattern {region}.maas.qwencloudapi.com, and the docs list six regions in total. You then add the path for the protocol you want.
| Region | Region ID | Base domain |
|---|---|---|
| Singapore | ap-southeast-1 |
ap-southeast-1.maas.qwencloudapi.com |
| Germany (Frankfurt) | eu-central-1 |
eu-central-1.maas.qwencloudapi.com |
| Japan (Tokyo) | ap-northeast-1 |
ap-northeast-1.maas.qwencloudapi.com |
| US (Virginia) | us-east-1 |
us-east-1.maas.qwencloudapi.com |
| Protocol | Path to append |
|---|---|
| OpenAI Chat Completions and Responses | /compatible-mode/v1 |
| Anthropic Messages | /apps/anthropic |
| DashScope HTTP | /api/v1 |
Prices vary slightly by region. Frankfurt, Tokyo and US Virginia were $0.057 input and $0.339 output per 1M tokens, a bit under Singapore. Those three regions have fixed limits of 30,000 requests and 5,000,000 tokens per minute. In Singapore, your TPM tier depends on your monthly spend, per the regions guide.
Make your first Qwen4-35B-A3B API call
The quickest test is a curl call to Chat Completions:
curl https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen4-35b-a3b",
"messages": [{"role": "user", "content": "Explain MoE routing in two sentences."}],
"enable_thinking": false
}'
In Python, the official openai package works unchanged:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1",
)
resp = client.chat.completions.create(
model="qwen4-35b-a3b",
messages=[{"role": "user", "content": "Summarize this changelog."}],
extra_body={"enable_thinking": False},
)
print(resp.choices[0].message.content)
print(resp.usage)
Over raw HTTP, Qwen-specific fields like enable_thinking go at the top level of the body; in the OpenAI SDK, they go inside extra_body. The Responses API works on the same base URL and adds built-in tools such as web_search and code_interpreter.
Use the Anthropic-compatible endpoint
If your stack already speaks the Anthropic Messages format, swap the base URL and keep your code. Qwen Cloud accepts the key in either an x-api-key header or an Authorization: Bearer header.
curl https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic/v1/messages \
-H "x-api-key: $DASHSCOPE_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model": "qwen4-35b-a3b", "max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello"}]}'
Agent tools that read ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN work the same way.
Control thinking with enable_thinking and reasoning_effort
Qwen4-35B-A3B is a hybrid model: it thinks by default, and you can switch thinking off per request. The thinking tokens come back in reasoning_content (Chat Completions) or as reasoning items (Responses).
| Setting | What it does |
|---|---|
enable_thinking: false |
Skips thinking for fast, cheap answers |
reasoning_effort |
xhigh, high (default), low or off, per the model card
|
preserve_thinking |
On by default; send earlier reasoning_content back in multi-turn chats |
The Qwen Cloud docs confirm enable_thinking for this model. They list reasoning_effort levels for Qwen4-Max but not yet for qwen4-35b-a3b, so test it with your own key before you depend on it.
Qwen’s recommended sampling is temperature=1.0, top_p=0.95 with thinking and temperature=0.7, top_p=0.80, presence_penalty=1.5 without. The card also warns that low effort can slow down agent tasks overall, because thin analysis leads to more retries.
Streaming, image and video input
Set stream: true to get tokens as they’re generated, and add stream_options: {"include_usage": true} to get a final usage chunk. Images and video use the standard OpenAI content parts:
messages = [{
"role": "user",
"content": [
{"type": "video_url", "video_url": {"url": "https://example.com/demo.mp4"}, "fps": 2},
{"type": "text", "text": "List every step shown in this video."},
],
}]
stream = client.chat.completions.create(
model="qwen4-35b-a3b", messages=messages, stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
Use an image_url part for images. fps sets how many frames per second the model samples.
Tool calls with the Qwen4-35B-A3B API
Function calling follows the OpenAI tools format. parallel_tool_calls defaults to true, so loop over every call the model returns, not just the first.
tools = [{"type": "function", "function": {
"name": "get_order",
"description": "Look up an order by id",
"parameters": {"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"]}}}]
resp = client.chat.completions.create(
model="qwen4-35b-a3b", tools=tools,
messages=[{"role": "user", "content": "Where is order A-1042?"}],
)
for call in resp.choices[0].message.tool_calls or []:
print(call.function.name, call.function.arguments)
Append each result as a role: "tool" message with the matching tool_call_id, then call again for the final answer. See the function calling guide.
Qwen4-35B-A3B API pricing and limits
At $0.06 in and $0.36 out per 1M tokens, a call with 20,000 input tokens and 2,000 output tokens costs about $0.0019. Thinking tokens bill as output, so enable_thinking: false is the simplest way to save money.
- Caching: implicit cache hits cost $0.003 per 1M. Explicit cache creation costs $0.075 (5 minutes) or $0.12 (1 hour) in Singapore.
- Batch: file-based Batch inference in Singapore costs 50% of real-time rates, with a 256K-token limit per request.
- Free quota: the model page showed a “1M tokens remaining” free quota panel, but the docs page says this model doesn’t include a free quota. Check your console before you count on it. For $0 routes, see how to use Qwen4-35B-A3B for free.
Self-hosted alternative: your own OpenAI-compatible endpoint
The weights are Apache 2.0, so you can serve the same API yourself. The vLLM recipe starts the FP8 build with Qwen4 parsers for reasoning and tools (trimmed here):
vllm serve Qwen/Qwen4-35B-A3B-FP8 --trust-remote-code --max-model-len auto \
--enable-auto-tool-choice --tool-call-parser qwen4 --reasoning-parser qwen4
Point the same client at http://localhost:8000/v1 with model Qwen/Qwen4-35B-A3B. Locally, reasoning_effort and preserve_thinking go in extra_body.chat_template_kwargs. For llama.cpp, Ollama and GPU sizing, see how to run Qwen4-35B-A3B locally.
Let your coding agent test the Qwen4-35B-A3B API with Apidog CLI
Region mix-ups are the classic failure here: a Singapore key sent to the Virginia endpoint, or an Anthropic path on the OpenAI base URL. Your coding agent can catch them first with Apidog CLI.
Set it up once:
npm install -g apidog-cli@latest
apidog login --with-token <YOUR_TOKEN>
Or tell the agent: “Read https://apidog.com/apidog-cli-installation-guide.md and set up Apidog CLI.” Then give Claude Code, Codex or OpenCode one prompt:
In Apidog project <PROJECT_ID>, create a test scenario called "Qwen4-35B-A3B API route check".
POST a qwen4-35b-a3b request with no API key to the Singapore Chat Completions route,
the Singapore Anthropic Messages route and the US (Virginia) Chat Completions route.
Assert each returns 401 with "No API-key provided". Validate the payload against
the CLI schema, run the scenario and tell me which steps fail.
The agent checks the payload shape, creates the scenario and runs it:
apidog cli-schema validate test-scenario-update --file steps.json
apidog test-scenario create --project <PROJECT_ID> --name "Qwen4-35B-A3B API route check" --folder-id 0 --priority 1
apidog test-scenario update <SCENARIO_ID> --project <PROJECT_ID> --file steps.json
apidog run -t <SCENARIO_ID> --project <PROJECT_ID> -e <ENV_ID> -r cli
Here’s that run on a sandbox project. All three routes are live and refuse a call with no key, 6 of 6 assertions:
Next, ask the agent to save an environment that holds your base URL and key, then add a real call that asserts status 200, a non-empty choices array and a usage object:
apidog environment create qwen-sg --project <PROJECT_ID> \
--base-url https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1
apidog run -t <SCENARIO_ID> --project <PROJECT_ID> -e <ENV_ID> --env-var "QWEN_KEY=$DASHSCOPE_API_KEY" -r cli
The same apidog run works in CI. See the apidog run command reference and Apidog CLI in Claude Code.
When your team has several of these agent checks going, Sharkly puts them on a shared board as tasks. Each agent runs on your own machine with your own Claude Code, Codex or OpenCode plan, and you review what it ships before it merges. It’s free to start.
FAQ
What is the model id for the Qwen4-35B-A3B API? qwen4-35b-a3b on Qwen Cloud. On a self-hosted vLLM or SGLang server, it’s the Hugging Face name, Qwen/Qwen4-35B-A3B (or the FP8 build you served).
Is the Qwen4-35B-A3B API OpenAI-compatible? Yes. Use base URL https://<region>.maas.qwencloudapi.com/compatible-mode/v1 for Chat Completions and Responses. It also has an Anthropic-compatible endpoint at /apps/anthropic.
How much does the Qwen4-35B-A3B API cost? In Singapore on December 4, 2026: $0.06 per 1M input tokens, $0.36 per 1M output tokens and $0.003 per 1M cached input tokens. Frankfurt, Tokyo and US Virginia were slightly lower.
Why do I get a 401 from Qwen Cloud? Either the key is missing (No API-key provided) or it belongs to another region. Keys only work with the endpoint of the region where you created them.
How do I turn off thinking? Send enable_thinking: false, at the top level over HTTP or in extra_body with the OpenAI SDK. On the model card, reasoning_effort: "off" does the same thing.
How does it compare with Qwen4-Max? Qwen4-Max is the API-only flagship; see the Qwen4-Max API guide. For the open-model matchup, read Qwen4-35B-A3B vs Qwen3.8-27B.





Top comments (0)