LLM Tool Chain APIs: Web Search at About $5 per 1,000 Calls

    This article explains how exposing web search, page reading, file parsing, OCR, speech recognition, and speech synthesis as APIs changes how LLM applications are built. It breaks down what each tool capability does, shows why a low per-call price does not equal a low total cost once token usage and retries are included, and outlines a three-layer reference architecture for a low-cost news assistant. It also covers onboarding steps, engineering practices such as caching and graceful degradation, and common mistakes to avoid.

    1. The Shift: From Chatting to Getting Work Done

    Over the past two years, most LLM applications have taken the form of a conversation: the user asks, the model answers. But when an application has to solve a real business problem, text generation alone is not enough. Real tasks usually require getting information first, understanding the material next, and producing a conclusion last, which means the model needs the ability to call external tools.

    A new way of opening up these capabilities has recently appeared in the industry: web search, web page reading, file parsing, OCR text recognition, speech recognition, and speech synthesis are now offered as APIs alongside dialogue and reasoning capabilities. The fundamental change is that developers no longer need to maintain their own “collect, parse, clean, feed to the model” pipeline. They can hand those stages to the platform and let it handle them centrally.

    This is especially friendly to small and mid-sized teams. Building a usable news assistant used to require at least three pieces of engineering: search service integration, web page text extraction, and LLM call orchestration. Each piece carried hidden costs, such as changing anti-scraping strategies, text extraction rules that stop working, and inconsistent formats across data sources. Tool chain APIs pull these volatile parts into the platform, leaving developers with only their business logic.

    2. What Each of the Six Tools Does

    Solves the problem of stale model knowledge. Model weights are static, while news, prices, and policy information are dynamic. A web search API typically returns structured results such as titles, summaries, and links, which makes it suitable as the retrieval layer for retrieval-augmented generation.

    2. Web Page Reading

    Search only provides leads; web page reading turns those leads into usable text. It has to deal with noise such as navigation bars, ads, and recommendation slots, and output a relatively clean body text field. In engineering terms, it is advisable to keep the original link so the source can be traced later and compliance reviews can be carried out.

    3. File Parsing

    In enterprise settings, a large amount of knowledge lives inside documents. File parsing converts formatted files into structured text, preserving heading levels, tables, and list relationships as much as possible, which provides the basis for later chunking and vectorization.

    4. OCR Text Recognition

    Aimed at scanned documents, image-based documents, and screenshots. Recognition results usually need to be combined with layout restoration; otherwise tables and multi-column layouts get scrambled easily. Billing is generally per page, which makes it easy to estimate cost by batch.

    5. Speech Recognition

    Converts audio into text, commonly used for meeting notes, customer service quality inspection, and voice commands. Billing is based on duration. For long audio, it is recommended to segment first and trim silence so you do not pay for useless duration.

    6. Speech Synthesis

    Converts text into audio for broadcasts, accessible reading, and voice assistant feedback. Pay attention to speaking rate, voice consistency, and how continuous the listening experience is when long text is split and stitched together.

    3. Cost Structure: Why “5 per 1,000 Calls” Is Not a Total Cost of 5

    The prices in the original information are representative: web search at about 5 CNY per 1,000 calls, OCR at about 1.5 CNY per 1,000 pages, and speech recognition at about 0.39 CNY per hour (limited-time discount). The key point is that these are only tool call fees. Token fees for model inference have to be calculated separately.

    A practical formula looks like this:

    1. cost per task ≈ tool call fees + input token fees + output token fees + retry overhead

    Retry overhead is often overlooked. Unstable search result quality, failed page parsing, and low OCR confidence all trigger retries, so actual call volume may be 1.2 to 1.5 times the theoretical value. It is advisable to add caching and deduplication in the architecture: reuse results for the same query within a set time window, and deduplicate the same document by content hash.

    4. Reference Architecture: How to Build a Low-Cost News Assistant

    A three-layer structure of “orchestration layer + tool layer + model layer” is recommended. The orchestration layer handles flow control and failure fallback, the tool layer wraps the various APIs, and the model layer focuses on understanding and generation.

    1. # Illustrative code: no specific vendor API names included
    2. def build_news_assistant(query, top_k=5):
    3. # 1. Retrieval
    4. results = search_api(query, top_k=top_k)
    5. # 2. Body text extraction; skip on failure instead of aborting
    6. docs = []
    7. for item in results:
    8. text = read_webpage(item.url)
    9. if text and len(text) > 200:
    10. docs.append({"url": item.url, "text": text[:4000]})
    11. # 3. Assemble context and control length to constrain token cost
    12. context = "\n\n".join(f"[{d['url']}]\n{d['text']}" for d in docs)
    13. # 4. Generate an answer and require source links
    14. prompt = f"Answer the question based on the material below and cite the source links:\n{context}\n\nQuestion: {query}"
    15. return chat_model(prompt)

    There are three design points. First, handle failures item by item, so one failed page does not affect the whole run. Second, truncate length to keep the context within budget. Third, enforce traceability, so the output must carry links and can be verified manually.

    5. Onboarding Steps and Engineering Advice

    1. Request credentials: create a key in the console and assign it by the principle of least privilege, avoiding direct exposure in the frontend.
    2. Wrap uniformly: consolidate the six capabilities into a single client that hides parameter differences, making it easier to swap implementations later.
    3. Go asynchronous: file parsing and speech recognition are long-running tasks, so a submit-then-poll or callback model is recommended.
    4. Observability: record latency, status codes, and billing dimensions for every call, connect to a logging service and monitoring alerts, and set a daily budget threshold.
    5. Caching strategy: cache search results for a short period, and cache parsing results long term by content hash.
    6. Fallback plan: when a tool is unavailable, degrade to a pure model answer and clearly tell the user the information may be incomplete.

    6. Common Mistakes

    • Mistake one: treating tool fees as the total cost. Ignoring tokens and retries makes the budget significantly inaccurate.
    • Mistake two: stuffing the entire source text into the model. The longer the context, the higher the cost and latency, so extract key passages first.
    • Mistake three: ignoring compliance. Scraped content requires attention to copyright and robots conventions, and user data must be desensitized before being sent to external services.
    • Mistake four: calling all tools synchronously at once. Long tasks should be asynchronous to avoid request timeouts and thread pile-up.

    7. Closing Thoughts

    The point of tool chain APIs is not that a particular interface is cheap, but that volatile and fragile engineering stages become standardized. Developers can then focus their energy on prompt design, evaluation systems, and closing the business loop. If an organization already uses Baidu AI Cloud capabilities, the same architectural thinking applies: with unified object storage, message queues, and monitoring and alerting services, you can build an application system with controllable cost, observability, and graceful degradation.