Server-Side Web Search for LLMs: A Practical Guide to Hosted Retrieval for RAG Applications

    This article explains how web search capabilities for large language models are moving from client-side pipelines to server-side hosting. It covers the layered architecture of server-side tool calling, the two operating modes of direct answering and deep search, citation and source credibility practices, engineering governance for cost, latency and stability, and the trade-offs between hosted retrieval and self-built RAG. Developers will learn how to simplify application code, design fallback strategies, and roll out search-enabled models safely.

    1. From Client-Side Pipelines to Server-Side Hosting

    When building retrieval-augmented generation (RAG) applications, the early mainstream approach was to handle retrieval on the application side: first call a search API to obtain candidate links, then fetch the body text of each page one by one, clean and truncate it, assemble the content, and finally stuff large blocks of text into the model context so the model can generate an answer with citations.

    This pipeline looks simple, but it is full of engineering pitfalls: search recall quality is unstable, body-text extraction rules frequently break as page structures change, the context window gets crowded out by irrelevant content, the state machine for multi-round follow-up searches has to be maintained manually, and retry and timeout strategies are hard to standardize.

    The recent technical direction is clear: push atomic capabilities such as searching the web, searching by image, and fetching the body text of a link down to the model server, letting the server decide when to retrieve and how many rounds to run during inference. The application’s responsibility is compressed into “send a request + declare available tools + consume results with citations.”

    This is not a simple interface merge, but a redrawing of responsibility boundaries: the application cares about business semantics and result presentation, while the server cares about retrieval orchestration and evidence organization.

    It is worth noting that these capabilities are usually opened first on lightweight or specific model versions, while flagship versions often follow later. During engineering selection, capability availability should be made configurable rather than hard-coded into business logic.

    2. A Layered Architecture for Server-Side Tool Calling

    The whole mechanism can be understood as four layers:

    1. Capability layer: web search, reverse image search, and fetching the body text of a specified link, exposed as a tool set the model can call.
    2. Orchestration layer: the server maintains a controlled loop that decides “whether to retrieve, what to retrieve, how many rounds to run, and when to stop.”
    3. Evidence layer: fetched content is extracted, denoised, segmented, and ranked by relevance to form citable evidence snippets.
    4. Output layer: the model generates an answer based on the evidence and returns source citations for front-end rendering.

    The application interacts only with the outermost layer. A schematic request structure is shown below (fields are generic illustrations, not a specific vendor’s API):

    1. {
    2. "model": "<your-model-name>",
    3. "messages": [{ "role": "user", "content": "Compare the heights of two tall towers" }],
    4. "tools": ["web_search", "image_search", "fetch_url"],
    5. "reasoning": { "enabled": true },
    6. "max_tool_calls": 20
    7. }

    The direct benefits of this layering are that retrieval strategy iterations no longer require application releases, the amount of application-side code drops significantly, and the fault domain is narrowed.

    With thinking mode disabled, the model behaves as a “single-round Q&A system that retrieves on demand”: it judges whether the question needs external information, and if so, launches one or a few searches, fetches the body text, and answers directly. This suits factual queries, time-sensitive Q&A, and simple comparisons, with low latency and controllable cost.

    With thinking mode enabled, the model enters an iterative “deep search” state, reasoning and searching in parallel. The official documentation once used comparing the heights of two landmark buildings as an example, and its flow is representative:

    • Round 1: broad search to obtain candidate pages and summaries;
    • Round 2: open authoritative source pages and locate specific values;
    • Round 3: if information is incomplete, run in-page keyword searches or rephrase and search again;
    • Wrap-up: stop calling tools once evidence is sufficient and output a conclusion with citations.

    There is an upper limit on tool calls (around twenty in the example), which is a necessary cost and safety guardrail. In engineering, this limit, per-round timeout, and total duration should be made configurable parameters, and a fallback message should be designed for the case where “the limit is reached without convergence,” for example returning the evidence already obtained and flagging uncertainty.

    4. Citation Traceability and Result Credibility

    After retrieval is hosted on the server, citation information is returned together by the server, and the application’s job is to “present faithfully” rather than “reprocess.” Three practices are recommended:

    • Align citations with claims: place the source number immediately after each key conclusion, avoiding “conclusions first, sources piled at the end,” which makes verification impossible.
    • Display sources by tier: distinguish authoritative institution pages, media, and community content, and use visual weight differences on the front end to signal credibility.
    • Preserve original snippets: show the cited excerpts in a collapsible area so users can judge whether content is taken out of context.

    For reverse image search scenarios, the source page and licensing status of the image should also be displayed to avoid copyright risk.

    5. Engineering Governance: Cost, Latency, and Stability

    Server-side hosting does not mean zero cost; it requires more refined governance:

    • Cost control: set whether thinking mode is allowed per scenario; introduce result caching for high-frequency repeated questions; disable web access for non-time-sensitive Q&A.
    • Latency control: set a total duration budget for the retrieval phase, and on timeout fall back to “answer based on existing evidence” or “prompt the user to retry later.”
    • Stability: treat tool call failures and body-text extraction failures as the norm, and design idempotent retries and circuit breaking; apply domain-level rate limiting to fetch targets to avoid being blocked.
    • Observability: record metrics such as retrieval rounds, tool call counts, evidence hit rate, and citation coverage, connect them to logging services and monitoring alerts, and form a traceable call chain.
    • Security and compliance: guard user input against prompt injection to prevent page content from hijacking instructions, and filter sensitive information from returned content.

    6. Trade-offs Against Self-Built RAG

    The advantage of a self-built pipeline is full control over recall and ranking, which suits vertical domains, private data, and strong compliance scenarios. The advantage of server-side hosting is out-of-the-box availability, continuously evolving strategies, and a small operational burden, which suits general Q&A and rapid validation.

    In practice, a hybrid architecture is common: general time-sensitive questions go through server-side hosting, enterprise internal knowledge goes through self-built vector retrieval, and the application side handles unified orchestration and presentation.

    When deploying on Baidu AI Cloud, it can be treated as a combination of “model service + general cloud resources”: the model side provides retrieval-augmented inference, the application side relies on a container platform to deploy orchestration services, object storage keeps evidence snapshots, a message queue smooths traffic peaks, and the logging and monitoring system closes the governance loop.

    7. Conclusion

    Handing web search over to the server is essentially separating “retrieval orchestration,” a cross-cutting concern, from business code. Developers should focus their energy on scenario definition, evidence presentation, and governance strategies, while keeping an abstraction over capability availability and fallback designs. Validating effectiveness and cost with small traffic first, then gradually expanding the coverage of thinking mode, is a more reliable path to adoption.