From Model APIs to Capability APIs: A Technical Guide to Building LLM Applications

    This article explains how LLM integration is shifting from raw model APIs to server-side capability APIs, where tools such as web search and URL reading are merged into a single inference call. It covers the architectural impact of moving orchestration from the client to the server, protocol compatibility, the requirement to pass content blocks back unchanged, and how server-side sampling changes affect output control. It also provides practical guidance on file parsing modes under per-page billing, engineering considerations for voice and multimodal pipelines, and a deployment checklist for latency, observability, cost, and fallback behavior.

    1. The Shift: From Model APIs to Capability APIs

    Over the past two years, the primary way developers integrated LLMs was to send a prompt and some context to an inference endpoint, then parse the returned text. Any requirement involving web access, reading pages, parsing attachments, or voice interaction meant building a full processing pipeline in the client or a middle layer: calling a search service, fetching pages, extracting main content, cleaning and truncating it, and stitching it back into the context. This pipeline looks simple, but in practice it involves a great deal of tedious engineering: unstable search recall quality, wildly varying page structures, content extraction rules that need constant maintenance, compressing overly long content, and aligning citation sources with the answer.

    The direction of recent technical evolution is clear: push these “peripheral capabilities” down to the server side and merge them into a single call with model inference, in the form of tools. The client no longer worries about whether to search, how many rounds to search, or which links to fetch. It only sends the user’s question, and the model autonomously decides the tool call sequence and returns results with source citations. The impact of this change on application architecture is far greater than “writing a few hundred fewer lines of code.” It changes the cost structure, failure boundaries, and the division of responsibilities on the frontend.

    One thing to note in advance: these capabilities are usually opened up on specific model specifications first, and other specifications may not follow at the same time. When selecting a model, developers should refer to the current support matrix in the official documentation rather than designing an architecture based on hearsay.

    2. Architectural Changes from Server-Side Tooling

    2.1 Responsibility Shifts from Client to Server

    In the traditional approach, retrieval augmentation was the client’s responsibility: first determine intent, then decide whether to retrieve, then manage multiple rounds of supplementary queries. After server-side tooling, this orchestration logic converges on the model side. Take a question like “compare the heights of two landmark buildings.” The model first performs a general search, then opens an authoritative page to read the specific values. If the information is incomplete, it switches keywords and continues searching within the page. The entire chain may trigger more than ten consecutive tool calls before producing a conclusion.

    For developers, this means two things. First, the distribution of time-to-first-byte changes: the total time for complex queries is mainly determined by the number of server-side tool rounds. Second, observability weakens: the client can only see the final tool result blocks, and intermediate failures and retries are invisible. Therefore, logging and tracing design must be adjusted accordingly, persisting the complete intermediate blocks returned by the server rather than only recording the final answer.

    2.2 Protocol Compatibility Lowers the Integration Barrier

    The mainstream message protocols (role-based message lists, structured responses with content block arrays, and a compatible chat completion format) can usually be integrated directly, so developers do not need to rewrite business code for different protocols. Mounting two typical tools covers most scenarios: one handles web and image search, and one reads user-provided links.

    A schematic request structure is shown below (it only expresses structure and does not represent any specific API):

    1. {
    2. "model": "<model identifier supported by the server>",
    3. "messages": [
    4. {"role": "user", "content": "Look up the latest public specifications of a product and provide sources"}
    5. ],
    6. "tools": ["web_search", "read_url"],
    7. "stream": true
    8. }

    2.3 Content Blocks Must Be Passed Back As-Is

    This is the easiest pitfall to fall into. The thinking blocks, search result blocks, and page fetch blocks returned by the server must be passed back in their original structure in the next request. If a self-built gateway filters out these blocks with the good intention of “saving tokens,” the request will still return successfully, but the model will “lose its memory”—it cannot see the pages it read in the previous round and can only search again or fabricate. The engineering practice is to treat the content blocks returned by the server as immutable data: store and replay them as-is, and any trimming strategy must be explicitly configured and disabled by default.

    2.4 Sampling Parameters Are Taken Over by the Server

    Once tool calls are enabled, automatic conversation titles are generated, or a higher security level is activated, the sampling pace is usually taken over by the server, and explicitly set parameters such as temperature and top_p in the request may be ignored. This means strategies that rely on tuning parameters to control output style will fail. A viable alternative is to constrain the output format and tone through prompts, writing style requirements into system instructions; and to split scenarios that require precise control (such as structured extraction) from scenarios that require tools into two calls—the former without tools, the latter accepting default sampling.

    3. File Parsing: Choosing a Mode Under Per-Page Billing

    Document and image inputs are generally billed per page and offer two modes: plain text extraction and parsing with layout recognition. The difference between the two is critical in real business scenarios. Take a financial report as an example. Plain text mode discards the revenue trend chart, and the model cannot see any graphical information, so questions about the chart can only get vague answers. Layout recognition mode crops out image regions and inserts them back at the corresponding positions in the text, giving the model the ability to read images.

    The selection recommendations can be summarized in three points:

    • Use plain text mode to control costs when you only need to search text clauses, contract terms, or log text;
    • Layout recognition must be enabled when you need to understand the layout relationships of charts, flowcharts, or scanned documents;
    • For very long documents, first segment and summarize before entering question answering, to avoid paying for ineffective pages.

    Pseudocode illustration:

    1. mode = "rich_layout" if need_chart_understanding(doc) else "plain_text"
    2. pages = split_by_budget(doc, max_pages=20)
    3. for chunk in pages:
    4. parsed = parse(chunk, mode=mode) # Billed per page; estimate before calling
    5. index.append(parsed)

    4. Engineering Essentials for Voice and Multimodal Pipelines

    Voice transcription and text-to-speech are usually mounted as independent capabilities. Three points need attention in engineering. First, audio segmentation and sentence-breaking strategies directly affect recognition accuracy; long audio should be split using silence detection. Second, recognition results need to retain timestamps to facilitate alignment with the original text for proofreading. Third, speech synthesis must coordinate with the frontend player state machine to handle interruptions, resuming playback, and speech rate adjustment. Multimodal inputs should also have unified size and duration limits, with local compression performed first when limits are exceeded, to avoid ineffective billing and timeouts.

    5. Deployment Checklist

    1. First confirm whether the target model specification supports server-side tools, to avoid architecture rework;
    2. The middle layer should pass through all content blocks by default, with trimming capability implemented as an explicit switch;
    3. Set timeouts and fallback strategies for tool rounds, falling back to a no-tool answer when retrieval fails;
    4. Choose file parsing mode based on “whether image reading is needed,” and estimate the page count cost;
    5. In scenarios where sampling parameters become ineffective, use prompts to constrain style instead;
    6. Fully record conversations and tool results for auditing and citation traceability.

    If you are integrating these capabilities into your own application, you can also look at how Baidu AI Cloud combines general capabilities such as model services, object storage, log services, and monitoring and alerting, using standard components to handle pass-through, auditing, and cost control, reducing the maintenance burden of a self-built middle layer.