How to Use LLM APIs with Web Search and File Parsing

    This guide explains how to use an all-in-one LLM API that provides web search, file parsing, voice capabilities, and safety checks on the server side. It covers the four core capabilities, how integrated APIs differ from traditional stitched-together architectures, how to get started, and what to verify before going to production.

    Building an AI application with web search, file upload, and voice features used to mean integrating a search API yourself, parsing PDFs, stitching context together, and maintaining intermediate state. Each step adds development effort, and a failure in any step can affect the entire system. One LLM platform now offers a “full-stack” set of APIs that handles these capabilities on the server side. This article explains how to enable these capabilities, how they differ from the traditional approach, and what to check before going live.

    Tool names, parameter names, pricing, and permission rules are subject to the platform’s latest official documentation. The fields shown in this article are illustrative only; verify each one before integration.

    1. Four Core Capabilities

    Traditional retrieval-augmented generation (RAG) requires developers to build and maintain their own vector database, retrieval module, and index updates. With the web search tool enabled, the model can fetch up-to-date information from the internet on demand and attach citation sources to its answers.

    The platform offers two common usage modes:

    • Web search in non-thinking mode: The model decides on its own whether it needs to search for web pages or images based on the question. Suitable for news lookups, real-time data retrieval, and similar scenarios.
    • Deep-thinking search: With the search tool enabled in thinking mode, the model can decide during multi-step reasoning when to search and when to open a specific link. Suitable for questions that require gathering information across multiple steps before reasoning, such as industry trend analysis.

    The two modes differ significantly in latency and cost. If a question only requires a single factual lookup, non-thinking mode is sufficient.

    After a user uploads a PDF, Office document, or image, the server automatically extracts plain text or parses mixed text-and-image content, then inserts the structured results into the conversation context. Developers do not need to write their own parsing service.

    With the link-reading tool enabled, the model recognizes URLs in user messages, fetches the page content, and answers in context. The client does not need to do its own crawling or cleaning. However, web page content enters the model’s context, so data boundaries require attention—see Section 7 of the original discussion for details.

    1.3 Standalone Voice Capabilities

    The platform also offers three capabilities that can be called individually or in combination:

    • OCR (optical character recognition): Converts text in images into editable text.
    • ASR (automatic speech recognition): Converts speech to text, with support for long audio.
    • TTS (text-to-speech): Converts model output into speech.

    Combined, these three enable pure voice-interaction applications, such as in-car voice assistants or voice entry points for smart hardware.

    1.4 Safety Checks

    With the safety check parameter enabled, the platform performs real-time moderation of inputs and outputs. When content triggers a risk policy, the API returns an explicit refusal indicator. Applications must handle such responses properly—for example, by showing a notice to the user and logging the event. Applications should not automatically rephrase and retry in an attempt to bypass moderation.

    The platform documentation recommends enabling this parameter for public-facing applications. Obligations such as content moderation, regulatory filings, and labeling AI-generated content remain the developer’s responsibility, subject to the regulations of your jurisdiction.

    2. Architecture Comparison: Stitched-Together Development vs. Integrated API Calls

    A traditional call chain typically looks like this:

    User client → business backend orchestration layer → external search API or object storage → document parsing service → LLM inference API → response

    The business backend has to handle routing decisions, context-length trimming, and error retries across multiple interfaces. If any step slows down, the overall response slows down.

    With an integrated API, the orchestration logic moves to the server side:

    User client → business backend → integrated LLM API (built-in search, parsing, safety moderation) → response

    The differences between the two approaches:

    Dimension Stitched-Together Development Integrated API
    Tool integration Each tool integrated and adapted separately Tool switches declared in the request
    Error handling Backend handles retries for each interface Server handles intermediate errors; the business side handles final errors
    Latency Multiple network round trips, longer chain Shorter chain; actual latency should be measured
    Maintenance cost Tool upgrades require changes in multiple places Mainly follows platform version changes
    Process control Fine-grained control over each step Intermediate steps are invisible; harder to debug

    The integrated approach is not better for every scenario. If you need precise control over retrieval scope, or if data cannot leave your internal network, stitched-together development remains the better choice.

    3. Integration Practice

    3.1 Prerequisites

    Before integrating, confirm the following:

    • Model version: Confirm the selected model supports the tool parameters you need.
    • Account permissions: Confirm the account has web search, file parsing, and other required capabilities enabled.
    • Rate limits: Confirm the requests-per-minute and concurrency limits to avoid throttling during peak hours.
    • Error codes: Prepare handling for refusals, timeouts, rate limiting, and other error codes.

    3.2 Request Example

    The following request structure enables web search and safety checks. It is pseudocode; field names must be replaced with those in the official documentation:

    1. {
    2. "model": "<model name from the official documentation>",
    3. "messages": [
    4. {
    5. "role": "user",
    6. "content": "Based on the latest industry reports, analyze this year's growth trends in the new energy vehicle market."
    7. }
    8. ],
    9. "tool_choice": "auto",
    10. "tools": [
    11. {"type": "web_search", "enable_thinking": true}
    12. ],
    13. "safety_check": true
    14. }

    Note that enable_thinking and safety_check are illustrative fields; refer to the platform documentation for the actual names.

    You can use the following table to decide whether to enable deep thinking:

    Question Type Recommended Mode Reason
    Single factual lookup, e.g., a stock price on a given day Web search in non-thinking mode One search is enough; low latency
    Multi-source comparison, e.g., comparing conclusions across reports Deep-thinking search Requires multi-step gathering and reasoning
    Internal knowledge base Q&A Do not enable web search Results should come from your own data; search only introduces noise

    3.3 Retry Strategy for Failures

    Timeout and rate-limit errors are suitable for exponential backoff retries—for example, retry after waiting 1 second, 2 seconds, then 4 seconds, up to three attempts. Refusal indicators and parameter errors should not be retried.