How to Add Web Search and Multimodal Capabilities to LLM Apps with a Unified API

    This article explains how application-level LLM APIs can expose hosted web search, URL fetching, file and OCR input, speech capabilities, and safety moderation through parameterized requests. It covers the capability scope, integration with mainstream chat protocols, the server-side execution model compared with traditional function calling, cost estimation, and production best practices.

    1. Background: From Model APIs to Application-Level APIs

    Over the past few years, the mainstream way for developers to integrate large models has been to call a basic chat completion endpoint: pass in a conversation history, and the model returns text. But building a genuinely useful conversational application requires far more than the model itself. A series of engineering problems still need to be solved:

    • When users ask time-sensitive questions, the model cannot answer with content after its knowledge cutoff, so web search is needed.
    • When users paste a link and expect the model to summarize it, web page fetching and main-content extraction are needed.
    • When users upload images or documents, preprocessing such as OCR and file parsing is needed.
    • For voice interaction scenarios, speech recognition (ASR) and text-to-speech (TTS) are needed.

    In the past, developers usually had to integrate multiple third-party services themselves and maintain the full chain of “intent recognition → tool invocation → result assembly → generation.” This involved significant engineering effort and many failure points.

    A recent industry trend is that model providers are opening up tool capabilities that have already been refined inside their own applications directly as APIs. Developers only need to add one or two parameters to the original request, and the server automatically performs actions such as searching, reading web pages, and injecting results into the context. Some observers suggest that with these capabilities, developers can reproduce a fully featured conversational application almost 1:1. This article examines the integration methods and practical considerations for this kind of “all-in-one” API from a general technical perspective.

    2. Capability Overview: What a Unified API Typically Includes

    Using the general capability set discussed here as an example, these APIs can be grouped into the following categories:

    1. Web Search

    The model automatically triggers search when it determines that search is needed, and the retrieved results participate in generation as context. The key value lies in “server-side hosting”: developers do not need to implement search intent recognition or manage relevance filtering of search results. Everything is handled by the server within the inference workflow.

    2. URL Fetch / Web Page Reading

    After a URL is passed in, the server fetches the page, extracts the main content, and injects it into the context. Compared with writing a crawler yourself, this approach usually handles anti-crawling, main-content extraction, encoding, and other messy work, and it is adapted to the model’s context length.

    3. File Input and OCR

    It supports uploading documents, images, and other files. The server completes parsing, including text recognition in images, and converts the content into a text representation that the model can understand. This significantly lowers the barrier to integrating multimodal input.

    4. Speech Input and Playback

    This covers both ASR and TTS. A typical scenario is transcription of long recordings lasting around an hour. Billing is usually based on recording duration, and the price is far lower than manual transcription. Limited-time discounts are also a common strategy during the promotion period for new capabilities.

    5. Safety Moderation

    Content safety is provided as a built-in capability, performing compliance checks on input and output. For consumer-facing applications, this is actually an easily overlooked but critical component.

    3. Integration: Low-Intrusion Parameterized Design

    The biggest highlight of this type of API design is compatibility with mainstream protocols. The industry’s common chat interface specifications, such as the Chat Completions style and the Messages style, can mostly be adapted directly. With a unified model name, migration cost is low.

    Taking the widely used Python SDK as an example, the integration flow is roughly as follows:

    Step 1: Obtain credentials

    Create an API key in the corresponding open platform console and keep it secure. It is recommended to inject it through environment variables rather than hard-coding it.

    Step 2: Declare tools

    Add a tools parameter to the original chat request to declare the required tools, such as web search and URL reading:

    1. import os
    2. from openai import OpenAI
    3. client = OpenAI(
    4. api_key=os.getenv("MODEL_API_KEY"),
    5. base_url="https://your-platform-compatible-endpoint/v1",
    6. )
    7. resp = client.chat.completions.create(
    8. model="target-model-name",
    9. messages=[
    10. {"role": "user", "content": "Find the industry updates from the past week and summarize the key points"}
    11. ],
    12. tools=[
    13. {"type": "web_search"}, # Web search
    14. {"type": "read_url"}, # URL reading
    15. ],
    16. )
    17. print(resp.choices[0].message.content)

    Step 3: Understand the execution model

    The biggest difference from traditional Function Calling is this: in the traditional approach, the model returns a tool-call intent, and the developer executes the tool and feeds the result back. With this kind of hosted tool, the server executes automatically—search, fetching, context assembly, and generation again are all completed within a single request. What the developer receives is the final answer.

    This design brings three engineering benefits:

    1. Shorter chain: It removes the multi-round round trip of “model → developer → tool → model,” resulting in lower latency.
    2. Simpler state: There is no need to maintain structured parsing and backfilling of intermediate results.
    3. Built-in fault tolerance: Exceptions such as search failures and unreachable pages are handled by the server. Developers do not need to write retry logic for every tool failure.

    4. Pricing Model: Token + Per-Call Cost Estimation

    Pricing for this kind of all-in-one API usually consists of two parts:

    • Model inference: Billed by token, with different unit prices for input and output. Many providers offer half-price rates during off-peak hours, such as non-peak periods on weekdays, which is suitable for scheduling batch jobs outside peak hours.
    • Tool calls: Billed per call. For example, search and web page fetching may have a per-thousand-call price. Speech capabilities are billed by recording duration, with prices significantly lower than traditional transcription services, and new capabilities often have discount periods.

    Advice for developers:

    1. First estimate the tool trigger rate per conversation. Not every conversation turn triggers search. You can sample online traffic to measure the actual proportion of tool calls, then multiply by the unit price to estimate marginal cost.
    2. Use off-peak half-price rates. Run non-real-time tasks such as offline summarization and knowledge base preprocessing during low-peak hours, which can nearly halve costs.
    3. Set usage alerts. “Automatic triggering” of hosted tools means the number of calls is not fully controllable. Be sure to configure usage limits and alerts on the platform side to prevent abnormal traffic from causing runaway costs.

    5. Practical Recommendations and Caveats

    Based on general engineering experience, here are several recommendations for implementation:

    • Declare tools conservatively: Only declare tools that the business truly needs. The more tools declared, the more room the model has to choose among tools, which may lead to unnecessary calls and increase cost and latency.
    • Context management: Search results occupy the context window. In long conversations, pay attention to trimming historical messages so that useful content is not pushed out of the window.
    • Pre-validate file inputs: Although parsing is server-side, client-side pre-checks for file size, format, and sensitive content are still essential to reduce invalid calls.
    • Do not disable safety moderation: Public-facing applications should retain built-in moderation capabilities, understand their blocking policies, and design user prompts and fallback experiences for blocked cases.
    • Observability: Even though tool execution happens on the server, the application side should still record token consumption, tool triggers, and latency distribution for each request to support cost attribution and performance optimization.

    6. Conclusion

    The opening of “all-in-one” application APIs marks a shift in large-model integration from “giving you a brain” to “giving you a complete application runtime.” For developers, this means that building a conversational application with search, multimodal, and voice interaction capabilities is simplified from integrating N services and maintaining a complex call chain to “one request and a few parameters.” The real technical point is not how many tools are integrated, but understanding the execution model of hosted tools, reasonably controlling trigger frequency and cost, and establishing a complete observability and safety system. Developers are advised to validate cost and quality under low traffic before gradually scaling to production.