Agent 配套工具

routeweiler|为 AI Agent 处理 HTTP 402 付费的异步 Python 客户端

routeweiler

Routeweiler 是一个 Python 异步 HTTP 客户端,当请求遇到 402 Payment Required 时,自动在 x402、L402 和 MPP 通道之间选择路径完成支付,并支持预算上限与调用追踪。

获取与使用

需要部署

按官方资料自行安装或部署

使用难度待核验
国内可用性待核验

2026-11-09 更新 · 本站尚未实测

项目介绍

Agent 配套工具 · 2026-11-09 更新 · 本站尚未实测

Routeweiler 是一个 Python 异步 HTTP 客户端,README 将其定位为“面向 AI Agent 集群的金融操作系统”。它把普通 HTTP 请求封装为 await routeweiler.get(url),当目标服务返回 402 Payment Required 时,客户端会读取支付挑战,并根据已配置的资金源与策略选择一条支付通道完成付款,然后继续请求。

仓库自述状态为 Beta,采用 SemVer 发版,0.x 小版本升级可能包含破坏性变更。项目面向的是需要调用按次计费 API 的开发者,不是通用聊天助手或可视化应用。

核心能力

点击能力名称查看输入、输出和原文依据。

  • 402 支付拦截与自动处理:README 说明客户端可透明处理 402,覆盖 x402(EVM)、L402(Lightning)、MPP-Tempo(稳定币)与 MPP-SPT(Stripe)四类通道。
  • 多通道资金源:x402 与 MPP-Tempo 通过 eth_account.LocalAccount 签名;L402 通过 LND gRPC 客户端支付 BOLT-11 发票;MPP-SPT 由 Stripe 托管卡信息并签发共享支付令牌。
  • 路由选择:可同时传入多个资金源,路由器按服务端接受的通道与 Policy 选择路径。
  • 预算信封(Budget Envelope):基于本地 SQLite 设置单会话或单 Agent 的消费上限、允许通道与有效期,记录预留与结算金额,超限抛出 BudgetExceededError。
  • 本地追踪:TraceSink.sqlite 会为每次调用(无论是否付费)写入一条 TraceEvent,含链上交易哈希与支付结果。
  • 策略控制:可通过 Policy 与 PolicyRule 按主机或完整 URL 匹配,拒绝特定地址或限制单次调用金额。

README 强调私钥等密钥材料保留在用户进程内,README 声称 Routeweiler 不传输私钥,本站未审计该安全承诺。

实际应用场景

适用场景

  • 调用按次付费的 AI 数据或推理 API,需要在代码中自动完成小额支付。
  • 需要给多个 Agent 分别设定消费上限并保留审计记录的团队。
  • 已持有 Base 链 USDC、LND 节点或 Stripe 支付资料的开发者,希望统一接入多种付费协议。

不适用的场景包括:没有区块链或 Stripe 支付账户、仅需普通免费 HTTP 请求、以及希望开箱即用的非开发者用户。

安装与接入

README 给出的安装方式为:

pip install routeweiler

要求 Python 3.11+。稳定版使用 pip install routeweiler,预发布版使用 pip install --pre routeweiler。

最小接入形态为:导入 Routeweiler 与 Funding,用 eth_account 从环境变量读取私钥构造钱包,传入 Funding.base_usdc(wallet=...),然后在异步上下文中发起请求。L402 需要自备运行中的 LND 节点并提供 admin macaroon 与 TLS 证书;MPP-SPT 需要 Stripe 密钥、客户 ID 与已保存的支付方式 ID。

资料未提供 MCP 配置、客户端配置文件或可视化管理界面,相关接入方式待核验。

使用条件与限制

是否需要部署
需自行准备运行环境,具体要求见正文
是否需要注册
账号和认证要求见正文;未明确说明的项目仍待核验
是否需要 API Key
待核验
费用与额度
费用边界见正文,项目许可不代表模型或托管服务免费
所需权限
待核验
许可证与服务条款
待核验

权限费用与限制

  • 资金权限:x402 与 MPP-Tempo 需要 EVM 私钥;L402 需要 LND 节点的 admin macaroon(权限较高,建议单独隔离);Stripe 需要 secret API key。这些凭据应妥善保管。
  • 真实扣款:README 的示例指向 Base 主网(chain 8453)与 Tempo 主网,使用主网配置会产生真实支出;测试网配置另行提供。
  • 费用边界:仓库代码以 Apache 2.0 发布,但不代表链上 Gas、支付通道费用、Stripe 手续费或托管服务免费。官方是否提供付费服务与具体价格,资料未说明,需向官方核验。
  • 预算限制:README 明确,未设置 budget_envelope 时追踪仍工作,但不执行任何上限。
  • 合规与地区:涉及加密货币与跨境支付的可用性、合规要求未在资料中说明,需用户自行核验所在地规定。

