LLM Application APIs: A Practical Guide to Web Search and Multimodal Tool Chains
This article explains how to build a controllable tool-calling layer for large language model (LLM) applications that need to answer with evidence. It breaks down the atomic capabilities behind modern LLM APIs—web search, deep retrieval, web page extraction, file upload and parsing, OCR, speech recognition, and speech synthesis—and proposes a five-layer reference architecture covering access, orchestration, capability, data, and governance. It also covers hard constraints for autonomous tool use, citation trustworthiness, document parsing quality, tiered voice and vision usage, cost control, and compliance, so developers can shift their focus from building tools to orchestration and governance.
1. Background: Strong Models Still Need a Tool Chain to Get Things Done
Getting a large language model to produce a fluent answer is not difficult. The real challenge is making it answer with evidence. A usable question-answering system typically needs to understand user intent, decide whether to go online, construct search queries, fetch page content, clean and chunk text, parse PDFs and tables, fit the fragments into the context, generate an answer with citations, and finally apply sensitive-content filtering and audit logging. This pipeline spans multiple engineering domains, including network access, document parsing, speech recognition and synthesis, caching, and rate limiting. It is often the most underestimated burden in AI application development.
A clear trend has emerged recently: model vendors are exposing the capabilities used in their official applications through APIs, including web search, deep retrieval, file input, web page reading, and standalone OCR, speech recognition, and speech synthesis endpoints. Developers only need to declare the available tools in the request, and the model decides on its own whether to call them, while the server side handles retrieval, fetching, and context assembly. This marks a shift in competition from model benchmark scores to the tool chains that developers used to maintain themselves.
This article does not evaluate any specific vendor. Instead, it abstracts these capabilities into a general architecture question: how to design an extensible tool-calling layer that lets a model use external capabilities autonomously within controlled boundaries.
2. Capability Breakdown: The Atomic Interfaces a Complete Application Needs
Breaking down the capabilities of official applications yields four categories of atomic capabilities.
The first category is retrieval: web search and deep retrieval. Web search returns a list of results and summaries relevant to the query. Deep retrieval performs multiple rounds of expansion, deduplication, and authority ranking, making it suitable for research-oriented questions.
The second category is content acquisition: web page fetching and main-content extraction. This turns dynamic pages into clean text and handles encoding, anti-scraping measures, and timeouts.
The third category is files: file upload and parsing. This converts PDFs, images, audio, and video into structured text or searchable fragments and returns a file identifier for later reference in the conversation.
The fourth category is multimodal: OCR, speech recognition, and speech synthesis, which handle image-to-text, speech-to-text, and text-to-speech respectively.
Together, these four categories form a closed loop of perception, memory, and expression: retrieval and fetching are perception, file parsing is memory, and speech synthesis is expression.
3. Reference Architecture: Five Layers and a Typical Call Sequence
A five-layer structure is recommended to avoid hard-coding external capabilities into business logic.
The access layer handles authentication, rate limiting, and quotas. The orchestration layer handles intent recognition and tool selection. The capability layer wraps atomic interfaces such as search, fetching, files, and voice. The data layer handles caching, vectorization, and logging. The governance layer handles compliance, auditing, and cost monitoring.
A typical sequence is as follows: after the user asks a question, the orchestration layer first decides whether to go online. If so, it calls the retrieval interface, then performs main-content extraction and chunking on the results. It then submits the fragments together with the question to the model. When the model outputs an answer, it includes citation sources. Finally, the answer passes through content safety filtering before being returned.
The following pseudocode is illustrative and only expresses the call order; it does not point to any specific interface:
plan = router.decide(query) # whether search/file/voice is neededif plan.search:docs = search(query, top_k=5)pages = extract(urls=docs.urls) # main-content extraction and cleaningcontext = chunk_and_rank(pages)if plan.file:fid = upload_and_parse(file)context += retrieve_from_file(fid)answer = llm(query, context, tools=[citation])return safety_filter(answer)
4. Web Search and Web Page Reading: Keeping Autonomous Calls Under Control
Letting the model decide when to call tools can significantly improve the experience, but it also introduces three risks: infinite call loops, retrieval results polluting the context, and uncontrolled external access.
Engineering practice should impose hard constraints: a cap on the number of tool calls per session, per-tool timeout and retry limits, truncation of result counts and content length, domain whitelists or blacklists, and cache key design (using the normalized query and time as the key). For high-risk scenarios, use a two-stage “retrieve first, confirm later” approach: the model proposes a retrieval plan, and the business side decides whether to execute it.
Citation trustworthiness is equally important. Keep the original link, fetch time, and content hash, and label the source number sentence by sentence in the answer. When multiple sources conflict, prioritize the more recent and more authoritative result and explicitly flag the disagreement.
5. File Input and Parsing: From Upload to Citable Evidence
The key to the file pipeline is that parsing quality determines answer quality. After upload, first perform type detection and size validation, then enter the parsing pipeline: layout reconstruction, table structuring, page and section localization, chunking, and vectorization. For scanned PDFs, perform image preprocessing and OCR first, then proceed to layout analysis.
The returned file identifier should be bound to the session and permissions to prevent unauthorized references. Chunks should retain hierarchical metadata (page numbers, heading paths) so answers can be traced back to a specific location. For very long documents, use a two-level “summarize first, then retrieve” strategy: first generate section summaries for routing, then perform fine-grained retrieval within the matched sections.
6. Voice and Vision: Experience Boosters, but Count the Cost
Speech recognition and synthesis and OCR are general capabilities with mature solutions in the industry and business models that combine free tiers with pay-as-you-go pricing. When selecting, focus on three points: recognition accuracy in specific domains (proper nouns, accents, noise); synthesis naturalness and controllability of emotion; and latency and concurrency capacity.
A practical recommendation is tiered usage: for latency-sensitive real-time conversations, use streaming recognition and low-latency synthesis; for offline transcription and batch recognition, use an asynchronous task queue; for cost-sensitive scenarios, set up caching and deduplication to avoid repeatedly synthesizing the same text.
7. Cost Control: Cheap Call Fees, Three Expensive Things
Under pay-as-you-go pricing, the cost of a single retrieval or synthesis may seem very low, but the total cost is determined by three parts: engineering control of call volume, compliance cost, and the cost of judging results. The first two can be amortized through caching, batching, rate limiting, and audit automation; the third cannot be outsourced and must be borne by the business side.
It is recommended to build a cost dashboard that tracks retrieval counts, fetch success rate, parsing failure rate, and voice duration per thousand sessions by scenario, and to set budget alerts and circuit-breaker thresholds. Apply backoff retries to failed requests to avoid avalanche-style repeated billing.
8. Compliance and Governance: Traceability Is the Baseline
External content entering the context brings copyright, privacy, and injection risks. The following should be ensured: label fetched content with its source and time; mask personal information; isolate prompt injection (treat external text as untrusted data and prohibit it from changing system instructions); and keep end-to-end logs to support auditing. Enterprise scenarios should also incorporate key management, quota isolation, and data residency into the design.
9. Conclusion
Integrating search, fetching, file parsing, and voice and vision into model APIs is shifting the focus of AI application development from building tools to orchestration and governance. What developers really need to build is a controllable, observable, and measurable tool-calling framework: use hard constraints to tame autonomous calls, use metadata to ensure citation trustworthiness, and use tiered strategies to balance experience and cost. With this approach, even as interface shapes change, developers can quickly replicate a conversational system that approaches the experience of official applications.
