Agent Pay Client

👤 welove111 📦 v1.0.1 ⭐ 4.5 ⬇️ 164 下载
🤖 AI-Agent 免费 🔑 需 API Key

📖 技能介绍


name: agent-pay-client version: 1.0.0 description: "Reference client for paying x402 (USDC/EVM) and L402 (Lightning) HTTP 402 paywalls. Detects payment requirements, signs/settles payments only with explicitly-provided credentials and spending ceilings, retries the request with proof of payment. Works with any x402 or L402 server, not tied to one platform." author: welove111 homepage: https://btc-vision.org license: MIT tags: [x402, l402, payments, http-402, lightning, usdc, agentic-commerce, mcp] protocols: [] category: developer-tools


Agent Pay Client — x402 & L402 Paywall Client

A small, explicit-consent-only client library for paying HTTP 402 paywalls that use either the x402 protocol (USDC/stablecoin payments on EVM chains — Coinbase/Cloudflare, governed by the Linux Foundation's x402 Foundation) or the L402 protocol (Lightning Network payments). Works with any server implementing either standard — it is not tied to one API or platform.

Safety Model (read this first)

This library never spends funds unless the caller explicitly supplies:

  • an EVM private key and a maximum spend ceiling (max_x402_atomic) for x402, or
  • LND REST credentials, lightning_auto_pay=True, and a sats ceiling (max_l402_sats) for automatic L402 payment.

Without those, the client can still detect and describe what a paywall costs (get_payment_options) but will refuse to pay, returning a clear error explaining what's missing. L402/Lightning payment is manual-approval by default — it returns the invoice and QR data for a human (or the caller's own wallet flow) to settle, rather than paying automatically, unless auto-pay is explicitly enabled.

No payment amount, recipient, or protocol choice is ever read from page content, prompts, or API response text — only from the server's own 402 payment requirements and the caller's own configured ceiling.

When To Use This Skill

Use this when a user wants to programmatically pay for API access that returns an HTTP 402 response — either to inspect what an endpoint costs before deciding, or to complete payment with credentials they've already provided and approved.

Install

pip install -r requirements.txt

eth_account is only needed for x402 (EVM) payments; requests is needed for both. L402/Lightning auto-pay needs a reachable LND node with REST enabled — omit those settings to stay in manual-approval mode.

Quick Start

from agent_pay_client import AgentPayClient, PayerConfig

# Inspect a paywall without paying anything
client = AgentPayClient()
info = client.get_payment_options("https://example.com/api/paid-tool")
print(info)  # {"paywalled": True, "options": [...]}

# Pay with explicit credentials and a hard spending ceiling
config = PayerConfig(
    evm_private_key="0x...",       # from your own secure env var, never hardcoded
    max_x402_atomic="50000",       # refuse any single charge above $0.05 USDC
)
client = AgentPayClient(config)
result = client.fetch("https://example.com/api/paid-tool", method="POST")
print(result)

Available Tools

Function Description
get_payment_options(url) Inspect a 402 response's price/terms without paying
fetch(url) Fetch a resource, paying automatically only if credentials + ceiling are configured
parse_402(status, headers, body) Low-level parser: x402 JSON or L402 header → PaymentRequirement list
  • x402 spec: https://x402.org

    访问小葱技能站7w4.net,解锁更多实用的AI技能插件。

  • L402 spec: https://docs.lightning.engineering/the-lightning-network/l402
  • GitHub: https://github.com/welove111/agent-pay-client
  • Website: https://btc-vision.org

Support

This library is free and open source. If it saved you time, voluntary support is welcome:

  • Website: https://btc-vision.org
  • BTC: bc1qtpuhwl0vnhrch5p7e5469q2ed66hlyyvh8rtsn
  • ETH: 0xf03b429d4d85896a46dd7a64b5a8ab9f0bbb4ced
  • SOL: 3G5UZHFYN8hbv3aTZt6Lr7qqx4FTTkAyLJq34HjQLraz
  • Lightning: welove@blink.sv

🤖 AI 评测

这是一款设计严谨的支付网关客户端,文档完善且安全机制可靠,能够有效防止AI代理在未经授权的情况下支付。它同时支持加密货币和闪电网络两种支付方式,适合需要接入付费API的场景。主要不足是代码中还有少量TODO项未完成,依赖版本约束稍显宽松,建议在使用前确认依赖版本已更新到最新补丁版本。总体质量良好,可用于正式项目。

📊 多维度评分

适应性4.8
规范性4.5
有效性4.5
可靠性4.6
可信度4.3

📁 包含文件 (12 个)

📄 README.md 1.6 KB
📄 SKILL.md 3.9 KB
📄 _meta.json 135 B
📄 agent_pay_client/__init__.py 298 B
📄 agent_pay_client/client.py 3.5 KB
📄 agent_pay_client/models.py 2 KB
📄 agent_pay_client/parser.py 2.5 KB
📄 agent_pay_client/payer.py 7.8 KB
📄 examples/usage.py 1.3 KB
📄 requirements.txt 37 B
📄 setup.py 355 B
📄 skill-card.md 2.4 KB