How to Integrate LLM Tool Calling: Built-in Tools vs. Standalone APIs
This article explains how to choose between declarative built-in tools and standalone APIs for LLM tool calling. It covers where tool execution happens, why built-in tools cannot be mixed with custom functions in the same request, and how Agents can use a two-stage retrieval approach to control context and token costs. It also includes practical guidance on multi-turn conversation handling, a pre-integration checklist, and decision criteria for selecting the right entry point.
1. The Problem: A Long Capability List, but Only One Obvious Entry Point
When a cloud provider exposes a full set of model-adjacent capabilities as APIs, most teams start by scanning the list item by item: web search, page content extraction, document parsing, character recognition, speech transcription. Everything appears to be covered. But in real engineering work, the hard question is not “does this capability exist?” It is “which entry point should I integrate?”
Choosing the wrong entry point has concrete and measurable costs. At best, the context gets stuffed with irrelevant page content, the model’s attention is diluted, and answer quality drops. At worst, a single file upload triggers multiple billing events, and the month-end bill looks abnormal but is hard to attribute. A more hidden problem is that many teams treat the two forms as two wrappers around the same thing. They then force Agent logic that should be encapsulated with standalone APIs into declarative built-in tools, and end up with neither the full text nor control over the flow.
To decide which path to take, first understand what actually changed.
2. What Really Changed: Tool Execution Moved
The traditional way to give a model tools is classic function calling: the model emits a structured call request, your server executes the search, fetches the pages, cleans the content, and splices the results back into the context so reasoning can continue. On this path, the execution cost falls on your own compute, and the full returned content consumes your token quota. Searching ten pages can pull in twenty thousand tokens that have nothing to do with the current question.
There is now another form: you declare server-side built-in tools in the request body, and search, link opening, and content extraction all happen on the provider side. Only the processed conclusions and source citations fall back into your context. To use an analogy, you used to send a courier out to pick up items and carry them back to your warehouse; now the warehouse ships and shelves the goods directly, and you only pick from the shelf.
For ordinary chat applications, this difference directly changes the cost structure of integration. What used to require building a search service and maintaining a fetch-and-clean pipeline now reduces to writing one extra declaration field in the request. The model decides on its own whether it needs to go online, and cites sources in the answer.
But there is one structural constraint to keep in mind: according to the public API documentation, built-in tools cannot be mixed with custom functions in the same request. Pure question-answering scenarios can hand search entirely over to built-in tools; once the request also needs to call your own business functions, this path no longer works. This is not a matter of capability level, but a mutual-exclusion limit in the request structure, and it is the root cause of choosing the wrong entry point.
3. Agent Scenarios: Use Standalone APIs and Keep Control of the Token Budget
Agents that need to connect to your own knowledge base, permission-controlled documents, or internal ticketing systems should bypass built-in tools and wrap the two standalone APIs for search and fetching as ordinary functions the model can call.
The design most worth borrowing here is two-stage content retrieval. In summary-only mode, the search API returns only the title, snippet summary, and relevance score. The model first reads the summaries to filter, then issues a separate fetch for the few matching links to get structured content. The full text of irrelevant pages never enters the context, so tokens are spent where they matter.
// Example: the search request fetches summaries only, not full content{"query": "release notes for the latest version of a framework","count": 5,"need_content": false}
// Example: model-side tool descriptions (pseudocode)tool: search(query, count=5, need_content=false) -> [{title, snippet, score, url}]tool: fetch(url, format="markdown") -> {content, title, published_at}
This split brings three engineering benefits. First, the context is controllable: the length of content injected into a single inference has a clear upper bound. Second, it is auditable: every fetch is a separate call, which makes logging and replay easy. Third, it degrades gracefully: if a fetch fails, the model can still answer based on the summary instead of failing the whole turn.
4. The Most Overlooked Detail in Multi-turn Conversations
Standalone APIs are stateless, but conversations are stateful. In multi-turn scenarios, the most common mistake is repeatedly splicing the previous turn’s search results into the history, so the context grows monotonically and starts approaching the window limit by the second turn.
A more robust approach has three points. First, treat tool results as disposable temporary data: write only the “conclusion + citation identifier” into long-term history, keep the full content in external storage, and re-fetch it by citation when needed. Second, rewrite and deduplicate search queries, merging multi-turn follow-ups into a single search to avoid repeatedly spending quota on synonymous queries. Third, set a budget for history, applying sliding truncation by turn count or token quota, and prioritize keeping the user’s original intent and confirmed conclusions.
5. Pre-integration Checklist
Whichever path you take, the following preprocessing determines post-launch stability and the cost curve:
- Query side: unify cleaning and normalization, resolve references, and filter out empty and overly long queries.
- Document side: after parsing, apply segmentation and metadata tagging (source, time, permission labels). Permission labels must participate in filtering at the search stage and cannot be left to the generation stage.
- Result side: set limits on summary length and item count, clean the content by removing ads and navigation, and keep citable position information.
- Failure side: set timeouts, retries, and circuit breaking for fetching and parsing, and prepare a “summary-only answer” fallback path.
- Observability side: separately track search count, fetch count, injected tokens, and hit positions, and attribute bill fluctuations to specific pipelines.
6. Selection Criteria and Implementation Advice
Three questions can drive the decision: does the answer have to depend on external real-time information; do you have to call your own business functions; do you need item-by-item auditing of injected content. If you only need external information and no custom functions, prefer declarative built-in tools and leave the complexity to the server side. If custom functions, an internal knowledge base, or strong auditing requirements are involved, choose standalone APIs with your own wrapper, and use two-stage content retrieval to control the context.
From an engineering standpoint, it is better to abstract both behind the same layer of protocol: expose unified search and fetch capabilities externally, and switch implementations internally by scenario. This way you get both the integration speed of the managed form and the room to finely control cost and quality on the Agent path. If you need to support batch parsing, result caching, and call auditing, you can combine general cloud infrastructure such as object storage, message queues, and log monitoring to turn tool calling into an observable, traceable standard pipeline rather than temporary patches scattered across business code.