国内使用情况

网友核验 用户经验分享

与站长实测独立,不代表官方认证或本站已实测。

我要核验
0 位参与者0 份有效分项记录

最近核验:暂无有效核验。参与人数按当前项目有效身份去重;不同核验项分别统计,不合并成用户总结果。仅统计审核通过且未过期的记录。

分项统计、有效期与样本量
核验项目有效人数成功 / 部分 / 失败 / 无法判断成功率最近核验 / 有效期
官方网站访问00 / 0 / 0 / 0样本不足暂无 / 7 天
GitHub 仓库访问00 / 0 / 0 / 0样本不足暂无 / 7 天
安装与运行00 / 0 / 0 / 0样本不足暂无 / 30 天
官方服务国内连接 / MCP 连接00 / 0 / 0 / 0样本不足暂无 / 30 天
国内网络情况00 / 0 / 0 / 0样本不足暂无 / 7 天
国内模型兼容性00 / 0 / 0 / 0样本不足暂无 / 30 天
自定义 API00 / 0 / 0 / 0样本不足暂无 / 30 天
海外服务依赖
00 / 0 / 0 / 0样本不足暂无 / 30 天
海外账号要求
00 / 0 / 0 / 0样本不足暂无 / 30 天
中文界面
00 / 0 / 0 / 0样本不足暂无 / 30 天
客户端兼容性00 / 0 / 0 / 0样本不足暂无 / 30 天
账号及费用信息
00 / 0 / 0 / 0样本不足暂无 / 30 天

成功率 = 成功 ÷(成功 + 部分成功 + 失败);无法判断不计入分母。至少 5 份可判断结果才显示成功率。账号、费用、海外依赖与语言等事实项,成功表示核查结论与资料吻合,具体观察另行统计;不表示免费或没有海外依赖。不同网络、客户端和版本的结果不能直接等同。

最近有效核验

暂无审核通过且未过期的网友核验。欢迎提交真实使用记录。

查看全部有效核验 →

国内实测状态:国内可用性待核验。协议兼容和官方资料说明不等于国内网络可用。

官方网站访问
尚未实测 待核验
GitHub 仓库访问
尚未实测 待核验
官方服务国内连接
尚未实测 待核验
国内网络情况
尚未实测 待核验
国内模型兼容性
尚未实测 待核验
自定义 API
尚未实测 待核验
海外服务依赖
尚未实测 待核验
海外账号要求
尚未实测 待核验
中文界面
尚未实测 待核验
国内最后核验时间
尚未实测

许可与国内使用

仓库包含 Apache License 2.0 许可证文件,适用于该仓库的代码。第三方协议、Stripe 服务、LND 节点、Base 与 Tempo 网络各有独立条款,不在此许可证覆盖范围内。仓库主页与文档站点存在,但域名不代表服务部署地域。

README 未提及对中国大陆网络环境的支持情况,也未说明是否支持国内支付渠道或国内模型,这些均待核验。仓库当前未被标注为归档。

项目资料与来源

官方网站 ↗

GitHub 仓库 ↗

官方文档 ↗

字段依据与待核验事项

access:来源确认 · pip install routeweiler

project_type:来源确认 · The financial operating system for AI agent fleets. An async HTTP client — `await routeweiler.get(url)` — that transparently handles `402 Payment Required`

原始 README(折叠技术参考)
# routeweiler

<p align="center">
  <img src="https://raw.githubusercontent.com/nikoSchoinas/routeweiler-python-sdk/main/assets/routeweiler.png" alt="Routeweiler" width="720">
</p>

<p align="center">
  <a href="https://github.com/nikoSchoinas/routeweiler-python-sdk/actions/workflows/ci.yml?query=branch%3Amain"><img src="https://img.shields.io/github/actions/workflow/status/nikoSchoinas/routeweiler-python-sdk/ci.yml?branch=main&style=for-the-badge&label=build" alt="Build status"></a>
  <a href="https://pypi.org/project/routeweiler/"><img src="https://img.shields.io/pypi/v/routeweiler?style=for-the-badge" alt="PyPI version"></a>
  <a href="https://pypi.org/project/routeweiler/"><img src="https://img.shields.io/pypi/dm/routeweiler?style=for-the-badge" alt="PyPI downloads"></a>
  <a href="https://pypi.org/project/routeweiler/"><img src="https://img.shields.io/pypi/pyversions/routeweiler?style=for-the-badge&logo=python&logoColor=white" alt="Python versions"></a>
  <a href="https://codecov.io/gh/nikoSchoinas/routeweiler-python-sdk"><img src="https://img.shields.io/codecov/c/github/nikoSchoinas/routeweiler-python-sdk?style=for-the-badge" alt="Coverage"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache_2.0-blue?style=for-the-badge" alt="License: Apache-2.0"></a>
  <img src="https://img.shields.io/badge/status-beta-blue?style=for-the-badge" alt="Status: Beta">
  <a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/badge/code%20style-ruff-261230?style=for-the-badge" alt="Code style: Ruff"></a>
  <img src="https://img.shields.io/badge/type%20checked-mypy-1f5082?style=for-the-badge" alt="Type-checked with mypy">
