web_router.integrations.langchain puts search and extract in front of a
LangChain agent as two tools, web_search and web_extract. The langchain
extra adds langchain-core, all the tools need; the agent loop and the model
are your own install, here langchain and langchain-openai:
OPENAI_API_KEY here). To enable a keyed web backend, pass its credentials
explicitly in provider_config.
provider="tavily" sends every call to one backend, which then needs its key.
A name that only searches leaves extract on the default routing;
extract_provider= picks that one.
Or build them one at a time — WebRouterSearch(router=..., provider=..., max_results=..., search_depth=...) and WebRouterExtract(...) — and pass
async_router=AsyncWebRouter(use_environment=False) to serve agent.ainvoke
without a worker thread.
WebRouterAnswer(router=..., provider="linkup") adds web_answer, a backend’s
written answer to one question with its sources. It is not among
web_router_tools(): every answer backend needs a key and bills each call.
The model supplies the query or the URLs; you supply everything else. The
provider, max_results, search_depth and the domain filters are fixed when
the tool is built and sent unchanged on every call, so an agent behaves the
same whichever backend serves it and switching backends is one argument. An
option the provider does not map raises on the first call, to you — not to the
model, which could not fix it.
The model reads a compact rendering; you keep the whole response. Each
tool answers in LangChain’s content_and_artifact form: the model sees JSON in
one layout for every backend, each result’s text cut to result_chars (a
page to document_chars), and the tool message’s artifact carries the
untouched SearchResponse or ExtractResponse. A backend failure, or a call
past timeout, reaches the model as the short error the Claude and OpenAI
tools give (see What the model reads when a call fails);
web_extract names the URLs it could not read rather than failing the call,
and refuses private hosts unless built with url_policy=None.
Back to Integrations.