Large Model API Integration: Search and Document Parsing in Practice
This article examines the shift from client-side tool assembly to server-side integration in LLM applications, focusing on how search and document parsing are now built into chat APIs or exposed as standalone endpoints. It outlines a two-layer capability model, explains how client-side responsibilities change, and provides a reproducible six-step validation method, cost and observability guidance, and an engineering checklist for building verifiable RAG applications.
1. The Trend: From Assembling Tools to Server-Side Integration
Over the past year, building a usable retrieval-augmented generation (RAG) application typically required developers to handle four tasks themselves: connecting search, parsing documents, chunking and vectorizing content, and stitching results back into the prompt. The first two tasks are tightly coupled to specific data sources and account for the most glue code and the most errors.
A clear change in the industry recently is that some cloud providers have begun embedding capabilities such as web search, retrieval during inference, document reading, and link fetching directly into chat APIs, enabled on demand. At the same time, search, fetching, optical character recognition (OCR), speech recognition, and speech synthesis are being separated into standalone endpoints that can be called individually. On the model services offered by the Baidu AI Cloud Qianfan platform, for example, developers can still call model capabilities through a unified API gateway and combine retrieval and document processing chains as business needs require.
The essence of this layering is moving “tool-call orchestration” and “context assembly” from the client up to the server, leaving the client responsible only for conversation state management and result rendering.
2. A Two-Layer Capability Model: In-Chat Tools and Standalone Endpoints
The first layer consists of tool switches inside the chat API, commonly including:
- Web search: the model retrieves public web pages before answering and cites sources;
- Deep-thinking search: the model autonomously decides to run additional retrieval, open pages, and search within a page during reasoning, with a cap on the number of tool operations per turn;
- Document input: support for common office and document formats, with limits on per-file size and page count;
- Link reading: extracting the main text from a given URL before answering;
- Content safety checks: compliance filtering on inputs and outputs.
The second layer consists of five independently callable endpoints: search, fetching, document parsing, speech recognition, and speech synthesis. They suit offline batch processing, non-conversational pipelines, or scenarios that require precise control over the input and output of each step.
3. Where to Draw the Line on Responsibilities
After the server takes over orchestration, the client is not left idle; instead, it must focus on three things:
- Session and context consistency: multi-turn tool calls generate large amounts of intermediate content, so you must decide what carries into the next turn’s context;
- Result explainability: render citation sources, retrieval timestamps, and the tool trace for users;
- Failure fallback: define fallback responses and retry strategies for empty search results, document parsing failures, and timeouts.
A schematic call skeleton (pseudocode, structure only):
resp = client.chat.completions.create(model="<model identifier>",messages=[{"role": "user", "content": "Compare the latest funding amounts of two companies"}],tools=[{"type": "web_search"}, {"type": "file_input"}],)print(resp.choices[0].message.content)for ev in resp.tool_events: # Tool trace, used for rendering and auditingprint(ev.type, ev.status)
4. Validation: A Reproducible Six-Step Test
Run a baseline comparison in a fixed order to make it easier to isolate the source of differences:
- Baseline chat: pure model response; record latency and tokens;
- Web search: ask a question that requires real-time data, and verify the numbers and source dates;
- Deep-thinking search: request a cross-source comparison, and observe reasoning tokens and the number of additional retrievals;
- Link reading: provide a page with a well-structured body, and check extraction completeness;
- Document input: create your own document and embed fictional fields (such as budget figures or internal code names) to verify that the content is actually read rather than guessed;
- Standalone endpoint: call the search endpoint separately once, and compare its results with the in-chat tool for consistency.
The key design is “planted-marker validation”: fictional information cannot come from the model’s prior knowledge, so a correct answer proves the reading pipeline is working.
5. Cost and Observability
At a minimum, monitor these billing dimensions: number of requests, input/output tokens, number of tool calls, document page count and size, and the per-call portion of standalone endpoints. Attach a business-side trace identifier to each request and align the tool trace with billing entries; only then can you pinpoint “which step is burning money.” In engineering practice, use logging services and monitoring alerts to set a per-request cost threshold.
6. Engineering Implementation Checklist
- Cache first: route identical queries through a cache to reduce repeated retrieval;
- Context trimming: keep only conclusions and citations, and discard lengthy intermediate pages;
- Timeouts and retries: set a separate timeout for search tools so they do not drag down the main chain;
- Compliance fallback: enable content safety checks and retain audit logs;
- Abstract interface layer: wrap tool switches as configuration to make migration between models easier.
7. Conclusion
Pushing search and document parsing down to the server reduces glue code but raises the bar for context governance, cost observability, and fallback strategies. Developers should shift their focus from “connecting tools” to “designing information flow,” combining capabilities in a configuration-driven way on platforms such as Baidu AI Cloud to build RAG applications that are verifiable, observable, and cost-controlled.
