llama-index-tools-twosio
LlamaIndex tools for 2s.io — pay-per-call AI agent APIs on Base via the x402 protocol.
No signup. No API keys. No monthly fees. Just a USDC-funded EVM wallet on Base mainnet. Each call settles per-request in USDC.
pip install llama-index-tools-twosio
import asyncio
import os
from llama_index_tools_twosio import get_twosio_tools
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.anthropic import Anthropic
tools = get_twosio_tools(private_key=os.environ["EVM_PRIVATE_KEY"])
agent = FunctionAgent(tools=tools, llm=Anthropic(model="claude-haiku-4-5"))
response = asyncio.run(agent.run("Find recent patents for 'neural network beamforming'."))
print(response)
The agent picks the right 2s.io endpoint, calls it, pays in USDC, and returns the result — transparent to your model.
What's in the box
Each tool wraps one 2s.io endpoint with a clear description and a typed pydantic schema. The curated set covers the highest-leverage workflows:
| Tool | Endpoint | What it does | Price |
|---|---|---|---|
twosio_patents_search |
patents.search |
USPTO patent application search | $0.0018 |
twosio_papers_search |
papers.search |
Unified arXiv + PubMed + Semantic Scholar search | $0.0024 |
twosio_law_case_search |
law.case-search |
US court opinion discovery (~9M opinions) | $0.0036 |
twosio_law_case_verify |
law.case-verify |
Citation anti-hallucination check | $0.006 |
twosio_law_sanctions_check |
law.sanctions-check |
OFAC SDN screening (KYC/AML) | $0.0048 |
twosio_wikipedia_summary |
wikipedia.summary |
Wikipedia REST API summary | $0.001 |
twosio_weather_zip |
weather.zip |
US NWS current weather by ZIP | $0.0012 |
twosio_geocode_address |
geocode.address |
Address → lat/lon (LocationIQ) | $0.001 |
twosio_ai_summarize |
ai.summarize |
URL → concise summary (Tier 2, LLM-backed) | $0.0225 |
twosio_crypto_gas_oracle |
crypto.gas-oracle |
Live EVM gas oracle | $0.001 |
The full 2s.io catalog has 39 endpoints. To use one not in the curated set, build a tool manually:
from llama_index_tools_twosio import twosio_tool
from llama_index_tools_twosio._endpoints import EndpointSpec, Param
from twosio import TwoS
client = TwoS(private_key=os.environ["EVM_PRIVATE_KEY"])
custom = twosio_tool(client, EndpointSpec(
name="twosio_dns_lookup",
short_name="dns.lookup",
description="Resolve a hostname against public DNS resolvers.",
sdk_path=("dns", "lookup"),
params=[
Param("name", str, "Hostname to resolve."),
Param("type", str, "Record type (A | AAAA | MX | TXT | NS).", required=False),
],
))
The full live catalog: https://2s.io/api/directory · OpenAPI: https://2s.io/api/openapi.
Filters
# Only the legal tools:
tools = get_twosio_tools(private_key=KEY, include=["law.case-search", "law.sanctions-check"])
# Everything except the LLM-backed (Tier 2) ones:
tools = get_twosio_tools(private_key=KEY, exclude=["ai.summarize"])
How payment works
Every tool call runs through the underlying 2sio SDK, which:
- Hits the 2s.io endpoint.
- Receives
HTTP 402 Payment Requiredwith an x402 envelope (price + recipient + EIP-3009 challenge). - Signs the
transferWithAuthorizationwith your private key. - Retries with the signed payload.
- Returns the response. The
meta.settlementblock in each result includes the on-chain tx hash.
You only pay for successful calls.
License
MIT.
Links
- 2s.io: https://2s.io
- Source: https://github.com/2s-io/sdk
- Issues: https://github.com/2s-io/sdk/issues
- Underlying SDK:
2sioon PyPI
Metadata
Release files for llama-index-tools-twosio 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| llama_index_tools_twosio-0.1.4.tar.gz | 7.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llama_index_tools_twosio-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.7 kB
Release files / llama_index_tools_twosio-0.1.4.tar.gz
| Download URL | llama_index_tools_twosio-0.1.4.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f62997ab9cfe5c0277d42b1e855cce9d23dd60d15cd11a96a94693862bccc1d4
|
|
BLAKE2b-256 checksum How to use checksums |
4a87aacc226594aafd91275d625f392a40ad85f97fe33a72406c96f49cd29962
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / llama_index_tools_twosio-0.1.4-py3-none-any.whl
| Download URL | llama_index_tools_twosio-0.1.4-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e181e28907fd9c2231abac2181b134a915c1f3906c9ed68b863e5e4da905f04
|
|
BLAKE2b-256 checksum How to use checksums |
91088d4dd135be8713668b78c8db8b599d22ebea7e9ada2b22130caf357c8d3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for llama-index-tools-twosio 0.1.4
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.