Building an AI Assistant with a Single API: A Guide to LLM Built-in Capabilities

    Learn how to build an AI assistant using server-side tools exposed through a single LLM API. This guide covers built-in capabilities such as web search, web page reading, OCR, and speech, compares them with traditional Function Calling, and walks through integration steps, sample code, and billing models.

    1. Background: From Raw Models to Capability Platforms

    In the past, when developers built AI assistants, the model itself was usually capable enough. The real friction came from everything around it. To answer real-time questions, the assistant needed a search engine integration. To read links sent by users, it needed a web scraping service. Handling images and scanned documents required OCR, and supporting voice meant integrating speech recognition and speech synthesis. Every third-party service added another set of authentication, rate limiting, timeout, and error-handling code, plus another bill to pay.

    Over the past year or two, some LLM providers have started packaging these capabilities as server-side tools, exposed through the same API. The caller declares which tools it needs in the request, and the server automatically performs the search, reads the web page, injects the results into the context, and returns the final answer. Developers no longer need to maintain their own tool-calling loop.

    2. Common Built-in Capabilities and Their Boundaries

    1. Web search: When the model determines that a question requires real-time information, it triggers a search, and the results are injected into the context by the server. Time-sensitive questions—weather, news, prices—are good candidates for enabling search. For common-knowledge questions the model already knows, search only adds cost and latency.
    2. Web page reading: Given a URL, the server fetches the main content and performs structured extraction. This works well for publicly accessible static pages. Pages behind login walls, pages that rely heavily on script rendering, and sites with anti-scraping protections usually yield little usable content.
    3. Files and OCR: After a user uploads a document or image, the server handles parsing and text recognition, and the model answers based on the recognized content. When scan quality is poor or table structures are complex, recognition errors directly affect the answer, so the UI should let users verify against the original.
    4. Voice input and read-aloud: Automatic speech recognition (ASR) converts recordings into text as input, and text-to-speech (TTS) reads the answer aloud. This suits scenarios that require voice interaction, such as accessibility use cases or driving. Recognition accuracy drops in noisy environments.
    5. Content moderation: Inputs and outputs are moderated uniformly on the server side, which reduces some compliance risk. Moderation rules are defined by the provider and cannot cover every violation scenario specific to your business.

    Providers roll out these capabilities at different paces. Search-related interfaces are usually released earlier, while file, OCR, and speech capabilities are often added in later versions. Check the capability list in the console or documentation before making a selection.

    3. Server-side Tools vs. Traditional Function Calling

    Both patterns let the model invoke external capabilities. The difference lies in who executes the tool.

    Aspect Traditional Function Calling Server-side Tools
    Tool executor The client executes it itself The server executes it
    Request round trips Usually two or more Usually one, sometimes more
    How results enter the context The client sends results back to the model The server injects them directly
    Client workload Must implement tool functions and the calling loop Only declares tools and handles the final result
    Tool controllability Fully controllable; can be swapped for any backend Constrained by the provider’s tool capabilities
    Failure handling The client decides retries and fallbacks Depends on error information returned by the server

    Server-side tools eliminate a large amount of engineering work, at the cost of reduced controllability. If your business needs to access its own databases or internal systems, traditional Function Calling is still the right choice.

    4. Integration Steps and Sample Code

    Step 1: Create an API key in the cloud platform console. The key should be read from environment variables—never hardcode it or commit it to a repository. Also confirm that the corresponding capability is enabled for your account, or requests may return permission errors.

    Step 2: Install an OpenAI-compatible SDK and construct the request. In the OpenAI-compatible protocol, the standard way to write the tools field is the function type plus a JSON Schema description. The way to enable built-in capabilities such as web search and web page reading varies by provider: some use dedicated parameters, others use specific tool types. The code below is a structural example—the parameter names must be replaced with those in the provider’s documentation.

    1. import os
    2. from openai import OpenAI
    3. client = OpenAI(
    4. api_key=os.environ["MODEL_API_KEY"], # Read from environment variables
    5. base_url=os.environ["MODEL_BASE_URL"], # Use the address given in the provider's docs
    6. timeout=15.0, # Client timeout in seconds
    7. )
    8. try:
    9. resp = client.chat.completions.create(
    10. model=os.environ["MODEL_NAME"], # Model name per the console listing
    11. messages=[
    12. {"role": "user", "content": "What's the weather in Shanghai today? Please answer briefly."}
    13. ],
    14. # Example: the parameter for enabling built-in web search is defined by the provider;
    15. # replace it with the documented form
    16. extra_body={"builtin_web_search": True},
    17. )
    18. except Exception as e:
    19. # Handle timeouts, rate limiting, and auth failures here with a fallback
    20. print(f"Request failed: {e}")
    21. raise SystemExit(1)
    22. text = resp.choices[0].message.content or ""
    23. if not text.strip():
    24. text = "No results available right now. Please try again later."
    25. print(text)

    Step 3: Handle process information returned by the server. Some providers include tool-call events in the response—stage information such as “searching” or “reading the web page”—which the frontend can use to display progress. The names and structure of these fields vary by provider and version, and not all providers offer them. Before reading a field, check whether it exists; if it does not, simply skip it rather than letting the program throw an error.

    5. Understanding the Billing Model

    Most built-in capabilities follow a dual-track model: the model is billed per token, and tools are billed per call. Speech capabilities are typically billed by audio duration. When estimating the cost of a single request, break it into three parts:

    • Model cost: input tokens multiplied by the input price, plus output tokens multiplied by the output price.
    • Tool cost: the number of search or web-fetch calls multiplied by the per-call price.
    • Speech cost: the duration of recognized or synthesized audio multiplied by the per-duration price.