Web search API output formats and token cost for local LLMs — article mark

Web search API output formats and token cost for local LLMs

One SearXNG search through our LB = 10 results, 556 tokens injected, ~0.9 s warm. Below: the real response, and the documented shape of every hosted search API.

Series — web search for local LLMs: Overview · Native Claude vs self-hosted · Search quality · Output formats & token cost · Next stage: Web scrapers for local LLMs

Run locally on my fleet.

Tokens per SearXNG search on three robertz.co queries: what the load balancer injects versus the raw SearXNG JSON Tokens per search, 10 results (robertz.co queries) injected by our LB raw SearXNG JSON q1 robertz.co q2 … authentication methods q3 … broker_parrot job fleet 530 1,057 551 1,081 587 1,454 Mean: 556 injected vs 1,197 raw JSON — the LB passes title + URL per hit, about half the raw payload.
Linear scale. Injected = the text the model receives (title + URL per result). Raw = SearXNG's own JSON for the same query.
QueryResultsInjected tokRaw JSON tokWarmCold
q1 robertz.co105301,0571,163 ms3,643 ms
q2 robertz.co authentication methods battle105511,081850 ms3,378 ms
q3 robertz.co broker_parrot self-hosted job fleet105871,454669 ms5,044 ms
mean105561,197894 ms4,022 ms

SearXNG through our LB — the real response

Query q1 robertz.co; the LB answers a web_search_20250305 tool with synthesised blocks. Pretty-printed, unicode unescaped, all 10 results shown.

