LLM Application API Open: How to Replicate a Full AI Assistant

    This article breaks down the shift from a plain model API to a full suite of application-level APIs, covering five core capabilities—web search, deep-thinking search, file input, link reading, and model safety—along with their engineering implications. It outlines a four-layer tool-calling architecture, essential reliability practices, a cost model based on tokens plus tool usage, and the compliance obligations of running a public-facing service. Developers will learn how to orchestrate, govern, and optimize an AI assistant instead of rebuilding undifferentiated infrastructure.

    1. Background: From a “Model API” to a Full Application API Suite

    Over the past two years, developers building AI assistant applications typically received only a plain chat completion endpoint. The model generated text, and everything else had to be built by the developer: search required a self-hosted crawler and index, file parsing required a document conversion pipeline, voice required separate recognition and synthesis services, and link reading required content extraction and denoising. As a result, the same “chat assistant” was rebuilt again and again, with most of the engineering effort going into infrastructure that offered no differentiation.

    Recently, a cloud vendor integrated capabilities from its AI assistant application—web retrieval, deep-thinking search, file input, and link reading—into its existing model API. It also opened standalone tool endpoints for search, web crawling, optical character recognition (OCR), speech recognition, and speech synthesis, which can be called individually or in combination. The vendor explicitly states that developers can use these capabilities to closely replicate a complete assistant application, and it provides a demo application and sample code alongside them.

    The real significance here is not “less code to write” but layering: the model layer handles reasoning, the tool layer handles interaction with the external world, and the application layer handles only interaction orchestration and experience design. Understanding this layering matters more than memorizing any specific parameter.

    2. Engineering Semantics of the Five Core Capabilities

    When the web search tool is enabled in non-thinking mode, the model can autonomously decide whether to run a web or image search based on the user’s question, and it attaches citation sources in the answer. Two engineering points matter: first, “autonomous decision” means the number of calls is unpredictable, so you need to set an upper limit; second, citation sources must be returned faithfully, otherwise users cannot verify them and product credibility drops quickly.

    In thinking mode, the model can repeatedly go online and read links during multi-step reasoning, using retrieval results as intermediate evidence to move forward. This is a shift from “one search, one answer” to iterative retrieval. It suits complex questions that need cross-validation, at the cost of significantly higher latency and tool call volume.

    2.3 File Input

    Common formats such as documents and images are supported. The model can perform plain text extraction or mixed text-and-image parsing, and the result is added to the conversation context. The key design here is the context budget: long documents must be chunked first and then retrieved on demand, rather than being stuffed in whole.

    When the link-reading tool is enabled, the model can recognize URLs in messages, fetch the main content, and answer in context. You additionally need to handle main-content extraction quality, dynamically rendered pages, and fallback wording when fetching fails.

    2.5 Model Safety

    Developers can enable a safety check parameter to run basic risk-control review on inputs and outputs, returning a refusal flag when a risk is hit. This is an attempt to move risk control forward from “rules the application writes itself” to the platform side.

    3. Putting a Tool-Calling Architecture into Practice

    It is recommended to split the application into four layers: an access layer (sessions and authentication), an orchestration layer (tool selection and parameter assembly), a tool layer (retrieval, crawling, recognition, synthesis), and a governance layer (quotas, logs, auditing). Illustrative code:

    1. # Illustrates call shape only; not any vendor's real API
    2. resp = client.chat.completions.create(
    3. model="<model_name>",
    4. messages=[{"role": "user", "content": user_input}],
    5. tools=[
    6. {"type": "web_search", "max_calls": 3},
    7. {"type": "read_url"},
    8. ],
    9. extra_body={"safety_check": True},
    10. )

    Three things must be added in engineering: timeouts and retries for tool calls, failure fallback (clearly telling the user when retrieval is unavailable instead of fabricating), and full-chain logging (recording the input summary and duration of each tool call). Without these, production issues are nearly impossible to locate.

    4. Cost Structure and Optimization

    These capabilities are typically billed in two parts: model token fees plus tool call fees, with the tool side settled by actual call type and usage. Effective cost optimization measures include: setting hard limits on tool calls; caching results for high-frequency questions; restricting deep-thinking search to high-value scenarios; using a small-parameter model for intent routing and escalating only when necessary; and summarizing and compressing file parsing results before adding them to context. Tracking “tool calls per session” and “average time per question” as core dashboard metrics reflects real cost better than looking at token consumption alone.

    5. Compliance Obligations for External Services

    If the application serves the public, enabling safety checks alone is not enough. Developers must also fulfill obligations such as content safety review, registration and filing related to large models, and generated-content labeling, and must retain traceable logs. It is recommended to make the “refusal flag” an explicit state rather than an exception in the architecture, so the frontend can show a compliance notice accordingly and avoid treating risk-control results as program errors.

    6. Conclusion

    Opening up application-layer APIs shifts the focus of competition from “can it be built” to “is it reliable, compliant, and economical.” For developers, the real moat lies in accumulated orchestration strategy, evaluation systems, and governance capabilities. If you use Baidu AI Cloud’s general-purpose capabilities (such as object storage, message queues, log services, and monitoring and alerting) to carry the tool layer and governance layer, this architecture can reach production-grade stability faster.