Metadata-Version: 2.4
Name: andreax-langchain-autopay
Version: 0.1.0
Summary: LangChain toolkit for Andreax's pay-per-call x402 AI tools (USDC on Base, EIP-3009 autopay).
Author: Andreax
License: MIT
Project-URL: Homepage, https://andreax.dev
Keywords: langchain,x402,usdc,base,eip-3009,agents,autopay
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: langchain-core>=0.3
Requires-Dist: web3>=6.0
Requires-Dist: requests>=2.28
Requires-Dist: eth-account>=0.10

# andreax-langchain-autopay

LangChain toolkit for [Andreax](https://andreax.dev)'s pay-per-call AI tools: 200+ tools
discoverable and payable over **x402** (HTTP 402 + USDC on Base), no API key, no signup.

```python
from andreax_langchain_autopay import AndreaxToolkit

toolkit = AndreaxToolkit(
    wallet_address="0xYourAddress",
    private_key=None,          # optional; required only if auto_pay=True
    auto_pay=False,            # True = pay automatically within your caps
    per_call_cap_usd=0.10,
    daily_cap_usd=5.00,
)

tools = toolkit.get_tools()   # -> list[AndreaxTool], ready for a LangChain agent
```

## Autopay

With `auto_pay=True` and a `private_key`, a tool call that answers `402 Payment Required` is paid
automatically: this SDK signs an **EIP-3009 `transferWithAuthorization`** locally (your private key
never leaves the process) and retries the call with the signed payload in the `X-PAYMENT` header.
Every payment is checked against two caps first:

- `per_call_cap_usd`: reject if a single call costs more than this.
- `daily_cap_usd`: reject if today's accumulated spend (in this process) would exceed this.

Without `auto_pay` (or without a `private_key`), a paid tool call raises/returns
`PaymentRequired` with the full 402 challenge (amount, recipient, network) so you can decide.

## Direct calls (no LangChain agent)

```python
result = toolkit.call("leer-url", {"url": "https://example.com"})
```

## Status

Alpha (0.1.0). Built against Andreax's live x402 catalog and 402 challenge format.
