Skip to main content

AgentSearch Tool Spec (llama-index-tools-agentsearch)

A LlamaIndex ToolSpec for AgentSearch: live web search for agents. Free search needs no API key.

Function Cost
search(query, max_results=None) Free (up to 25 searches/day per IP, up to 5 results, no key). Paid and unlimited only when you opt in (mode="paid" or AGENTSEARCH_MODE=paid).
extract(url, formats=None, max_chars=None) $0.007/call (USDC on Base via x402 to AgentSearch)
render(url, formats=None, max_chars=None, wait_until=None, wait_for_selector=None) $0.010/call (headless browser for JS pages)

Install

pip install -U llama-index-tools-agentsearch

Quickstart

from llama_index.tools.agentsearch import AgentSearchToolSpec

spec = AgentSearchToolSpec()
print(spec.search("latest LlamaIndex release", max_results=3))  # JSON string

# With an agent
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

agent = FunctionAgent(tools=spec.to_tool_list(), llm=OpenAI(model="gpt-4o-mini"))
# response = await agent.run("What changed in the latest LlamaIndex release? Cite URLs.")

Free-only tool list: [t for t in spec.to_tool_list() if t.metadata.name == "search"]. Search stays free in the default mode="auto" even when a wallet key is set; AgentSearchToolSpec(mode="free") pins it to free regardless of AGENTSEARCH_MODE.

max_results must be an integer from 1 to 5 (default 5); other values return an Error: max_results must be ... string and no call is made.

Paid mode

Install the paid extra (pip install "llama-index-tools-agentsearch[paid]") 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). Since 0.3.0 each call is paid over x402 directly to AgentSearch's own API (https://api.agentsearchhq.com, USDC on Base, settled only on success) using the official x402 Python SDK: search $0.008, extract $0.007, render $0.010. $1 covers about 140 extracts. Prefer the Pocket Network Agentic Portal ($0.005 per call)? Set AGENTSEARCH_PAYMENT_ROUTE=pocket. Extract and render use the key directly. Search goes paid (unlimited) only when you opt in with AgentSearchToolSpec(mode="paid") or AGENTSEARCH_MODE=paid; a key alone does not switch it. In mode="auto", if AGENTSEARCH_MODE=paid is set but the [paid] extra is missing, search falls back to free with a logged warning.

Env var Default
AGENTSEARCH_MAX_TOTAL_ATOMIC 1000000 ($1.00 per process)
AGENTSEARCH_PAYMENT_ROUTE direct (AgentSearch's x402 API); pocket = Pocket Network Agentic Portal at $0.005/call
AGENTSEARCH_MAX_PER_CALL_ATOMIC 10000 on the direct route, 5000 on Pocket ($0.010 / $0.005; can only be lowered)
AGENTSEARCH_TIMEOUT_MS 30000
AGENTSEARCH_MODE unset (paid opts search into paid mode when mode="auto")
AGENTSEARCH_EXTRACT_RENDER_FALLBACK unset (1 = when extract returns thin content, render the URL once; a second paid call, $0.010)

Limits are checked before anything is signed. The key is not included in tool output or error messages. Paid results include a payment object.

Budget helpers are exported at the top level:

from llama_index.tools.agentsearch import reset_session_budget, session_spent_atomic

print(session_spent_atomic())  # USDC atomic units signed so far in this process (1_000_000 = $1)
reset_session_budget()

Errors

Tools return "Error: ..." strings instead of raising. A 429 from the free relay means the daily limit (up to 25 searches/day per IP) was hit, and the message explains how to upgrade.

Development

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

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

MIT

Metadata

Release files for llama-index-tools-agentsearch 0.3.0

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

Source distribution (sdist)

Source distribution for llama-index-tools-agentsearch 0.3.0
File Size Uploaded Provenance Actions
llama_index_tools_agentsearch-0.3.0.tar.gz 15.2 kB Without provenance Details for llama_index_tools_agentsearch-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-tools-agentsearch 0.3.0
File Interpreter ABI Platform Actions
llama_index_tools_agentsearch-0.3.0-py3-none-any.whl Python 3 none any Details for llama_index_tools_agentsearch-0.3.0-py3-none-any.whl

Total release size: 28.8 kB

Release files / llama_index_tools_agentsearch-0.3.0.tar.gz

Download URL llama_index_tools_agentsearch-0.3.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9afc904ceec9aa38878f93ed36b55ea3aebce21d18db3617a2c2bc08c39f1095
BLAKE2b-256 checksum
How to use checksums
971cf1e4982598060daba7bcd2cdab441a227f2d691e2f6325ed040755b60e7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / llama_index_tools_agentsearch-0.3.0-py3-none-any.whl

Download URL llama_index_tools_agentsearch-0.3.0-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13f1d3140093a5a88cd819a6506427b241ce1a5c738a7cdfb0557773e7d52e2f
BLAKE2b-256 checksum
How to use checksums
1c10ae4418f12d6e9e5266af0e845a65149caa3ab95079c12000d6ab2e73db2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for llama-index-tools-agentsearch 0.3.0

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