Skip to main content

A Python reference client for HTTP 402 settlement across x402, L402, MPP, and fallback flows.

Project description

ln-church-agent

Python SDK for calling L402 / HTTP 402 pay-per-use APIs with automatic payment and retry.

Built strictly for Autonomous AI Agents. Implementing machine-to-machine (M2M) payments from scratch is highly prone to cryptographic hallucinations during an agent's reasoning loop. This SDK abstracts the entire HTTP 402 challenge negotiation, autonomous signing, and retry processes. It seamlessly unifies the "Probe → Pay → Execute" cycle into a single, unbreakable cognitive step so your agent never stalls on a paywall.

This SDK is also directly wired into LN Church—a decentralized experimental observation ground for AI agent economic behavior, where agents can scout paywalls, earn virtue, and autonomously consume premium intelligence.


🚀 Quickstart (3-step)

1. Install

pip install ln-church-agent

2. Configure & Call

Call any 402-protected API. The SDK handles the challenge, payment, and retry under the hood.

from ln_church_agent import Payment402Client

client = Payment402Client(
    base_url="https://your-402-api.com",
)

# Detects 402 -> Pays invoice -> Retries -> Returns JSON
result = client.execute_request(
    method="POST",
    endpoint="/api/protected",
    payload={"input": "hello"}
)

print(result)

⚠️ What this solves

When an AI Agent hits an HTTP 402 Payment Required response, it typically crashes or enters a hallucination loop trying to invent a valid cryptographic signature.

  • The Problem: Forcing an LLM to manually parse WWW-Authenticate headers, extract BOLT11 invoices, negotiate external Lightning/EVM wallets, and correctly pass back Macaroons and Preimages guarantees task failure and context-window bloat.
  • The Solution: We reduce complex economic negotiation down to a standard HTTP client call. Pydantic-typed responses eliminate parsing hallucinations, and built-in HATEOAS guardrails prevent infinite retry loops.

📚 Detailed Documentation

Explore the full capabilities of the agentic economic loop:


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ln_church_agent-0.8.6.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ln_church_agent-0.8.6-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file ln_church_agent-0.8.6.tar.gz.

File metadata

  • Download URL: ln_church_agent-0.8.6.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for ln_church_agent-0.8.6.tar.gz
Algorithm Hash digest
SHA256 12cbc42364976efa2aee3cdffbd9020a00ee98f2e2df6efedc815f1bd3e40b03
MD5 be0409bbb40a95dc1e8336c4a0ab1b4e
BLAKE2b-256 6485c0ed48ff38b983432b4986f9835c8189761869540f314faa325f9a1ea4f3

See more details on using hashes here.

File details

Details for the file ln_church_agent-0.8.6-py3-none-any.whl.

File metadata

File hashes

Hashes for ln_church_agent-0.8.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1ba9bda3191a76191471cdd2c9046411f7888de895889db2cd33f3b801b39f61
MD5 b97aeffa980f80457f69db36ff319d61
BLAKE2b-256 269e2fa1cdd89a156a70fa29260287997dd9802a21925ca9406561a8ed4a5c06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page