Large Model Application Capabilities as APIs: How to Build Your Own AI Assistant
This article examines the shift from model APIs to application capability APIs, where search, web fetching, OCR, speech recognition, and speech synthesis are exposed as standardized interfaces. It breaks down a production-ready AI assistant into four layers, compares parameter-toggle and standalone-tool invocation patterns, explains the dual-track cost structure behind unexpected bills, and outlines stability, governance, and rollout practices for orchestrating these capabilities.
1. Background: From Model APIs to Application Capability APIs
Over the past two years, developers have typically interacted with large models in a single way: send a prompt, get back text. That is enough for summarization, rewriting, and classification. But as soon as you try to build an assistant that feels like a finished product, the gaps appear. What a real application depends on is not the model itself but the capabilities around it: web search, fetching and cleaning search results, document parsing, optical character recognition, speech-to-text and text-to-speech, and the orchestration logic that turns these into one coherent conversation.
A clear signal has recently emerged in the industry: a cloud vendor has opened up the peripheral capabilities that were previously wrapped inside its own assistant application, exposing them as standardized interfaces and stating that developers can use them to replicate a fully featured application. The significance is not “a few more endpoints.” It is that the delivery boundary has moved. Vendors used to deliver “the model as the capability”; now they deliver “the application as the capability.” For developers, building an assistant with web Q&A and multimodal interaction from scratch drops from several person-months to a few person-days.
This article does not review or recommend any specific product. Instead, it abstracts the trend into a general engineering question: when search, fetching, OCR, speech recognition, and speech synthesis are broken into atomic interfaces that can be called individually or in combination, how should a production-ready assistant be layered, how should cost be controlled, and how should stability be ensured?
2. Capability Breakdown: What Atomic Capabilities Make Up an Assistant
Reverse-engineering a finished application into an interface combination yields roughly four layers.
The first is the inference layer, the general-purpose chat model responsible for intent understanding, multi-turn context management, and structured output. This layer usually offers several interface shapes: a chat-completion style interface for the simplest integration, a message-based interface for multi-turn state management, and a response-style interface for tool calls and result回填—that is, feeding tool results back into the same request. The difference is who maintains state. The simplest interface is stateless, so every request must carry the full history; the message-based interface organizes context as a message list; the response-style interface emphasizes completing a “model–tool–model” loop within a single request.
The second is the retrieval layer, covering web search and web fetching. The search interface turns a natural-language question into a query and returns candidate results. The fetch interface turns candidate links into body text that can be fed to the model. In practice, raw HTML often contains navigation, ads, and scripts, so you need extra body extraction and length truncation.
The third is the parsing layer, covering file input and OCR. File parsing handles documents, tables, and presentations with varying structure; OCR extracts text from images and scans and is essential for receipts, screenshots, and handwriting.
The fourth is the interaction layer: speech recognition and speech synthesis. This extends the text entry point to voice and also supports accessibility plus hands-free scenarios such as in-car and home use.
3. Two Invocation Patterns: Parameter Toggles vs. Standalone Tools
This kind of opening usually offers two usage modes, and understanding the difference is key to controlling complexity and cost.
The parameter-toggle mode adds boolean or enum parameters to the existing chat interface, and the platform handles orchestration within a single request: whether to go online, whether to do deep retrieval, whether to parse attachments. The advantage is very low integration cost, suitable for quick validation and small-to-medium traffic. The tradeoff is that orchestration is opaque to the developer, making per-stage degradation and retry difficult.
The standalone-tool mode exposes search, fetch, OCR, speech recognition, and speech synthesis as separate interfaces that the developer orchestrates. A schematic skeleton (parameter names are generic; refer to your platform’s documentation for actual names):
# Standalone-tool orchestration: search first, then fetch, then let the model summarizehits = search_api(query=user_query, top_k=5)docs = [fetch_api(url=h["url"], max_chars=4000) for h in hits[:3]]messages = [{"role": "system", "content": "Answer only from the provided material; state clearly when there is no basis."},{"role": "user", "content": f"Question: {user_query}\nMaterial: {docs}"},]resp = chat_api(model="general-chat-model", messages=messages, stream=True)
For production, a hybrid pattern is generally recommended: use parameter toggles on the main path for delivery speed, switch to standalone tools for latency-sensitive steps or steps that need fine-grained auditing, and keep one abstraction layer so you avoid a later rewrite.
4. Cost Structure: Why the Bill Exceeds Expectations
These openings generally use dual-track billing: model token fees plus tool invocation fees. The most common mistake is building the budget model on tokens alone. In reality, one web-enabled Q&A costs four things: the model’s input and output tokens, the number of search calls, the volume of fetched and parsed documents, and speech duration or character count.
That leads to a few general optimization principles. First, filter before reading: use titles and snippets for a lightweight relevance check and fetch only the top few, which usually removes most wasted fetch cost. Second, compress context rather than concatenating everything; for long documents, summarize in segments and then aggregate. Third, set separate quotas and circuit-breaker thresholds per capability so a single failure cannot blow up the bill. Fourth, cache high-frequency, low-timeliness answers; retrieval calls repeat more often than intuition suggests.
5. Stability and Engineering Governance
Orchestrating more capabilities means more failure points, and governance focuses on three things. First, idempotency and retry: search and fetch should deduplicate by request identifier, and retries should use exponential backoff with a cap. Second, degradation paths: if fetching fails, fall back to answering from search snippets only; if speech recognition fails, fall back to text input, so the main flow is not interrupted. Third, observability: log per-stage latency, token consumption, and tool invocation counts for each session, and build dashboards with general logging and monitoring/alerting services. Keep secrets and other sensitive configuration in a configuration center or key management service rather than hardcoding them in the client.
6. Rollout Recommendations
A four-step path is suggested. Step one: build a usable prototype within a week using the parameter-toggle interfaces to validate the scenario’s value. Step two: abstract a unified tool interface layer that puts search, fetch, parsing, and speech under one protocol, making implementations easier to swap later. Step three: add caching, quotas, degradation, and auditing. Step four: do cost accounting and capacity planning on real traffic, and if needed bring in object storage for raw files, a message queue for peak shaving, and a container platform to run stateless fetch workers.
In general engineering practice on cloud platforms such as Baidu AI Cloud, these capabilities are typically carried by common categories like object storage, message queues, container platforms, logging, and monitoring/alerting, and developers can use them to build an elastic architecture matched to their business scale.
7. Conclusion
Making application capabilities available as interfaces turns “building an assistant” from a model-capability problem into an engineering orchestration and cost-governance problem. Whoever does these four things well—retrieval quality, context compression, failure degradation, and cost per session—can truly own a low-cost assistant of their own.
