WebRouter
haystack_integrations.components.fetchers.webrouter.webrouter_fetcher
WebRouterFetcher
Fetches web pages with WebRouter and returns their main content as Haystack Documents.
WebRouter is an open-source library that puts one interface in front of several page extraction providers. Each call goes to one provider and falls back to the next one if it fails.
No API key is required. By default only keyless providers are used; credentials in the process environment
are not discovered automatically. To use a keyed provider, pass its key explicitly through provider_keys,
for example provider_keys={"tavily": Secret.from_env_var("TAVILY_API_KEY")}. Only the named Secrets are resolved.
This component accepts only keyless or API-key-only provider configuration. Each provider_keys entry
is forwarded as api_key; other constructor credentials and settings are not exposed.
With WebRouter 0.17, API-key configuration is available for nimble, tavily, exa, linkup,
firecrawl, webiq, keenable, deepseek, specstream, apify and browserbase; keyless routing
and keyless providers such as jina are also available. oxylabs (username/password or web_api_key)
and brightdata (token plus zone) cannot be configured through this component.
See the WebRouter documentation for the providers.
Usage example
from haystack_integrations.components.fetchers.webrouter import WebRouterFetcher
fetcher = WebRouterFetcher()
result = fetcher.run(urls=["https://haystack.deepset.ai"])
documents = result["documents"]
failures = result["meta"]["failures"]
init
__init__(
provider: str | None = None,
*,
content_format: Literal["markdown", "html", "text"] = "markdown",
extract_params: dict[str, Any] | None = None,
provider_keys: dict[str, Secret] | None = None
) -> None
Initialize the WebRouterFetcher component.
Parameters:
- provider (
str | None) – Name of the provider to send every fetch to, for example"firecrawl"or"tavily". If not set, WebRouter picks one among the providers available and falls back to the next one if a call fails. - content_format (
Literal['markdown', 'html', 'text']) – Representation of each page in the Document content:"markdown","html"or"text". A provider that cannot return the requested format is skipped, or raises an error when set asprovider. - extract_params (
dict[str, Any] | None) – Additional keyword arguments passed toWebRouter.extract, such astimeoutorprovider_options. Aformatkey here takes precedence overcontent_format. See the WebRouter extract reference for the full list. - provider_keys (
dict[str, Secret] | None) – Explicit mapping of provider names to API key Secrets. Resolved during warm-up and passed as WebRouter'sprovider_config; omitted providers receive no credentials from the environment.
to_dict
Serialize the component, retaining Secret references rather than resolved keys.
from_dict
Deserialize the component and its nested provider key Secrets.
warm_up
Initialize the WebRouter sync client.
Called automatically on first use. Can be called explicitly to avoid cold-start latency.
warm_up_async
Initialize the WebRouter async client.
close
Close the WebRouter sync client.
close_async
Close the WebRouter async client.
run
run(
urls: list[str], extract_params: dict[str, Any] | None = None
) -> dict[str, Any]
Fetch the given URLs with WebRouter and return their content as Documents.
Fetching several URLs can partly succeed: the pages that could not be read are logged as warnings and listed
in meta["failures"].
Parameters:
- urls (
list[str]) – URLs to fetch. - extract_params (
dict[str, Any] | None) – Optional per-run override of the extract parameters. If provided, fully replaces the init-timeextract_params.
Returns:
dict[str, Any]– A dictionary with:documents: One Document per page that was read, withurl,title,providerand, when known,published_dateinmeta.meta: Request-level metadata:provider, the provider that served the call, andfailures, a list of{"url": ..., "error": ...}for the URLs that could not be read.
Raises:
web_router.ConfigurationError– The selected provider cannot be configured; supported API keys are supplied throughprovider_keys.web_router.WebRouterError– If no URL could be read, or no provider could serve the call.
run_async
run_async(
urls: list[str], extract_params: dict[str, Any] | None = None
) -> dict[str, Any]
Asynchronously fetch the given URLs with WebRouter and return their content as Documents.
Fetching several URLs can partly succeed: the pages that could not be read are logged as warnings and listed
in meta["failures"].
Parameters:
- urls (
list[str]) – URLs to fetch. - extract_params (
dict[str, Any] | None) – Optional per-run override of the extract parameters. If provided, fully replaces the init-timeextract_params.
Returns:
dict[str, Any]– A dictionary with:documents: One Document per page that was read, withurl,title,providerand, when known,published_dateinmeta.meta: Request-level metadata:provider, the provider that served the call, andfailures, a list of{"url": ..., "error": ...}for the URLs that could not be read.
Raises:
web_router.ConfigurationError– The selected provider cannot be configured; supported API keys are supplied throughprovider_keys.web_router.WebRouterError– If no URL could be read, or no provider could serve the call.
haystack_integrations.components.websearch.webrouter.webrouter_websearch
WebRouterWebSearch
Searches the web with WebRouter and returns the results as Haystack Documents.
WebRouter is an open-source library that puts one interface in front of several web search providers. Each call goes to one provider and falls back to the next one if it fails.
No API key is required. By default only keyless providers are used; credentials in the process environment
are not discovered automatically. To use a keyed provider, pass its key explicitly through provider_keys,
for example provider_keys={"tavily": Secret.from_env_var("TAVILY_API_KEY")}. Only the named Secrets are resolved.
This component accepts only keyless or API-key-only provider configuration. Each provider_keys entry
is forwarded as api_key; other constructor credentials and settings are not exposed.
With WebRouter 0.17, API-key configuration is available for nimble, tavily, you, brave, exa,
parallel, perplexity, linkup, seltz, webiq, octen, keirolabs, keenable, deepseek,
valyu, specstream, firecrawl and apify; you-mcp, exa-mcp and parallel-mcp work keylessly.
agentcore and the LiteLLM proxy providers need additional credentials or endpoint settings and cannot
be configured through this component.
See the WebRouter documentation for the providers.
Usage example
from haystack_integrations.components.websearch.webrouter import WebRouterWebSearch
websearch = WebRouterWebSearch(top_k=5)
result = websearch.run(query="What is Haystack by deepset?")
documents = result["documents"]
links = result["links"]
init
__init__(
top_k: int | None = 10,
provider: str | None = None,
search_params: dict[str, Any] | None = None,
*,
provider_keys: dict[str, Secret] | None = None
) -> None
Initialize the WebRouterWebSearch component.
Parameters:
- top_k (
int | None) – Maximum number of results to return.Noneleaves the number to the provider. - provider (
str | None) – Name of the provider to send every search to, for example"tavily"or"exa". If not set, WebRouter picks one among the providers available and falls back to the next one if a call fails. - search_params (
dict[str, Any] | None) – Additional keyword arguments passed toWebRouter.search, such asinclude_domains,exclude_domains,recency,country,search_depthortimeout. Amax_resultskey here takes precedence overtop_k. See the WebRouter search reference for the full list. - provider_keys (
dict[str, Secret] | None) – Explicit mapping of provider names to API key Secrets. Resolved during warm-up and passed as WebRouter'sprovider_config; omitted providers receive no credentials from the environment.
to_dict
Serialize the component, retaining Secret references rather than resolved keys.
from_dict
Deserialize the component and its nested provider key Secrets.
warm_up
Initialize the WebRouter sync client.
Called automatically on first use. Can be called explicitly to avoid cold-start latency.
warm_up_async
Initialize the WebRouter async client.
close
Close the WebRouter sync client.
close_async
Close the WebRouter async client.
run
run(
query: str, search_params: dict[str, Any] | None = None
) -> dict[str, list[Document] | list[str]]
Search the web with WebRouter and return the results as Documents.
Parameters:
- query (
str) – Search query. - search_params (
dict[str, Any] | None) – Optional per-run override of the search parameters. If provided, fully replaces the init-timesearch_params.
Returns:
dict[str, list[Document] | list[str]]– A dictionary with:documents: One Document per result.contentholds the fullest text the provider returned for the result, andmetaholdstitle,url,providerand, when known,published_date.links: The URLs of the results.
Raises:
web_router.ConfigurationError– The selected provider cannot be configured; supported API keys are supplied throughprovider_keys.web_router.WebRouterError– No provider can serve the search or the backend request fails.
run_async
run_async(
query: str, search_params: dict[str, Any] | None = None
) -> dict[str, list[Document] | list[str]]
Asynchronously search the web with WebRouter and return the results as Documents.
Parameters:
- query (
str) – Search query. - search_params (
dict[str, Any] | None) – Optional per-run override of the search parameters. If provided, fully replaces the init-timesearch_params.
Returns:
dict[str, list[Document] | list[str]]– A dictionary with:documents: One Document per result.contentholds the fullest text the provider returned for the result, andmetaholdstitle,url,providerand, when known,published_date.links: The URLs of the results.
Raises:
web_router.ConfigurationError– The selected provider cannot be configured; supported API keys are supplied throughprovider_keys.web_router.WebRouterError– No provider can serve the search or the backend request fails.