llama-stack icon indicating copy to clipboard operation
llama-stack copied to clipboard

[Discussion] Add a SearchApi web search provider (remote::searchapi-search)

Open gabsferreira opened this issue 1 month ago • 2 comments

What would you like to discuss with the community?

Disclosure first: I'm the developer advocate at SearchApi, the API I am proposing here. So I have a direct interest in this landing, and you should weigh the rest accordingly.

Motivation

OGX serves web search through the builtin::websearch toolgroup via remote::tavily-search, remote::brave-search, remote::bing-search, remote::nimble-search, remote::serply-search and remote::exa-search. I would like to add one more option backed by SearchApi's Google Search API, which returns Google organic results as ranked {title, link, snippet} rows. It is a drop-in web grounding choice on the same web_search tool shape, so it needs no API or routing changes.

I am not claiming it beats the existing providers at retrieval quality. It is another Google-backed option for people who already have a SearchApi account or want its other verticals later.

Proposed provider

  • provider_type: remote::searchapi-search, toolgroup_id: builtin::websearch.
  • Mirrors the serply_search / exa_search layout exactly: framework-free httpx2 (no new dependency), persistent AsyncClient created in initialize() and closed in shutdown(), config inheriting BaseToolRuntimeConfig for timeouts, the shared low/medium/high -> 3/5/10 mapping for search_context_size, and the key read from config (SEARCHAPI_API_KEY) or per request via the X-OGX-Provider-Data header (searchapi_search_api_key).
  • Transport is GET https://www.searchapi.io/api/v1/search?engine=google&q=... with the key only in the Authorization: Bearer header, never in the query string, plus User-Agent: ogx.
  • Google phased out the num parameter in September 2025, so SearchApi documents one results page of 10 per request. The provider does not send num and trims the page locally to the requested count (so high is at most 10).
  • allowed_domains becomes a (site:a OR site:b) clause in the query, same as serply_search. user_location.country is forwarded as gl, which is a documented parameter of this engine.
  • Config surface kept small: api_key as SecretStr and max_results, every Field with a description so ./scripts/provider_codegen.py generates the doc page.

In tree, same shape as #6636 and #6643

Following #6621, where @mattf answered "in tree", and the two providers that landed after it, I have prototyped it in tree as a peer to serply_search, with the same file set as the Exa PR (#6643): provider package, registry entry, starter / ci-tests wiring through distro_codegen.py, the generated reference page, the lets-go web search order, the hand-written docs mentions, and a unit test file.

Status

The PR is ready and tested live against the real API (plain query, allowed_domains, gl, invalid key) plus a mocked unit layer for CI. I will link it here as soon as it is open. Scope is web search only; SearchApi also has News, Scholar, Maps and other engines, and those would need an API extension, so they stay out of this one.

Happy to adjust anything to match the house pattern.

gabsferreira avatar Oct 29 '26 17:10 gabsferreira

PR is open: https://github.com/ogx-ai/ogx/pull/6927

gabsferreira avatar Oct 29 '26 17:10 gabsferreira

Good news — SearchApi is in. The routed web_search API shipped in #7014 (merged to main 2026-11-17) with remote::searchapi-search registered as one of the built-in search providers (ogx.providers.remote.web_search.searchapi_search), so the ask in this discussion has landed.

Closing this as implemented. If anything is missing from the SearchApi integration (config surface, error mapping, etc.), open a follow-up issue — or reply here and we'll reopen. Thanks for the thorough write-up and the up-front disclosure.

mattf avatar Nov 22 '26 12:11 mattf