Building a Complete Conversational App Quickly with Application-Level APIs
This article explains how application-level APIs move search, web fetching, file parsing, OCR, speech services, and safety checks into server-side orchestration. It covers the engineering work that remains for developers, and how to design capability switches, architecture, context management, cost controls, and security practices for a conversational app.
Building a conversational app that looked complete used to mean more than calling a model inference API. Developers also had to integrate search engines, web crawling, document parsing, OCR, speech recognition, speech synthesis, and content safety services. The hard part was not any single call but the orchestration between these tools: when to trigger search, how to insert retrieved results into the context, how to degrade gracefully when file parsing fails, how to preserve citation sources, and how to attribute tool call costs. The application-level API capabilities that the platform has recently opened move this “glue layer” work to the server side, so developers can focus more on product logic, interaction experience, and business workflows.
It is important to note that an application-level API does not mean zero engineering work. It lowers the barrier to integrating core capabilities and assembling context, but developers remain responsible for quota management, cost control, security and compliance, observability, and exception handling. The sections below cover capability breakdown, recommended architecture, call flow, cost governance, and security practices.
1. From Model APIs to Application-Level APIs: Changes in Capability Boundaries
In the traditional model, developers typically had to maintain a pipeline like this: user input, intent recognition, search service, web page fetching, document parsing, context trimming, model generation, and safety review. Each step could introduce a separate provider, separate billing, separate timeout policies, and separate error codes. The value of application-level APIs is that they package capabilities such as web search, deep thinking search, file input, link reading, and safety checks as switchable extensions. The server then handles tool invocation and context assembly.
This does not mean developers can ignore the details. Application-level APIs are usually billed as model token fees plus tool call fees. More tool calls, more complex file parsing, and longer voice pipelines all increase cost. Developers should therefore treat capability switches as part of product strategy rather than enabling everything by default.
2. Core Capabilities and How to Combine Them
1. Web Search: Automatic Retrieval for Time-Sensitive Questions
When web search is enabled in non-thinking mode, the model can automatically run web or image searches based on the user’s question and attach citation sources to its answer. It suits time-sensitive topics such as news, prices, policies, and real-time information. From an engineering standpoint, three points matter. First, store search results in a structured form that keeps at least the title, summary, link, fetch time, and cited snippet. Second, make citations traceable so that every citation can be located. Third, trigger search by policy rather than for every question, because searching everything increases both latency and cost.
2. Deep Thinking Search: Autonomous Retrieval During Multi-Step Reasoning
Search in thinking mode focuses on searching the web autonomously during multi-step reasoning, reading links, and combining the retrieved results to produce an answer. It suits complex analysis, solution comparison, and long-chain problem decomposition. Compared with regular search, deep thinking search may make more calls and consume more tokens. Developers should set a maximum number of reasoning steps, a maximum number of retrievals, and a timeout. They should also offer an explicit switch between fast mode and deep mode so users can choose their own trade-off between latency and cost.
3. File Input: Injecting Documents and Images into Context
File input supports common office documents, PDFs, images, and other formats. It can extract plain text or parse mixed image and text content, then add the result to the conversation context. In practice, file parsing should be asynchronous. After upload, the service returns a task ID, and the conversation continues once parsing completes. Teams should also enforce a file type allowlist, size limits, sensitive information masking, and caching of parsing results. For mixed image and text content, preserve layout structure or paragraph order so that parsing does not break the meaning.
4. Link Reading: Automatically Identifying and Fetching Web Content
With link reading enabled, the model detects web links in the user’s message, fetches the page content, and answers using that content together with the conversation context. Security boundaries need special attention. Server-side fetching should block access to internal network addresses, apply a domain allowlist or blocklist, and set timeouts and maximum response sizes to prevent abuse through malicious links. Fetched content should go through main content extraction and noise filtering, and retain source information so that answers can cite it.
5. Safety Checks: Input and Output Moderation with Refusal Flags
Developers can enable the safety check parameter to run basic content moderation on model inputs and outputs. When a risk is detected, the response includes a refusal flag. For apps serving external users, safety checks should be enabled. Developers should also meet their content safety review obligations and any other compliance requirements that apply in their jurisdiction, such as model registration or AI content labeling. Safety checks are not a set-and-forget feature. Teams should configure review policies that fit their business scenario, and provide a manual review path and audit logs.
6. Standalone Tool APIs: Supporting Non-Conversational Workflows
Beyond conversational features, search, web fetching, OCR, speech recognition, and speech synthesis can be called individually or combined. Developers can reuse the same capabilities in non-conversational scenarios such as document processing pipelines, voice customer service, content moderation, and knowledge base construction. It is recommended to build a tool registry within the application that manages each tool’s capabilities, quotas, timeouts, retries, and billing tags in one place.
3. Recommended Architecture: Separating the Control Plane from the Data Plane
To balance flexibility and maintainability, split the system into a control plane and a data plane. The control plane manages capability switches, tenant quotas, routing policies, safety policies, auditing, and cost attribution. The data plane handles session context, file parsing, retrieval and fetching, model inference, and tool calls. With this separation, product teams can adjust policies such as whether search is on by default, whether deep mode is available, or the maximum number of pages parsed per file, without changing the core pipeline.
Context management is another key point. Retrieved snippets, file parsing results, and linked page content should not be added to the context without limit. Apply summarization, deduplication, ranking, and token budget trimming. It is recommended to keep original quoted snippets with source metadata, compress long documents into segment summaries, and maintain an updatable conversation summary across turns.
4. Abstract Call Flow and Pseudocode
The following pseudocode only illustrates how an application-level API can be orchestrated. The function and parameter names are abstract examples and do not represent the interface definitions of any specific platform.
def handle_chat(req):session = load_session(req.session_id)ctx = build_context(session.messages, req.user_input)if req.files:parsed = parse_files(req.files, mode=req.parse_mode) # plain text or mixed image-text parsingctx += parsed.to_context()if req.links:pages = read_links(req.links, timeout=req.timeout)ctx += pages.to_context()plan = decide_plan(query=req.user_input,enable_search=req.enable_search,enable_thinking=req.enable_thinking,max_steps=req.max_steps)if plan.need_search:for step in plan.steps:hits = search(step.query)ctx += read_pages(hits, max_items=step.max_items)answer = generate(ctx, safety_check=req.safety)return answer
In a real implementation, add tool registration and policy configuration. For example, declare each tool’s timeout, retry count, caching strategy, and billing tag. For apps serving external users, run safety checks on both input and output, and record audit information for refusal results.
5. Billing and Cost Governance: Turning Capability Switches into Product Strategy
Application-level APIs are usually billed as model token fees plus tool call fees, with tool fees calculated from the tools actually called and their usage. Cost governance can start in five areas. First, set budgets and quotas at the tenant, user, and session levels. Second, cache and reuse search results, linked page content, and file parsing results. Third, distinguish fast mode from deep mode, and limit the maximum number of reasoning steps and retrievals. Fourth, trigger file parsing on demand so that files are not re-parsed in every conversation. Fifth, build a cost attribution dashboard that tracks call volume and fees by capability, tool, and tenant.
6. Security, Compliance, and Engineering Quality
Apps serving external users should enable safety checks and implement content safety review. They should also meet any applicable requirements, such as model registration and AI content labeling, depending on the jurisdiction. From an engineering standpoint, implement input masking, output filtering, citation traceability, and audit logs. Prevent link fetching from reaching internal networks, and block malicious redirects. Apply file type validation, virus scanning, and isolated execution to file parsing. Set rate limiting, circuit breaking, timeouts, and idempotency keys for tool calls.
When deployed on Baidu
