Decoupling LLM Capabilities: A Technical Guide to Building an AI Assistant with Composable APIs
This article explains how large model capabilities such as web search, link reading, document parsing, OCR, ASR, and TTS are moving from closed client applications into independently callable APIs. It breaks an AI assistant into four capability layers, then covers engineering practices for retrieval, document handling, voice and OCR, a reusable layered architecture, and cost and stability governance. Developers will find orchestration logic, pseudocode, and practical guidance for building their own assistant while staying compliant, observable, and cost-controlled.
1. From “Available Inside a Product” to “Composable via APIs”: Why Capability Decoupling Matters
In the past, conversational assistants from model vendors bundled capabilities such as web retrieval, link fetching, file understanding, and voice interaction inside their own clients, so developers could only use them within that interface. A clear trend has recently emerged: these capabilities are being split into independently callable API forms, and vendors have even stated that developers can replicate an application with an experience highly consistent with the official client.
For developers, the significance is not “one more API.” It is a transfer of ownership over interaction capabilities: retrieval strategy, context organization, the voice pipeline, and rendering are now fully in their own hands for the first time. The sections below cover architecture, capability decomposition, engineering practices, and governance.
2. Capability Decomposition: What Atomic Capabilities Make Up an AI Assistant
Reverse-decomposing the client yields four abstract capability layers:
- Reasoning layer: handles dialogue, planning, and tool-call decisions. It typically offers two modes, “non-thinking” and “thinking.” The former has low latency; the latter is for multi-step reasoning.
- Tool layer: web search, image search, link reading, code execution, and more, with the model deciding when to call them autonomously.
- Perception layer: converts non-text input into text or structured data the model can consume, including OCR text recognition and ASR speech recognition.
- Expression layer: converts text output into speech, i.e., TTS speech synthesis.
The key point is that these four layers can be called as an integrated whole or used separately. For example, ingesting a batch of scanned documents only needs the perception layer’s OCR, while an intelligent customer service system only needs the reasoning layer plus the tool layer.
3. Web Retrieval: From “Search First, Then Ask” to “Search While Thinking”
The traditional approach is two-stage: first call a search API to get results, then stitch them into the prompt and hand them to the model. The problem is that the first-stage query terms are decided by a human (or simple rules), and once the first retrieval misses, the entire chain breaks.
After API-based decoupling, retrieval becomes a tool the model can call. In non-thinking mode, the model decides on its own whether to search the web or images based on the question and attaches sources in the answer. In thinking mode, the model repeatedly issues retrievals, reads links, and revises conclusions across multiple reasoning steps. Three engineering points matter:
- Traceable citations: require structured source fields (title, link, summary, time) in the response and render them as superscript markers on the frontend so users can verify them.
- Freshness fallback: for time-sensitive questions, explicitly state in the prompt that retrieval “must” be performed, preventing the model from answering from memory.
- Failure degradation: when retrieval times out or returns empty results, fall back to an answer without retrieval and clearly inform the user, rather than silently fabricating.
Illustrative call logic (pseudocode, expressing orchestration intent only):
request = {model: "<reasoning model identifier>",stream: true,tools: ["web_search"], # non-thinking mode: single-round retrievalmode: "thinking" # thinking mode: multi-step autonomous retrieval}for chunk in stream(request):if chunk.type == "tool_call":log_source(chunk.sources) # persist sources for auditing and frontend markersyield chunk.text
4. Link Reading and Document Parsing: Folding “Crawler + Parser” into a Single Call
Give the model a URL, and the server side handles fetching, main-content extraction, and cleaning, after which the model answers with the context. This replaces the whole set of dirty work: building your own crawler, anti-scraping countermeasures, and maintaining content-extraction rules. The file side works the same way: after uploading a PDF, office document, or image, the system first performs plain-text extraction or mixed text-and-image parsing, then stitches it into the context.
Engineering recommendations:
- Keep preprocessing and direct calls side by side. For fixed-layout documents with clear fields, such as invoices and receipts, rule-based parsing is more stable and cheaper; leave materials with varied layouts to model-based parsing.
- Chunk long documents. Split by semantic boundaries, extract chunk by chunk, then merge, avoiding stuffing everything into the context at once and exceeding the context window.
- Structure the output. Require fixed fields (such as invoice number, amount, date, confidence) so results can be stored directly and validated later.
- Security boundaries. Fetching external links requires a domain whitelist, content-length limits, and prompt-injection protection to prevent malicious instructions in web pages from influencing model behavior.
5. Voice and OCR: Composition Freedom from Independent APIs
The voice pipeline is split into two independent APIs, ASR (speech to text) and TTS (text to speech), while OCR is handled page by page separately. All three can be combined freely with conversational capabilities. ASR typically covers mainstream languages such as Chinese, Cantonese, and English, and extends to Japanese and Korean, German, French, Spanish, Portuguese, Italian, Russian, Arabic, Hindi, and Southeast Asian languages, with support for less common languages still expanding.
Typical combinations:
- Voice assistant: ASR → reasoning (retrieval optional) → TTS, streaming end to end, where time-to-first-token determines the perceived experience.
- Meeting notes: segment long audio for ASR → reasoning for summarization and action-item extraction → store text.
- Image ingestion: batch OCR recognition → structured extraction → write into a retrieval index, forming a question-answerable knowledge base.
Practice points: apply silence splitting and endpoint detection to audio to reduce invalid recognition; control speech rate and emotion parameters on the TTS side to avoid a mechanical feel; retain timestamps in recognition results for alignment and proofreading against the original.
6. Architecture: A Reusable Reference Layering
Client (Web / Mobile / Desktop)↓ Unified gateway: authentication, rate limiting, metering, auditingOrchestration layer: session state, tool routing, degradation strategy↓Capability layer: reasoning / search / link reading / OCR / ASR / TTS↓Data layer: object storage (audio, video, documents), logging service, monitoring and alerting
Supporting recommendations: use object storage for sessions and files, use a message queue to smooth asynchronous task peaks, instrument the full chain into logging and monitoring with alerting, and track success rate and latency percentiles by API dimension.
7. Cost and Stability Governance
Once capabilities are finely split, cost granularity becomes finer and easier to lose control of. Four lessons:
- Tiered routing. Send simple intents to smaller-parameter models or non-thinking mode, and escalate to thinking mode only for complex questions.
- Cache first. Cache retrieval results and document-parsing results by content fingerprint so repeated requests hit directly.
- Budget guardrails. Set token and call quotas per tenant, meter OCR by page and voice by duration separately, and set threshold alerts.
- Observability loop. Build dashboards for tool-call success rate, retrieval hit rate, and end-to-end time-to-first-token, with automatic fallback to a simplified pipeline on anomalies.
8. Conclusion
The shift of large model capabilities from inside the client to APIs essentially breaks “experience” into composable building blocks. What developers truly gain is not a set of new parameters but full control over retrieval strategy, context construction, the voice pipeline, and cost structure. With the general capabilities of cloud platforms such as Baidu AI Cloud (object storage, message queues, logging services, monitoring and alerting), this layered architecture can be implemented quickly and evolve continuously under conditions of compliance, observability, and cost control.
