Engineering Practices for Built-in Web Search and Multimodal Capabilities in LLM APIs
As Large Language Model (LLM) services increasingly integrate built-in tools for web search and multimodal processing on the server side, developers face new architectural choices. This article explores the engineering practices of adopting these built-in capabilities, covering the three primary forms of built-in tools, breaking down common features like web search, URL reading, OCR, and voice processing, detailing the integration process with code examples, and providing a cost estimation model for usage-based billing.
1. Background: From Calling Models to Calling Capabilities
In the past, the standard development approach for LLM applications involved the client receiving a user query, calling the model API, and retrieving the text result. If the query required real-time information, developers had to manually integrate search services, web scraping tools, document parsing components, and speech recognition services, while writing a complete tool-calling loop. The complexity of this pipeline primarily stemmed from “glue code”: each tool required separate authentication, timeout strategies, error handling, and formatting conventions to pass results back into the context.
Recently, some model services have started hosting common capabilities on the server side. Within a single request, the model autonomously determines whether it needs to search the web or read a link. The server completes the retrieval and page parsing, then injects the results into the context. The client only needs to declare which capabilities to enable. For teams, this reduces the number of external dependencies, but it also changes the cost structure and debugging methods, necessitating a re-evaluation of the technical architecture.
2. Three Forms of Built-in Tools
Categorized by execution location, built-in tools generally fall into three types:
- Server-side Hosted Tools: Executed by the platform; the client only toggles them on or off, such as web search and URL reading. Integration is fast, but retrieval strategies, result ranking, and scraping details are uncontrollable.
- Client-side Function Tools: The model outputs a structured call request, which is executed by the business code, and the results are passed back to the model. Suitable for accessing internal databases, business APIs, and other private resources.
- Hybrid Mode: A single request includes both hosted tools and custom functions. In this case, attention must be paid to the execution order and how the two types of results are merged into the context.
When selecting a tool, the first step is to determine whether the data can leave your network boundary. Public information retrieval can safely use hosted capabilities; queries involving internal data should route through client-side function tools, where access permissions are controlled by your own gateway.
3. Breakdown of Common Capabilities
3.1 Web Search
Web search is used to fill information gaps that occurred after the model’s training cutoff. When evaluating, focus on three metrics: retrieval timeliness, result relevance, and whether source URLs are returned. It is recommended to require results with sources to facilitate citation in the response, allowing users to verify the information.
3.2 URL Reading
Given a URL, the server scrapes the page and extracts the main content. Key considerations include: support for dynamic pages requiring script rendering, extraction accuracy, truncation strategies for excessively long pages, and how login walls and paywalls are handled. Extracted results may lose table structures; content involving numbers should be verified on the original page.
3.3 File Input and OCR
Uploaded PDFs and images are first parsed into text. Scanned documents rely on Optical Character Recognition (OCR), where layouts, tables, and handwritten content are prone to errors. For key fields such as amounts, dates, and ID numbers, it is recommended to add rule validation or manual spot-checks.
3.4 Voice Input and TTS
Automatic Speech Recognition (ASR) and Text-to-Speech (TTS) represent the two ends of voice interaction. When integrating, you must confirm the audio format, sample rate, maximum duration per call, and latency differences between streaming and offline batch modes. Real-time conversation scenarios should prioritize streaming APIs, while batch transcription scenarios focus more on the cost per unit of time.
3.5 Content Moderation
Moderation services classify and detect both user input and model output. Results typically provide risk categories and confidence scores, rather than a simple “violation” or “compliant” flag. Business stakeholders need to define their own thresholds and actions, such as direct approval, escalation to human review, or blocking. Binding moderation results to business tiers is easier to maintain than a blanket blocking approach.
4. Integration Process
Integration generally follows four steps.
Step 1: Create and manage credentials. Generate access credentials in the platform console. Store them only in environment variables or a secret management service. Do not hardcode them in repositories or print them to logs.
Step 2: Select an API protocol. If your team already has a client compatible with a mainstream protocol, you usually only need to replace the service URL and model name, resulting in minimal business code changes.
Step 3: Declare tools and send the request. Declare the tools you want to enable in the request payload. Additionally, it is recommended to inject environment information at the system level, such as the current date, region, and language, to help the model generate more accurate search keywords. For example, if the date is missing in a weather query, the model might retrieve outdated information.
Step 4: Parse server-side call logs. The response usually includes a log of tool calls, including the call type, parameters, and frequency. These records should be written to logs for troubleshooting and billing reconciliation.
An illustrative code snippet is provided below. The field names are only for demonstrating the calling pattern; specific names should follow the official documentation of the platform you are using.
import osAPI_URL = "https://api.example.com/v1/chat/completions" # Example endpointAPI_KEY = os.environ["LLM_API_KEY"] # Read credentials from environment variablespayload = {"model": "your-model-name","messages": [{"role": "system", "content": "Current date: 2026-11-14, Region: US, Language: English."},{"role": "user", "content": "What is the weather like in California today, is it suitable to go out? Please answer briefly."},],"tools": [{"type": "web_search"}, # Example: Enable web search{"type": "read_url"}, # Example: Enable URL reading],}# send_json_request is an illustrative function; replace it with your team's HTTP wrapper, ensuring timeout settingsdata = send_json_request(API_URL, API_KEY, payload, timeout=60)answer = data["choices"][0]["message"]["content"]print(answer)for call in data.get("tool_calls_log", []):print("Tool:", call.get("kind"), "Params:", call.get("action"))
5. Billing Models and Cost Estimation
Usage-based billing services typically consist of three parts: model inference fees (calculated by input and output tokens), tool call fees (calculated per call), and audio fees (calculated by duration). Some platforms also implement tiered pricing or limited-time discounts.
Monthly costs can be estimated using the following formula:
Monthly Cost = Request Count × Average Input Tokens ÷ 1,000,000 × Input Unit Price + Request Count × Average Output Tokens ÷ 1,000,000 × Output Unit Price + Search Count × Search Unit Price + Read Count × Read Unit Price + Audio Duration × Duration Unit Price
For example: assuming an average of 10,000 requests per day, with an average of 2,000 input tokens and 300 output tokens per request, and each request triggering 1…