{
  "id": "msg_48238ff67e9b448c892617af",
  "type": "message",
  "role": "assistant",
  "model": "fullclaudevllm",
  "content": [
    {
      "type": "server_tool_use",
      "id": "srvtoolu_70eca560776d4a4bb4886528",
      "name": "web_search",
      "input": {
        "query": "robertz.co"
      }
    },
    {
      "type": "web_search_tool_result",
      "tool_use_id": "srvtoolu_70eca560776d4a4bb4886528",
      "content": [
        {
          "type": "web_search_result",
          "title": "simulators — robertz.co — 22 interactive simulators you can run in the browser: digital logic and CPUs, networking and radio, databases, auth flows and algorithm complexity. No install, no sign-up.",
          "url": "https://robertz.co/simulators/",
          "encrypted_content": "",
          "page_age": null
        },
        {
          "type": "web_search_result",
          "title": "www.Robertz.com - Welcome to RobertZ Web Site — In the United Kingdom, Robertz.com is ranked 18,301,672, with an estimated 4,536 monthly visitors a month. Click to view other data about this site.",
          "url": "http://urlm.co.uk/www.robertz.com",
          "encrypted_content": "",
          "page_age": null
        },
        {
          "type": "web_search_result",
          "title": "Robert Zieliński — software engineer · robertz.co — Robert Zieliński — software engineer behind robertz.co, leometeo.com, and dobrapogoda24. Notes on infra, deploys, Python, and Ruby on Rails.",
          "url": "https://robertz.co/",
          "encrypted_content": "",
          "page_age": null
        },
        {
          "type": "web_search_result",
          "title": "Roberts Co — Roberts Co is a boutique tier one construction company. We're here to build a better way.",
          "url": "https://roberts.co/",
          "encrypted_content": "",
          "page_age": null
        },
        {
          "type": "web_search_result",
          "title": "www.Robertz.com - Welcome to RobertZ Web Site — In the United States, Robertz.com is ranked 37,782,615, with an estimated 10,206 monthly visitors a month. Click to view other data about this site.",
          "url": "http://urlm.co/www.robertz.com",
          "encrypted_content": "",
          "page_age": null
        },
        {
          "type": "web_search_result",
          "title": "www.Robertzandco.com - Robertz & Co. — In België, Robertzandco.com heeft 530.064 in de rangschikking met een geschatte < 300 bezoekers per maand. Klik om andere gegevens over deze site te bekijken.",
          "url": "http://urlmetrics.be/www.robertzandco.com",
          "encrypted_content": "",
          "page_age": null
        },
        {
          "type": "web_search_result",
          "title": "Link to instagram.com — The site owner hides the web page description.",
          "url": "https://www.instagram.com/robertz.co/",
          "encrypted_content": "",
          "page_age": null
        },
        {
          "type": "web_search_result",
          "title": "Home - The Roberts Company — Safety, reliability, responsiveness, expertise and innovation. These are the drivers behind the products and services provided by...",
          "url": "https://www.robertscompany.com/",
          "encrypted_content": "",
          "page_age": null
        },
        {
          "type": "web_search_result",
          "title": "robertz | robzlog — Hello and welcome. Who am I? Robert Zarywacz I'm a real person who lives in Ilfracombe in North Devon, England on the coast of the Bristol Channel.",
          "url": "https://www.robzlog.co.uk/robertz",
          "encrypted_content": "",
          "page_age": null
        },
        {
          "type": "web_search_result",
          "title": "Robertz and Co – Stratégie – Organisation – Management – Marketing — Cabinet de Conseil en Stratégie, Organisation et Management. Robertz & Co accompagne les organisations dans la réalisation de leurs projets stratégiques afin d’améliorer leurs...",
          "url": "https://robertzandco.com/",
          "encrypted_content": "",
          "page_age": null
        }
      ]
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0,
    "server_tool_use": {
      "web_search_requests": 1
    }
  }
}

The text counted as injected (title + URL per hit, 530 tokens):

simulators — robertz.co — 22 interactive simulators you can run in the browser: digital logic and CPUs, networking and radio, databases, auth flows and algorithm complexity. No install, no sign-up.
https://robertz.co/simulators/
www.Robertz.com - Welcome to RobertZ Web Site — In the United Kingdom, Robertz.com is ranked 18,301,672, with an estimated 4,536 monthly visitors a month. Click to view other data about this site.
http://urlm.co.uk/www.robertz.com
Robert Zieliński — software engineer · robertz.co — Robert Zieliński — software engineer behind robertz.co, leometeo.com, and dobrapogoda24. Notes on infra, deploys, Python, and Ruby on Rails.
https://robertz.co/
… (14 more lines)

Documented formats — not run (no API key on the box)

Response skeletons from each vendor’s API reference. Placeholders only; nothing here was fetched.

APIOutput shapePer-result content fieldBilling
SearXNG via our LB (measured, above)Anthropic blocks (server_tool_use + web_search_tool_result)title + URL; encrypted_content empty, page_age null$0 marginal · 556 tok / search
Claude web_search_20250305Anthropic blocks + cited textencrypted_content (opaque)$10 / 1k searches + tokens
Tavily /searchJSONcontent, optional raw_contentnot measured
Brave Web SearchJSONdescription, optional extra_snippetsnot measured
Exa /searchJSONtext, highlights, summarycostDollars in response
Perplexity SonarOpenAI-style chat completionsnippet in search_resultsnot measured

Claude web_search (native)

{
  "role": "assistant",
  "content": [
    { "type": "server_tool_use", "id": "<srvtoolu_id>", "name": "web_search",
      "input": { "query": "<query>" } },
    { "type": "web_search_tool_result", "tool_use_id": "<srvtoolu_id>",
      "content": [
        { "type": "web_search_result", "url": "<url>", "title": "<title>",
          "encrypted_content": "<opaque>", "page_age": "<date>" }
      ] },
    { "type": "text", "text": "<answer>",
      "citations": [
        { "type": "web_search_result_location", "url": "<url>", "title": "<title>",
          "encrypted_index": "<opaque>", "cited_text": "<up to 150 chars>" }
      ] }
  ],
  "usage": { "input_tokens": "<n>", "output_tokens": "<n>",
             "server_tool_use": { "web_search_requests": "<n>" } }
}

Source: platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool

Tavily

{
  "query": "<query>",
  "answer": "<only with include_answer>",
  "images": [],
  "results": [
    { "title": "<title>", "url": "<url>", "content": "<snippet>", "score": "<float>",
      "raw_content": "<only with include_raw_content>",
      "published_date": "<only with include_published_date>",
      "favicon": "<url>", "images": [], "id": "<id>" }
  ],
  "auto_parameters": "<only with auto_parameters>",
  "response_time": "<seconds>",
  "usage": "<usage>",
  "request_id": "<id>"
}

Source: docs.tavily.com/documentation/api-reference/endpoint/search

Brave Search API

{
  "query": "<query object>",
  "web": {
    "results": [
      { "title": "<title>", "url": "<url>", "description": "<snippet>",
        "extra_snippets": ["<only with extra_snippets=true>"] }
    ]
  },
  "locations": "<optional>",
  "rich": "<optional>"
}

Source: api-dashboard.search.brave.com/app/documentation/web-search/responses — the page shows partial examples; more keys may exist.

Exa

{
  "requestId": "<id>",
  "results": [
    { "title": "<title>", "url": "<url>", "publishedDate": "<date>", "author": "<author>",
      "id": "<id>", "image": "<url>", "favicon": "<url>",
      "text": "<page text>", "highlights": ["<passage>"], "highlightScores": ["<float>"],
      "summary": "<summary>", "subpages": [], "entities": [],
      "extras": { "links": [], "imageLinks": [], "richImageLinks": [], "richLinks": [], "codeBlocks": [] } }
  ],
  "costDollars": "<cost object>",
  "searchTime": "<ms>"
}

Source: exa.ai/docs/reference/search

Perplexity Sonar

{
  "id": "<id>",
  "object": "<object>",
  "created": "<unix>",
  "model": "<sonar model>",
  "choices": [
    { "message": { "role": "assistant", "content": "<answer with [n] markers>" },
      "finish_reason": "<reason>" }
  ],
  "citations": ["<url>"],
  "search_results": [
    { "title": "<title>", "url": "<url>", "date": "<date>", "last_updated": "<date>",
      "snippet": "<snippet>", "source": "<source>", "place_metadata": "<optional>" }
  ]
}

Source: docs.perplexity.ai/api-reference/chat-completions-post — the example elides some fields.

Questions? Let's Chat :)

ai llm engineering