Skip to main content

langchain-agentsearch

LangChain (Python) tools for AgentSearch: live web search for agents.

Tool Name Cost
AgentSearchTool agentsearch_search Free (up to 25 searches/day per IP, up to 5 results, no key). Paid search with no daily cap is opt-in (mode="paid" / AGENTSEARCH_MODE=paid).
AgentSearchExtractTool agentsearch_extract $0.005/call (USDC on Base via x402)
AgentSearchRenderTool agentsearch_render $0.005/call (headless browser for JS pages)

Install

pip install -U langchain-agentsearch          # free search
pip install -U "langchain-agentsearch[paid]"  # + x402 payments for extract/render

Quick start (free, no key)

from langchain_agentsearch import AgentSearchTool

search = AgentSearchTool()
print(search.invoke({"query": "latest LangChain release", "max_results": 3}))
# JSON string: {"query": ..., "results": [{"title", "url", "content"}, ...]}

With an agent:

from langgraph.prebuilt import create_react_agent
from langchain_agentsearch import AgentSearchTool, AgentSearchExtractTool, AgentSearchRenderTool

agent = create_react_agent(llm, [AgentSearchTool(mode="free"), AgentSearchExtractTool(), AgentSearchRenderTool()])

Search, then read the page

Snippets are often not enough to answer from. The usual loop: search free → extract the 1–2 best URLs as markdown → render only pages extract couldn't read (JavaScript apps).

from langchain.agents import create_agent
from langchain_agentsearch import AgentSearchTool, AgentSearchExtractTool, AgentSearchRenderTool

SYSTEM = (
    "Search first. Extract at most 2 of the best results with max_chars=8000. "
    "If extract returns empty or very short content, render that URL once. Cite every URL you used."
)
agent = create_agent(
    model="openai:gpt-4.1-mini",
    tools=[AgentSearchTool(mode="free"), AgentSearchExtractTool(), AgentSearchRenderTool()],
    system_prompt=SYSTEM,
)

Without a wallet this already runs: search is free and extract/render return an Error: ... string (no request, no charge), so the agent answers from snippets. Add a wallet (below) and the same agent reads full pages at $0.005 per page; $1 covers 200 calls. Pass render_fallback=True to extract (or set AGENTSEARCH_EXTRACT_RENDER_FALLBACK=1) to retry thin pages with render automatically.

Full walkthrough: https://agentsearchhq.com/blog/langchain-agent-search-then-read-page?utm_source=langchain-agentsearch&utm_medium=package

Paid mode

Install the paid extra and set AGENTSEARCH_WALLET_PRIVATE_KEY to the private key of a new wallet made only for this, funded with a little USDC on Base (e.g. $1; no ETH needed). Each call is paid over x402 through the Pocket Network Agentic Portal using the official x402 Python SDK. From 0.2.1 a wallet key alone keeps search free and only enables extract/render. Paid search (no daily cap, $0.005 per search) is opt-in: AgentSearchTool(mode="paid") or AGENTSEARCH_MODE=paid. (In 0.2.0 a key switched the default search tool to paid; mode="free" works in every version.)

Env var Default
AGENTSEARCH_MAX_TOTAL_ATOMIC 1000000 ($1.00 per process)
AGENTSEARCH_MAX_PER_CALL_ATOMIC 5000 ($0.005; can only be lowered)
AGENTSEARCH_TIMEOUT_MS 30000

Limits are checked before anything is signed. The key is never logged or returned. Paid results include a payment object.

Errors

Tools return "Error: ..." strings rather than raising. A 429 from the free relay means the daily limit was hit; the message explains how to upgrade.

Development

pip install -e ".[test,paid]" && pytest            # unit tests (mocked)
AGENTSEARCH_LIVE=1 pytest -k live                    # one real free search

Docs: https://agentsearchhq.com/agents.md?utm_source=langchain-agentsearch&utm_medium=package

MIT

Metadata

Release files for langchain-agentsearch 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-agentsearch 0.2.1
File Size Uploaded Provenance Actions
langchain_agentsearch-0.2.1.tar.gz 11.2 kB Without provenance Details for langchain_agentsearch-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-agentsearch 0.2.1
File Interpreter ABI Platform Actions
langchain_agentsearch-0.2.1-py3-none-any.whl Python 3 none any Details for langchain_agentsearch-0.2.1-py3-none-any.whl

Total release size: 22.8 kB

Release files / langchain_agentsearch-0.2.1.tar.gz

Download URL langchain_agentsearch-0.2.1.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c515a4149294d1e7ec57dc34c9573ae2ef9a6c8ef82a563d81777e2d9e158465
BLAKE2b-256 checksum
How to use checksums
672d35dbf3580b8f2b8232fd22f79c5892aee7db43e7450800caa8159476d6e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / langchain_agentsearch-0.2.1-py3-none-any.whl

Download URL langchain_agentsearch-0.2.1-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc8fd874acfa489f28efc975b292bda877b7d825f64ee313b0e143f74d0c3564
BLAKE2b-256 checksum
How to use checksums
e300df3bd3199e0d4199c020287a9742496a3363a0ae19405e2ce605beea4b56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for langchain-agentsearch 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page