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

小蔥技能有更好的技能skills外掛。


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
  • 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