A Practical Guide to Integrating Web Search and Multimodal Parsing into LLM APIs

    This article explains how to integrate server-side hosted capabilities—web search, URL reading, and document parsing—into LLM APIs. It covers the shift from self-built pipelines to server-managed tools, integration via three mainstream API protocols, the critical requirement of returning structured blocks intact across conversation turns, limitations on sampling parameters when managed tools are enabled, and how to choose between plain text extraction and layout-aware parsing based on cost and accuracy trade-offs.

    1. From Self-Built Pipelines to Server-Side Hosting: The Trend of Capability Encapsulation

    For a long time, developers who wanted to build a “web-connected” conversational application had to assemble an entire pipeline themselves: first decide whether a user’s question requires retrieval, then call a search API to fetch web pages, extract the main content, clean the HTML, chunk the text back into the context, and finally stitch together a prompt for the model to generate an answer. This pipeline involves search quality, anti-scraping strategies, text extraction accuracy, token budget control, and more—each stage consuming engineering effort.

    A clear industry trend has emerged recently: cloud providers and model service platforms are moving these tools down to the server side, exposing them as API parameters. The client only needs to pass switches such as “allow web access,” “allow URL reading,” or “allow file parsing,” while search decisions, multi-round tool invocations, and result aggregation are all handled by the server. The core value of this model lies in:

    • Internalized decision-making: Whether to search, how many rounds to run, and whether to refine keywords are decided autonomously by the model during inference, rather than by hardcoded client-side rules;
    • Context consistency: Tool results natively live within the model’s conversational context, avoiding the information misalignment caused by client-side prompt stitching;
    • Reduced operational burden: No need to maintain fragile components such as search proxy pools or web page parsers.

    2. Integration via Three Mainstream Protocols

    Server-side tool hosting capabilities are generally compatible with three common industry protocols: the Anthropic-style Messages protocol, the OpenAI-style Responses protocol, and the classic Chat Completions protocol. For existing applications, this means migration costs are minimal—usually it only takes adding a few fields to the request body.

    A typical integration example (in Chat Completions style; field names should follow each provider’s official documentation):

    1. {
    2. "model": "chat-model",
    3. "messages": [{"role": "user", "content": "Compare the heights of two tall towers"}],
    4. "tools": [
    5. {"type": "web_search"},
    6. {"type": "read_url"}
    7. ],
    8. "thinking": {"enabled": true}
    9. }

    Here, web_search handles web and image search, while read_url handles links the user drops directly into the conversation. With thinking mode enabled, the model can “reason while searching” like a deep research agent: it runs an initial search, opens source pages to find data, searches for keywords within a page or retries with rephrased queries if the data is incomplete, and may invoke tools up to around twenty consecutive times before concluding. With thinking disabled, it degrades to on-demand single-round search, with source citations attached to the answer.

    3. Must Be Returned As-Is: The Easiest Context Pitfall

    One rule repeatedly emphasized in the documentation deserves every integrator’s attention: the thinking blocks, search result blocks, and page-fetch result blocks returned by the server must be sent back unchanged in the next conversation turn.

    The reason is that multi-turn conversations are inherently stateless. Which pages the model “saw” in the previous turn and what intermediate conclusions it retrieved are all recorded in these structured blocks. If the client discards them, the request will still succeed, but the model will forget the web content it just read and can only answer from residual memory in the next turn—significantly degrading quality.

    This pitfall is especially common in self-built gateway scenarios: many teams place a proxy layer between client and server for authentication, rate limiting, and log sanitization. If the gateway filters fields by a whitelist and silently drops unrecognized structured blocks, the problem occurs without any visible error. Best practices include:

    1. Configure the gateway to pass message bodies through transparently—add, never remove;
    2. Specifically verify in a test environment “whether the second turn remembers the first turn’s retrieved content”;
    3. Perform signature verification on returned blocks to prevent client-side tampering.

    4. Sampling Parameters May Be Ignored—Confirm in Advance

    Another easily overlooked limitation: once managed capabilities such as tool calling, automatic title generation, or high security levels are enabled, the server takes over the sampling cadence, and parameters like temperature and top_p in the request are directly ignored.

    This has a significant impact on applications that require fine-grained control over output style (e.g., creative writing or low-temperature code generation). Before integration, clarify how much your business depends on sampling parameters. If necessary, evaluate splitting tool calls into separate requests, or disabling managed capabilities in a dedicated channel, to regain control over sampling behavior.

    5. Billing and Accuracy Trade-offs in Document Parsing

    Per-page billed file parsing (PDF, Word, PPT, images) typically offers two modes, and the choice directly affects cost and results:

    • Plain text extraction: Extracts text only—fast and inexpensive. However, charts and figures in the document are discarded entirely, and the model cannot see them at all. Suitable for text-only documents such as contracts and notices.
    • Layout-aware parsing (rich layout recognition): The system automatically detects charts, crops the images, and inserts them back into their original positions in the text, so the model can “read” both text and images simultaneously. The trade-off is that the cropped images are billed as image input tokens, and since chart detection is automatic, any figure the detector misses remains invisible to the model.

    Take financial report analysis as an example: if you only ask about textual information such as revenue figures, plain text extraction is sufficient; if you ask “what trend does the revenue chart show,” layout parsing is mandatory. It is recommended to route by business scenario rather than applying one mode across the board.

    6. Conclusion

    Server-side tool hosting frees web search, URL reading, document parsing, and voice capabilities from client-side pipelines, significantly lowering the barrier to building multimodal conversational applications. The three key points for integration are: choose a familiar protocol, ensure structured blocks are returned intact across turns, and understand how managed capabilities affect sampling parameters. For file parsing, balance cost against accuracy per scenario. Mastering these details is what allows server-side tools to truly improve business efficiency.

    If your team needs a stable enterprise-grade platform for production deployment, you can look into the LLM services and supporting retrieval and document parsing cloud products offered by Baidu AI Cloud, applying the methodology in this article to your selection and integration process.