Function: createSearxngSearchTool()
function createSearxngSearchTool(
config: SearxngToolConfig<ArtifactResolver>,
): Promise<Tool<SpooledArtifact>>;Defined in: batteries/tools/searxng/index.ts:402
Create a configured SearXNG search Tool (async — accepts a dynamic-import artifact).
Parameters
| Parameter | Type | Description |
|---|---|---|
config | SearxngToolConfig<ArtifactResolver> | The instance URL, optional custom headers, output-format policy, artifact resolver, and input/output middleware pipelines. See SearxngToolConfig. |
Returns
Promise<Tool<SpooledArtifact>>
A promise of a Tool ready to register in a ToolRegistry.
Remarks
Async because artifact may be an async / dynamic-import resolver, which must be resolved to the sync () => Ctor that Tool.artifactConstructor requires before the tool is built (the wrap-site invokes it synchronously). For the common case where you reference the artifact class directly, use createSearxngSearchToolSync and skip the await.
The handler always requests format=json. Note that SearXNG ships with JSON output disabled by default (it is abused by bots); an instance that has not enabled search.formats: [json] in its settings.yml answers with HTTP 403, which the tool returns as a graceful Error: string naming the setting.
WARNING
Do not trust the number_of_results field for a result count — SearXNG frequently reports 0 in JSON output even when results is non-empty. This is a long-standing upstream quirk, not a tool defect (see searxng#2987 and searxng#2457). The tool passes the field through verbatim; use results.length as the authoritative count.
Throws
E_INVALID_SEARXNG_CONFIG when instanceUrl or artifact is invalid.