Integrating Built-in LLM Tools: A Guide to Web Search, Web Fetching, and Speech
This guide explains how built-in LLM tools for web search, web fetching, and speech can reduce client-side orchestration code. It compares the effort of building a custom toolchain with using platform-provided tools, lists what to verify before adoption, and covers integration details, billing estimates, and architecture practices such as intent routing, streaming, citations, and content moderation.
1. The Cost of the Traditional Approach
Building an app that can answer “What’s the weather in Shanghai today?” takes more than a model call. Developers usually need to integrate a search API, fetch the result pages, extract the main text, and insert that content into the prompt. They also have to handle timeouts, retries, and deduplication. Each step can fail, and the failure logic ends up scattered across the client.
The table below compares the effort required for each approach.
| Step | Custom Toolchain | Platform Built-in Tools |
|---|---|---|
| Search API | Apply for access and write your own wrapper | Provided by the platform, billed per call |
| Web fetching and content extraction | Write your own parsing logic | The platform returns structured content |
| Context assembly | Assemble manually on the client | Merged into the context automatically on the server |
| Timeouts and retries | Implement each one on the client | Handled by the platform, though the client still sets an overall timeout |
| Troubleshooting | Investigate across several systems | Relies on status information returned by the platform |
2. Check the Platform Documentation for Supported Capabilities
Common built-in tools include web search, web page reading, file parsing (such as text extraction from PDFs and images), speech recognition, speech synthesis, and content moderation. Coverage varies widely between platforms. Some platforms offer only search, while others provide a complete speech pipeline. Tools with the same name may differ in parameters, result formats, regional restrictions, and concurrency limits.
Before choosing a platform, confirm the following four items:
- Whether the target tool is enabled for your region and plan;
- Whether the tool’s parameter structure and model name match the documentation;
- Whether the results include source links, publication times, and text excerpts;
- What limits apply to call volume, concurrency, and file size.
3. Integration
Most platforms support the OpenAI-style Chat Completions protocol, so you can keep using the official SDK and change only the base URL and API key. The example below shows a basic call. Each platform defines how built-in tools are declared. Look up the specific fields in the platform documentation, then pass them through tools or extra_body.
import osfrom openai import OpenAIclient = OpenAI(api_key=os.environ["LLM_API_KEY"], # Read from an environment variable. Do not hard-code it in the source.base_url=os.environ["LLM_BASE_URL"], # API endpoint provided by the platform)resp = client.chat.completions.create(model=os.environ["LLM_MODEL"], # Model name provided by the platformmessages=[{"role": "user", "content": "What's the weather in Shanghai today? Is it good for going out? Keep the answer short."}],# Declare built-in tools here. Field names and structure follow the platform documentation.# extra_body={"tools": [...]},)print(resp.choices[0].message.content)
Three points need attention:
Tool execution. With traditional function calling, the client parses the tool call, runs the function, sends the result back, and makes a second request. With built-in tools, most platforms complete these steps on the server, so the client usually receives only the final answer. The response may also include tool call status or citation information. Field names and meanings vary by platform. Read the fields defined in the documentation, and set default handling for cases where a field is missing.
Deep thinking switch. Some platforms offer this parameter. When enabled, responses usually take longer but are more thorough. Disable it for real-time Q&A and enable it for analytical tasks. The parameter name is platform-specific and cannot be copied to other platforms.
Date and region information. The model does not know the current date, so words like “today” and “tomorrow” can be misinterpreted. Include the current date, time zone, and region in the system message so the model resolves relative dates correctly.
4. Billing: Token Charges and Per-Call Fees Combined
These services are typically billed in two parts. Model inference is billed by input and output tokens, and some platforms charge different unit prices at different times of day. Tool calls are generally billed per call, and search and fetching are often priced per thousand calls. Speech capabilities are billed by audio duration.
The example below estimates the cost of one weather query using hypothetical prices. These figures are for illustration only. Check the platform’s price list for actual rates.
- Input tokens: 1 CNY per million tokens;
- Output tokens: 4 CNY per million tokens;
- Search: 10 CNY per thousand calls.
Assume one query uses an average of 1,500 input tokens and 300 output tokens, and makes one search call.
- Model cost: 1500 × 1 / 1,000,000 + 300 × 4 / 1,000,000 = 0.0027 CNY
- Search cost: 10 / 1000 = 0.01 CNY
- Total per query: about 0.0127 CNY, or about 127 CNY per 10,000 queries
In this example, search accounts for the largest share of the cost. The most direct way to control costs is to skip the search tool for small-talk requests and enable it only for time-sensitive questions.
5. Architecture Essentials
1. Route tools by intent. At the gateway layer, classify each request as small talk, Q&A, document processing, or speech, and declare only the tools each category needs. Use rules wherever they can determine the category, so the classification step does not add latency or cost of its own.
2. Streaming output and progress indicators. Tool execution adds wait time. Enable streaming output, and when the platform returns tool execution events, show status messages such as “Searching…” or “Reading web page…” in the interface. The client should also set an overall timeout, for example 30 seconds, and return the content already received or a friendly message when the timeout is reached. For retryable errors, use exponential backoff: wait 1 second before the first retry, double the wait for each later retry, and retry at most 2 times. These values are only starting points. Adjust them based on real latency.
3. Citations and sources. Keep a source list next to each answer. Each entry should include the title, link, and publication time, and duplicate sources should be removed. When displaying external content, follow copyright requirements and the platform’s terms of service.
4. File and speech preprocessing. Upload large files to object storage first, then pass their access URLs to the platform. Temporary links usually expire, so reissue them when needed. Split long audio before processing, and keep timestamps during splitting so transcription results can be aligned with the original audio. OCR accuracy on tables and handwriting is usually lower. Before launch, evaluate OCR on a sample of real data, and add business validation for key fields.
5. Moderation before and after generation. Input moderation blocks non-compliant requests, and output moderation checks generated content. Match the moderation rules to your business scenario, and keep moderation logs for later review.
6. Conclusion
When the platform supports the tools you need and your account has access, built-in tools can significantly reduce client-side orchestration code. You no longer need to integrate search, fetching, and speech separately. Authentication, streaming, citation display, retry handling, and compliance moderation still have to be implemented by the developer. Read the platform documentation first, then test real latency and costs with a small amount of traffic. Once the setup is stable, expand usage gradually.