</p>

The financial operating system for AI agent fleets. An async HTTP client —
`await routeweiler.get(url)` — that transparently handles `402 Payment Required` across
x402 (EVM), L402 (Lightning), MPP-Tempo (stablecoin), and MPP-SPT (Stripe), routes to the best rail, enforces spend caps, recovers credentials, emits audit traces, and keeps your keys entirely in your own process.

**Documentation:** [docs.routeweiler.com](https://docs.routeweiler.com)

<p align="center">
  <img src="https://raw.githubusercontent.com/nikoSchoinas/routeweiler-python-sdk/main/assets/diagram.png" alt="Routeweiler flow diagram" width="900">
</p>

## Install

```bash
pip install routeweiler
```

Python 3.11+ required.

## Quick start

```python
import asyncio
import os
from eth_account import Account
from routeweiler import Routeweiler, Funding

signer = Account.from_key(os.environ["PRIVATE_KEY"])

async def main():
    async with Routeweiler(funding=[Funding.base_usdc(wallet=signer)]) as client:
        response = await client.get("https://api.example.com/data")
        print(response.json())

asyncio.run(main())
```

## Supported rails

| Rail | Method | Funding source | Networks |
|------|--------|---------------|----------|
| [x402](https://x402.org) | EVM signed transaction | `EvmFundingSource` | Base, Base-Sepolia |
| [L402](https://docs.lightning.engineering/the-lightning-network/l402) | BOLT-11 Lightning invoice | `LightningFundingSource` | Bitcoin, Regtest |
| [MPP-Tempo](https://paymentauth.org) | Tempo 0x76 stablecoin tx | `TempoFundingSource` | Moderato testnet |
| [MPP-SPT](https://docs.stripe.com/agentic-commerce) | Stripe Shared Payment Token | `StripeFundingSource` | USD, EUR, GBP |

## Funding sources

Each rail accepts a typed `FundingSource` holding the credentials it uses to sign or authorise payments. Key material stays in your process; Routeweiler never transmits private keys.

### x402 — `EvmFundingSource`

An `eth_account.LocalAccount` that signs EIP-3009 `transferWithAuthorization` for USDC on Base.

```python
from eth_account import Account
from routeweiler import Funding

wallet = Account.from_key(os.environ["PRIVATE_KEY"])  # 64-char hex secp256k1 key, 0x prefix optional
funding = Funding.base_usdc(wallet=wallet)            # mainnet (chain 8453)
# funding = Funding.base_sepolia_usdc(wallet=wallet)  # testnet (chain 84532)
```

### L402 — `LightningFundingSource`

Wraps an LND gRPC client. Bring a running LND node and pass its admin macaroon + TLS cert; Routeweiler pays BOLT-11 invoices through it.

```python
from routeweiler.funding.lightning import LightningFundingSource, LndClient

lnd = LndClient(
    grpc_host="localhost",
    grpc_port=10009,
    macaroon_path="/path/to/admin.macaroon",
    tls_cert_path="/path/to/tls.cert",
)
funding = await LightningFundingSource.create(lnd, network="bitcoin")
# network: "bitcoin" | "bitcoin-testnet" | "bitcoin-regtest" | "bitcoin-signet"
```

### MPP-Tempo — `TempoFundingSource`

Signs Tempo's type-0x76 charge transactions with an `eth_account.LocalAccount` — same key shape as x402, different chain. The same wallet can fund both rails.

```python
from eth_account import Account
from routeweiler import Funding

wallet = Account.from_key(os.environ["PRIVATE_KEY"])  # 64-char hex secp256k1 key, 0x prefix optional
funding = Funding.tempo_usdc(wallet=wallet)              # mainnet, USDC
# funding = Funding.tempo_pathusd_moderato(wallet=wallet)  # testnet, pathUSD
```

### MPP-SPT — `StripeFundingSource`

No on-device signing. Stripe holds the card; you supply a secret API key, a customer id, and a saved payment method id. Routeweiler asks Stripe to mint a Shared Payment Token at pay-time.

```python
from routeweiler import Funding

funding = Funding.stripe(
    api_key=os.environ["STRIPE_API_KEY"],   # sk_live_... / sk_test_...
    customer="cus_ABC123",                  # buyer's Stripe customer id
    payment_method="pm_XYZ789",             # saved card / bank
    currency="usd",                         # ISO-4217: usd | eur | gbp | ...
)
```

Pass any combination to `Routeweiler(funding=[...])`. The router picks the best rail per challenge based on [Policy](#policy) and what the server accepts.

## SQLite trace recorder

Enable local tracing with `TraceSink.sqlite`. Every call (paid or free) produces
exactly one `TraceEvent` row, including the on-chain tx hash and the payment outcome:

```python
from routeweiler import Routeweiler, Funding, TraceSink

async with Routeweiler(
    funding=[Funding.base_usdc(wallet=signer)],
    trace_sink=TraceSink.sqlite("./routeweiler.db"),
) as client:
    response = await client.get("https://api.example.com/data")

# Inspect with the sqlite3 CLI:
# sqlite3 ./routeweiler.db \
#   'SELECT request_id, selected_rail, http_status FROM trace_events;'
```

## Budget envelopes

Enforce per-session or per-agent spend caps with local SQLite budget envelopes.
Without a `budget_envelope`, tracing still works but **no cap is enforced**.

```python
from routeweiler import BudgetEnvelope, Funding, Routeweiler, TraceSink

async with Routeweiler(
    funding=[Funding.base_usdc(wallet=signer)],
    trace_sink=TraceSink.sqlite("routeweiler.db"),
    budget_envelope=BudgetEnvelope(
        id="session-abc",
        cap_minor_units=500,           # 5.00 USD (in cents)
        cap_currency="usd",
        allowed_rails=["x402", "l402"],
        ttl_seconds=3_600,             # 1 hour
    ),
) as client:
    response = await client.get("https://api.example.com/data")
```

`budget_envelope` accepts three forms:

- **`None`** (default) — no cap enforcement.
- **`str`** — ID of a pre-existing envelope; raises `EnvelopeNotFoundError` at
  construction time if the row is missing.
- **`BudgetEnvelope`** — declarative spec; If an envelope with the same `id` already exists it is reused unchanged.

Envelopes track reserved and settled amounts with Ed25519-signed draw receipts.
`BudgetExceededError` is raised if a payment would breach the cap.

## Policy

Control which rails are used, set per-call spend limits, or deny specific URLs:

```python
from routeweiler import Policy, PolicyRule, RuleMatch, Routeweiler

async with Routeweiler(
    funding=[...],
    policy=Policy(
        currency="usd",          # reference currency for max_per_call_minor_units
        rules=[
            PolicyRule(
                name="deny analytics",
                when=RuleMatch(url_matches="*.tracking.io"),
                deny=True,
            ),
            PolicyRule(
                name="cap per call",
                when=RuleMatch(url_matches="*"),
                max_per_call_minor_units=500,  # 5 USD cents
            ),
        ]
    ),
) as client:
    ...
```

`url_matches` patterns without a `/` are host globs matched case-insensitively against
the URL's hostname (`*.tracking.io` matches `https://api.tracking.io/v1/events`); patterns
containing `/` are matched against the full URL (`https://api.example.com/*`).

`max_per_call_minor_units` requires a reference currency to compare rail-native quotes
against. Set `Policy(currency="usd")` (or any supported currency) when no
`budget_envelope` is configured. The envelope's `cap_currency` takes precedence when
both are present. If neither is provided and a rule uses `max_per_call_minor_units`,
`Routeweiler` raises `ValueError` at construction time.

## Releases

Releases follow [SemVer](https://semver.org). Pre-1.0 minors (`0.1.0 → 0.2.0`) may include breaking changes.

| Tag format | Channel | Install |
|---|---|---|
| `v0.2.0` | Stable | `pip install routeweiler` |
| `v0.2.0b1` | Beta | `pip install --pre routeweiler` |

## License

Apache 2.0 — see [LICENSE](../../LICENSE).
历史前置条件说明(补充参考)

Python 3.11+;x402 与 MPP-Tempo 需要 EVM 私钥与链上资金;L402 需要运行中的 LND 节点、admin macaroon 与 TLS 证书;MPP-SPT 需要 Stripe secret API key、客户 ID 与已保存支付方式;主网操作产生真实费用;官方是否提供收费服务及价格待核验;国内网络与支付渠道兼容性待核验。

项目来源与清单版权许可

https://github.com/nikoSchoinas/routeweiler-python-sdk

整理来源:https://github.com/slavakurilyak/awesome-ai-agents

清单版权与许可:

MIT License

Copyright (c) 2024 Slava Kurilyak

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.