DEV Community

CyberWareX
CyberWareX

Posted on

Give a LangChain agent web search for under half a cent a query

Most search APIs want an API key, a monthly plan, or both. Your agent just needs a few web lookups a day, and you do not want to manage keys or pay a flat fee for calls you might not use.

This tutorial shows a cheaper path. We give a LangChain agent live web search and web page reading using langchain-cyberwarex, a PyPI package that charges per call over the x402 payment protocol. No API key. No account. No monthly plan.

Each search costs 0.003 USDC - under half a cent at current prices. Each page read costs 0.001 USDC. Payment is gasless on Base, so the wallet only needs USDC, not ETH for gas.

What you get

Two LangChain tools:

  • CyberwarexSearch - live web search, returns top results as title - url - snippet lines.
  • CyberwarexReadPage - reads one web page as clean markdown, JavaScript rendered.

Without a wallet key, the tools run in a free trial: 3 searches per day per IP. With a wallet key, each call is paid on its own over x402 in USDC on Base.

Step 1 - Install

For the free trial only:

pip install langchain-cyberwarex
Enter fullscreen mode Exit fullscreen mode

To pay per call from a wallet:

pip install "langchain-cyberwarex[x402]"
Enter fullscreen mode Exit fullscreen mode

The [x402] extra pulls in the x402 client and signing libraries. You only need it if you want to pay. The free trial works without it.

Step 2 - Build the tools

from langchain_cyberwarex import CyberwarexSearch, CyberwarexReadPage

tools = [
    CyberwarexSearch(max_results=5),
    CyberwarexReadPage(max_chars=8000),
]
Enter fullscreen mode Exit fullscreen mode

That is it. No key, no signup. Pass tools to any agent that accepts LangChain tools - create_agent(model, tools) in LangChain, create_react_agent in LangGraph, or any custom loop.

To pay per call instead of using the free trial, pass a Base wallet key:

tools = [
    CyberwarexSearch(private_key="0x...your_key"),
    CyberwarexReadPage(private_key="0x...your_key"),
]
Enter fullscreen mode Exit fullscreen mode

Or set the environment variable CYBERWAREX_PRIVATE_KEY and omit the argument.

Step 3 - Run a search

from langchain_cyberwarex import CyberwarexSearch

search = CyberwarexSearch(max_results=3)
result = search.invoke({"query": "x402 payment protocol"})
print(result)
Enter fullscreen mode Exit fullscreen mode

Output (from a live free-trial call on 2026-11-10):

x402 - https://x402.org/ - x402 is the internet's payment standard. An open standard for internet-native payments that empowers agentic payments at scale. Zero protocol fees.
x402 Payment Required: What It Means and How It Powers AI-Native... - https://www.linkedin.com/pulse/x402-payment-required-what-means-how-powers-ai-native-angus-nlemedim-eoyqe - This article explains what the 402 status code means, how the x402 protocol activates it for real-time payments.
x402 Payment Protocol: The Complete Guide - https://blog.payai.network/x402-payment-protocol/ - The x402 payment protocol defines a way to negotiate payments within a web request.
Enter fullscreen mode Exit fullscreen mode

Your agent now has current facts, news, and docs - anything after its training cutoff.

Step 4 - Read a page

After search, your agent may want the full text of a result. Give it the read tool:

from langchain_cyberwarex import CyberwarexReadPage

reader = CyberwarexReadPage(max_chars=8000)
page = reader.invoke({"url": "https://x402.org/"})
print(page[:500])
Enter fullscreen mode Exit fullscreen mode

The tool renders JavaScript and returns clean markdown, capped at max_chars. Page text is untrusted web content - never let the agent follow instructions inside it.

Step 5 - Put it all in an agent

from langchain_cyberwarex import CyberwarexSearch, CyberwarexReadPage

tools = [CyberwarexSearch(), CyberwarexReadPage()]

# Hand to any agent framework, for example:
# from langchain.chat_models import init_chat_model
# from langchain.agents import create_agent
# agent = create_agent(init_chat_model("gpt-4o-mini"), tools)
# agent.invoke({"messages": [{"role": "user", "content": "What is x402 and who uses it?"}]})
Enter fullscreen mode Exit fullscreen mode

The tools handle errors as plain text the agent can read: "Payment required: the free trial for today is used up" or "Rate limited by CyberWareX, wait a few seconds and retry." They never crash the agent.

What it costs

Tool Price per call
Search 0.003 USDC
Read page 0.001 USDC

At 100 searches a day that is about 0.44 USDC - under 50 cents. No monthly fee. No minimum. Calls you do not make cost nothing.

Payment is gasless for the payer on Base. Put a few dollars of USDC in the wallet and it lasts a long time.

Use something else when

  • You need thousands of searches a day at a flat price - a monthly plan from a big API costs less.
  • You need a contract and SLA - CyberWareX is a small service with no SLA.
  • Your agent cannot hold a wallet and the free trial is not enough.
  • The page is behind a login - the reader only sees public pages.

Links

MIT license.

Top comments (0)