Metadata-Version: 2.4
Name: langchain-call402
Version: 0.1.5
Summary: LangChain tools for Call402, the x402 pay-per-call API by SteadyScrape
Author-email: "SteadyScrape S.R.L." <hello@call402.dev>
License: MIT
Project-URL: Homepage, https://call402.dev
Project-URL: Terms, https://call402.dev/terms
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: langchain-core<2,>=1.0
Requires-Dist: httpx<1,>=0.27
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"

# langchain-call402

LangChain tools for [Call402](https://call402.dev), the pay-per-call API by SteadyScrape. It wraps the existing Call402 REST routes and x402 payment flow, with no extra logic.

## Install

```bash
pip install langchain-call402
pip install "x402[evm]==2.29.0"                                  # only if you want the tool to pay
```

Tested with Python 3.13, `langchain-core==1.8.5`, `httpx==0.28.1`, `x402==2.29.0`. Declared ranges: `langchain-core>=1.0,<2`, `httpx>=0.27,<1`.

## How payment works

Call402 charges per successful call in USDC on Base (`eip155:8453`) using x402 v2, settled through the PayAI facilitator. An unpaid POST returns HTTP 402 with a `PAYMENT-REQUIRED` header (price, asset, pay-to address). If you pass a `payment_signer`, the tool hands it those requirements, sends the signed `PAYMENT-SIGNATURE` back once, and returns the result with the settlement in `payment_response`. This package holds no wallet and no keys: the signer is your code with your wallet. Without a signer, or if the signer returns `None`, the 402 is raised with the requirements attached and nothing is charged. Empty or invalid input returns 400 and is not charged. Failed, timed-out or empty results are never settled. Errors are raised, not hidden.

## Worked example

```python
# pip install "x402[evm]==2.29.0"   (tested; your wallet, your key, never ours)
import os
from eth_account import Account
from x402 import x402ClientSync
from x402.http import x402HTTPClientSync
from x402.mechanisms.evm.exact import register_exact_evm_client
from x402.mechanisms.evm.signers import EthAccountSigner
from x402.schemas import PaymentRequired

account = Account.from_key(os.environ["MY_BASE_WALLET_KEY"])  # a Base wallet holding a little USDC
x402_http = x402HTTPClientSync(register_exact_evm_client(x402ClientSync(), EthAccountSigner(account)))

def pay(payment_required: dict) -> str:
    """Sign the 402 requirements with your wallet; return the PAYMENT-SIGNATURE header."""
    payload = x402_http.create_payment_payload(PaymentRequired.model_validate(payment_required))
    return x402_http.encode_payment_signature_header(payload)["PAYMENT-SIGNATURE"]
```

```python
from langchain_call402 import get_call402_tools, Call402ToolException

tools = get_call402_tools(payment_signer=pay)           # all 32; or include=["domain_expiry"]
domain_expiry = next(t for t in tools if t.name == "domain_expiry")
print(domain_expiry.invoke({"domain": "example.com"}))  # $0.01 if a result comes back

# Without a signer the 402 comes back to you, nothing charged:
[unpaid] = get_call402_tools(include=["domain_expiry"])
try:
    unpaid.invoke({"domain": "example.com"})
except Call402ToolException as e:
    print(e.error.status, e.error.charged, e.error.payment_required["accepts"][0]["amount"])  # 402 False 10000

# In an agent: pass `tools` to any tool-calling model, e.g. model.bind_tools(tools)
# or langchain.agents.create_agent(model, tools). Set handle_errors=True if the
# agent should see the 402/400 text as the tool result instead of an exception.
```

## The 32 tools

Read from `https://api.call402.dev/v1/tools` and `/v1/pricing` on 2026-12-02. The package ships this list as `catalog.json`; pass `live_catalog=True` to read it from the API at runtime instead.

| Tool | What it does | Route | Price per successful call |
|---|---|---|---|
| `company_jobs` | Open jobs at a company | `POST /v1/jobs` | $0.01 |
| `company_profile` | Company profile from its website | `POST /v1/company-profile` | $0.01 |
| `hiring_summary` | Company hiring summary | `POST /v1/hiring-summary` | $0.02 |
| `uk_company` | UK company record (Companies House) | `POST /v1/uk-company` | $0.01 |
| `keyword_suggestions` | Keyword suggestions (autocomplete) | `POST /v1/keyword-suggestions` | $0.01 |
| `seo_audit` | Technical SEO audit of a page | `POST /v1/seo-audit` | $0.01 |
| `domain_expiry` | Domain expiry and registration (RDAP) | `POST /v1/domain-expiry` | $0.01 |
| `form_d_filings` | SEC Form D funding rounds | `POST /v1/form-d-filings` | $0.02 |
| `job_search` | Job search across career sites | `POST /v1/job-search` | $0.02 |
| `pdf_to_markdown` | PDF text to markdown | `POST /v1/pdf-to-markdown` | $0.01 |
| `patent_search` | Google Patents search and details | `POST /v1/patents` | $0.01 |
| `website_screenshot` | Website screenshot | `POST /v1/screenshot` | $0.01 |
| `product_price` | Product price and stock check | `POST /v1/product-price` | $0.01 |
| `agent_readiness` | Agent-readiness check of a site | `POST /v1/agent-readiness` | $0.005 |
| `geo_page_changes` | GEO page changes from your AI answers | `POST /v1/geo-page-changes` | $0.04 |
| `str_profit_calculator` | STR Profit Calculator (STR Profit Tracker, KeyLedgerDesigns) | `POST /v1/str-profit-calculator` | $0.01 |
| `guest_message_script` | Guest Message Script (Guest Message Library, KeyLedgerDesigns) | `POST /v1/guest-message-script` | $0.01 |
| `content_calendar` | 90-Day Content Calendar (Realtor 90-Day Content System, KeyLedgerDesigns) | `POST /v1/content-calendar` | $0.02 |
| `welcome_book` | Welcome Book Sections — Cabin & Lake House edition (KeyLedgerDesigns) | `POST /v1/welcome-book` | $0.01 |
| `prediction_markets` | Polymarket prediction market odds | `POST /v1/prediction-markets` | $0.01 |
| `remote_jobs` | Remote jobs by title and worker location | `POST /v1/remote-jobs` | $0.03 |
| `tiktok_top_ads` | Top TikTok ads (Creative Center) | `POST /v1/tiktok-top-ads` | $0.02 |
| `building_permits` | Canada building permits | `POST /v1/building-permits` | $0.01 |
| `public_tenders` | Public tenders search | `POST /v1/public-tenders` | $0.01 |
| `pdf_ocr` | Scanned PDF OCR | `POST /v1/pdf-ocr` | $0.02 |
| `bulk_file_download` | Bulk file download (ZIP + SHA-256) | `POST /v1/bulk-file-download` | $0.02 |
| `apify_store_tracker` | Apify Store Actor stats | `POST /v1/apify-store` | $0.005 |
| `wcag_quick_check` | WCAG Quick Check (automated) | `POST /v1/wcag-quick-check` | $0.01 |
| `website_clean_text` | Website to clean text (main content as markdown) | `POST /v1/website-clean-text` | $0.005 |
| `x402_check` | x402 payment setup check (pre-flight, never pays) | `POST /v1/x402-check` | $0.005 |
| `citation_check` | Citation check (does this reference exist and match?) | `POST /v1/citation-check` | $0.01 |
| `cloud_price_compare` | Cloud price compare (AWS EC2 vs Azure VM) | `POST /v1/cloud-price-compare` | $0.03 |

Base URL `https://api.call402.dev`. Discovery: `GET /v1/tools`, `GET /v1/pricing`, `GET /.well-known/x402`, and MCP at `/mcp`.

## Tests

```bash
pip install -e ".[test]" && pytest -q                     # mocked 402 / 200 / 400, no network
CALL402_LIVE=1 pytest -q -k live_unpaid                    # one unpaid production POST, expects 402, charged=false
```

Call402 is operated by SteadyScrape S.R.L. (Costa Rica). Terms: https://call402.dev/terms · Privacy: https://call402.dev/privacy · hello@call402.dev
