Build an AI Assistant with Full-Stack APIs: A Practical Developer Guide

    This article explains how to use separately callable LLM capabilities—web search, deep reasoning with search, file parsing, URL reading, and safety checks—to build an AI assistant. It covers when to use each tool, how to combine them through a unified message format, how to estimate token and tool costs, what compliance work to address before launch, and a five-step path for a document Q&A assistant.

    What These APIs Can Do

    After large language models expanded from pure text chat to multimodal interaction, the focus of application development shifted accordingly. A major LLM provider recently separated web search, deep thinking, file parsing, and link reading—capabilities previously available only inside its official app—into individually callable APIs. Developers do not need to train models or maintain retrieval systems themselves. By passing parameters and handling returned results according to the documentation, they can build an assistant with baseline capabilities.

    This approach saves integration work, but it does not automatically produce a product ready to launch. Actual efficiency depends on the complexity of the business scenario, the team’s familiarity with the APIs, and investment in testing and operations. The sections below explain the boundaries of each capability so readers can choose what they need.

    What Each Tool Solves

    The table compares appropriate and inappropriate scenarios for each capability:

    Capability Problem it solves Not suitable for
    Web search Answering questions about real-time news, prices, and policy changes Mathematical derivation, general historical knowledge
    Deep reasoning with search Multi-source comparison and research requiring multi-step reasoning Simple Q&A that is sensitive to latency
    File parsing Extracting content from PDF, Office, and image files Files with poor scan quality or extremely complex layouts
    URL reading Reading the body of a URL included in a user message Pages that require login or have access restrictions
    Safety checks Basic content risk control for input and output Replacing a complete compliance process

    Web search is triggered on demand. The model decides whether retrieval is needed based on the question. Questions that do not require web access are answered with built-in knowledge, which reduces latency and avoids irrelevant information. Answers usually include cited sources, and the frontend can display these sources so users can verify them.

    Deep reasoning with search is suitable for comparative analysis questions. The model proposes hypotheses, retrieves and verifies information, corrects its direction, performs supplementary retrieval, and finally synthesizes a conclusion. This process takes longer and costs more, so it is only suitable for scenarios that genuinely require multi-step reasoning.

    File parsing falls into two categories. Plain text extraction is suitable for scenarios that need to quote the original text. Mixed text-and-image parsing can recognize tables, flowcharts, and chart annotations, making it suitable for tasks such as contract review and report interpretation. Medical, legal, and financial files often contain sensitive information, so before integration you need to confirm the file retention period and de-identification approach.

    The URL reading tool automatically fetches the main content of a web page and filters out noise, so developers do not need to maintain HTML parsing logic. However, two issues still need to be handled. First, a website’s terms of use and copyright rules may restrict reuse of its content. Second, some sites have access restrictions, and calls will fail. It is advisable to maintain an allowlist of domains and design a fallback for failures.

    How to Combine Capabilities into a Usable Assistant

    APIs pass data through a unified message format, so capabilities can be combined according to business needs. A customer service assistant can enable only web search and safety checks. A document analysis tool can combine file parsing with deep reasoning. A voice assistant can add speech recognition and speech synthesis on top of that. When adding new capabilities, existing business logic usually does not need to change.

    The code below shows the invocation approach. It is not a real runnable example. SDK names, parameter fields, and model IDs should follow the vendor documentation; placeholders are used here:

    1. # Non-runnable example: shows how to organize tool switches
    2. # Class names, SDK versions, authentication, and fields depend on vendor documentation
    3. client = create_client(api_key=os.environ["LLM_API_KEY"]) # read key from environment variable
    4. response = client.chat.completions.create(
    5. model="<model ID from vendor documentation>",
    6. messages=[{"role": "user", "content": user_question}],
    7. tools=[
    8. {"type": "web_search", "max_results": 5},
    9. {"type": "read_url", "allowed_domains": ["example.com"]},
    10. ],
    11. )

    Keep several points in mind when writing code. API keys should be stored in environment variables or a secret management service, not written into code or logs. Tool parameter names may change between versions, so verify the current documentation before launch. When a request fails, distinguish authentication failures, rate limiting, and parameter errors by error code, and handle each separately.

    How to Estimate Costs

    Total cost consists of three parts: token costs for model inference, invocation fees for each tool, and possible speech synthesis fees. The cost of a single Q&A request can be estimated with the following formula:

    Single cost = input tokens × input unit price + output tokens × output unit price + search count × search unit price + parsed pages × per-page parsing unit price

    For example, assume 1,000 input tokens, 800 output tokens, 2 searches, and 1 parsed file page. If the input price is CNY 0.001 per thousand tokens, the output price is CNY 0.002 per thousand tokens, the search price is CNY 0.01 per search, and the parsing price is CNY 0.02 per page, then the single cost is: 1 × 0.001 + 0.8 × 0.002 + 2 × 0.01 + 1 × 0.02 = CNY 0.0426. These unit prices are only for demonstrating the calculation method; actual numbers follow the official price list.

    For public free applications, it is advisable to set budget controls at the request entry point. Common practices include setting a daily maximum number of searches, prioritizing cached or built-in knowledge answers for high-frequency questions with stable answers, and regularly reconciling bills.

    Compliance Work Before Launch

    Safety-check parameters provide basic risk control for input and output, and return a refusal flag when risky content is detected. Enabling this parameter is part of compliance work, but it is not compliance by itself.

    If you offer generative AI services to the public, your application will generally need to meet requirements such as the following. Check the applicable regulations and guidance from the relevant authorities in your target market:

    • Complete filing or registration for generative AI services or models where required.
    • Add explicit or implicit AI-generated labels to generated content as required.
    • Establish content filtering. Beyond platform risk controls, design your own review rules for your business.
    • Provide user complaint and reporting channels, and define response time limits and handling processes.
    • Define the scope and retention period of logs and restrict access permissions.
    • Explain how user-uploaded files are handled, including retention duration, deletion mechanisms, and whether they are used for model training.
    • When processing personal information, improve the privacy policy and obtain user authorization.

    These items should be confirmed by legal and product teams. This article cannot replace professional compliance review.

    Hands-On: Development Path for a Document Q&A Assistant

    Take “upload a document, interpret the content, supplement with search, and provide voice playback” as an example. The development process can be divided into five steps.

    1. Upload module: accept PDF, Word, and image files, call the file parsing API, and store the result temporarily in the current session context. Before parsing, check file size and page limits; reject files that exceed the limits and prompt the user.
    2. Question handling: place the user question and parsed document content into the message sequence. If the document is too long, segment or summarize it first to avoid exceeding the context length.
    3. Tool routing: if the question involves real-time information such as prices, policies, or news, attach web search parameters; otherwise, use only the base model. Routing rules can start with keywords and then be adjusted gradually based on logs.
    4. Response generation: the model synthesizes the document content and search results to generate an answer. The frontend should display cited sources. If search fails, indicate that the answer is based only on the document content.
    5. Voice extension: when the user clicks the playback button, send the text to the speech synthesis API and return the audio stream.

    Every step needs timeout and failure fallback settings. For example, if search times out, the assistant can answer based only on the document and note on the page that the latest information was not retrieved.

    FAQ

    How should I choose a tool combination?
    First list the types of questions the business needs to answer. If real-time information is needed, enable web search. If user-uploaded files need to be read, enable file parsing. If multi-step reasoning is needed, consider deep reasoning. Do not enable capabilities you do not use; this saves cost and reduces possible failure points.

    How can I control invocation costs?
    Set daily invocation limits, cache repeated questions, and include search counts in monitoring metrics. In the early stage after launch, reconcile bills weekly, compare estimated costs with actual costs, and identify the areas with the largest deviations.

    What are common errors?
    Authentication failures are often caused by an incorrect key or environment variables not being loaded. Parameter errors are usually caused by tool field names not matching the current documentation. When search results are empty, check whether the query is too long or too colloquial. When URL reading fails, first confirm whether the domain is in the allowlist and whether the target page requires login.

    Can I launch after enabling safety checks?
    No. Safety checks are only one layer of risk control. Filing or registration, AI-generated labels, complaint response, and data retention must be completed before launch.

    Conclusion

    Full-stack APIs do lower the integration barrier for AI assistants, and ordinary frontend engineers can build a prototype. But between a prototype and a production product, cost control, compliance review, and effect evaluation are still required. Readers can first use the capability table and cost formula in this article to assess their needs, and then validate the effect with small-scale tests. This is more reliable than pursuing complete functionality from the start.