
Aliyun Bailian (7): Built-in Web Search and Code Interpreter
Server-side web_search, web_extractor, and code_interpreter through the Responses API — a mini-agent without writing the tool loop.
The previous article built a coding agent by hand: define tools, loop, dispatch, repeat. That’s the right pattern when the tools are yours (your filesystem, your test runner). But for two extremely common tools — searching the web and running a snippet of code — Model Studio now runs them server-side. You enable a flag, the platform does the search-or-execute round trip inside one API call, and you get the final answer back. This article is the practical guide to those built-in tools.
Two ways to get web search#
There are two distinct entry points, and picking the wrong one wastes a day.
The simple one — enable_search on Chat Completions. If all you want is “answer this using current web info”, the cheapest change to your existing chat code is a single parameter. With the native DashScope SDK:
| |
That’s it. The model decides whether a search is needed, runs it, and folds the results into the answer. Both thinking and non-thinking modes support the agent and agent_max search strategies, where the model can issue multiple, refining queries rather than one shot. For a chatbot that occasionally needs fresh facts, enable_search=True is all you need.
The powerful one — the Responses API with explicit tools. When you want the model to not just search but also open pages and run code over what it finds, you move to client.responses.create(...) and pass tools explicitly. This is the rest of the article.
The Responses API and the built-in tool block#
The Responses API is the newer, agent-oriented surface. The request is flatter — input instead of messages — and you attach built-in tools by type:
| |
Three things to know up front:
- The three tools are meant to be used together.
web_searchfinds URLs,web_extractoropens them and pulls the full content,code_interpreterruns analysis over whatever was found. The docs explicitly recommend enabling all three for best results on complex tasks. web_extractormust be paired withweb_search— it has nothing to extract on its own.qwen3-max/qwen3-max-2026-01-23require thinking mode for these tools, hence theenable_thinking=True.qwen3.5-plusdoes not require it. Get this wrong and the tools silently don’t fire.
Reading the output: it’s not just text#
response.output_text gives you the final answer string, which is enough for a chat UI. But the interesting part — what the model searched, what it executed — lives in response.output, an array of typed items. Iterate it when you need transparency or citations:
| |
This typed stream is how you build a “the assistant searched X, then read Y, then computed Z” trace for the user — the same UX pattern as a research agent, but the orchestration happened server-side. To count how many tool invocations a request used (for cost attribution), the usage block carries it:
| |
Code interpreter: the model runs Python for you#
code_interpreter gives the model a sandboxed Python runtime. It writes code, the platform executes it, the model reads the result, and continues. This is the right tool for anything the LLM is bad at doing in its head: exact arithmetic, parsing a messy CSV, computing a statistic, generating a chart.
| |
The win here is correctness. Ask qwen3.5-plus to compute a compound growth rate in its head and it will sometimes be subtly wrong; ask it with code_interpreter enabled and it writes the formula, runs it, and reports a number you can trust. For data-analysis chat features this is the difference between a demo and a product. Note the same thinking-mode rule: qwen3-max needs enable_thinking=True, qwen3.5-plus does not.
When to use built-in vs. roll-your-own#

I reach for the built-in tools when:
- The tool is web search or generic code execution — the two things the platform does well and I’d otherwise have to operate (a search API key, a sandbox) myself.
- I want the orchestration handled server-side — no tool loop, no parsing tool_calls, no retry logic. One call in, answer out.
- The task is occasional, so paying per built-in tool call beats running my own search/sandbox infrastructure.
I roll my own (the article-6 pattern) when:
- The tools touch my systems — my database, my files, my internal APIs. The platform can’t reach those.
- I need fine control over each step — custom retry, caching, auditing of every tool input/output.
- Volume is high enough that per-call tool pricing loses to running my own infra.
A useful note on cost: at the time of writing, web_extractor and code_interpreter are free for a limited promotional period, while web_search is metered per call (that’s the usage.x_tools count above). Don’t architect around “free forever” — meter your tool calls from day one so the bill doesn’t surprise you when the promo ends.
A combined example: research-then-compute#
The three tools shine together. “Find the current USD/CNY rate, then convert these invoice totals” needs a search, a page read, and arithmetic — one Responses call does all of it:
| |
The model searches for the rate, extracts it from a finance page, then uses code_interpreter to do the multiplication and the sum — accurately. Building that by hand means a search integration, an HTML scraper, and a calculation step. Here it’s one call.
What’s next#
That closes the loop on this seven-part series: platform and pricing (1), the LLM API and function calling (2), multimodal Qwen-Omni (3), Wanxiang video (4), Qwen TTS (5), coding agents (6), and built-in tools (7). The throughline has been the same: Bailian keeps moving capability from “you orchestrate it” to “the platform orchestrates it” — function calling, then agents, now server-side tools. The next frontier on the platform is full hosted agents (Agent 2.0), which unify knowledge bases and MCP under the model’s own planning — a natural follow-up once you’ve outgrown a single Responses call.
Aliyun Bailian 7 parts
- 01 Aliyun Bailian (1): Platform Overview and First Request
- 02 Aliyun Bailian (2): The Qwen LLM API in Production
- 03 Aliyun Bailian (3): Qwen-Omni for Video, Audio, and Image Understanding
- 04 Aliyun Bailian (4): Wanxiang Video Generation End-to-End
- 05 Aliyun Bailian (5): Qwen-TTS for Multilingual Voice
- 06 Aliyun Bailian (6): Qwen3-Coder and Coding Agents
- 07 Aliyun Bailian (7): Built-in Web Search and Code Interpreter you are here