aegis-router
One-shot agent payments for Python APIs. Wrap a FastAPI app in five lines so AI agents can discover it, trust it, and pay for it — x402 (USDC on Base) and MPP (Machine Payments Protocol, Tempo) from the same route, with spec-current discovery docs, a local revenue ledger, and the Aegis trust layer built in.
from fastapi import FastAPI
from aegis_router import PaidAPI
app = FastAPI()
api = PaidAPI(app, pay_to="0xYourAddress", realm="api.example.com")
@api.paid("$0.01", example={"result": "…"})
@app.get("/paid/search")
async def search(q: str):
return {"result": do_search(q)}
api.install()
That route now:
- answers 402 Payment Required with BOTH an x402
payment-requiredchallenge and an MPPWWW-Authenticate: Paymentchallenge — buyers pay with whichever rail their client speaks; - verifies x402 payments via your facilitator and MPP payments directly against Tempo RPC (replay-protected, no facilitator needed);
- appears in
/openapi.jsonwithx-payment-info, in a generated/llms.txt, and in/.well-known/x402— all derived from the same registry that charges, so advertised price and wire price can never drift; - logs every call and every settlement (rail, payer, tx reference) to a local SQLite ledger — you know you're being paid, and by whom, from minute one;
- returns the reason in the 402 body when a payment fails, instead of silently not getting paid.
Install
pip install aegis-router # + aegis-buy client: pip install 'aegis-router[aegis]'
Python ≥ 3.11. Payments stack: the official x402 SDK and pympp (Tempo Labs' MPP SDK).
Why this and not a TypeScript router
- Python-native. FastAPI/Starlette middleware, not a Next.js proxy in front of your API.
- Dual-rail, four networks. x402 challenges on Base by default (bring your own facilitator for Solana/Polygon/Arbitrum accepts) plus MPP on Tempo — every payment standard you skip is a buyer who can't pay you.
- Trust, not just payments. Making an endpoint payable is table stakes; Aegis makes it provably delivering: register once and its verifiers continuously score your liveness, challenge validity, price honesty and actual paid delivery — a score buyers check before they spend.
- A ledger in the box. Other stacks tell you to watch your wallet.
- Loud failures. Buyers get told why a payment was rejected.
Trust & discovery flywheel
aegis-router check https://api.example.com # lint your live agent-payability
aegis-router submit https://api.example.com # register with the Aegis trust hub ($0.05 via x402)
aegis-router summary # local revenue by rail
Then register with the scanners: x402scan and mppscan.
Configuration
| Argument | Default | Notes |
|---|---|---|
pay_to |
— | EVM address receiving USDC (x402, Base) |
realm |
— | Your public host, e.g. api.example.com |
mpp_recipient |
pay_to |
Tempo address receiving Tempo USDC |
mpp_secret_key |
MPP_SECRET_KEY env |
HMAC secret binding challenge ids; set it in production |
facilitator |
https://facilitator.xpay.sh |
Any x402 facilitator |
network |
eip155:8453 |
x402 settlement network |
ledger_path / replay_path |
./aegis-router-*.db |
SQLite files |
enable_mpp / enable_x402 |
True |
Run single-rail if you must |
Per-route: api.price(path, price, method=, description=, example=, input_example=, input_schema=, mpp=) or the @api.paid(...) decorator.
Agent-assisted setup
Point your coding agent at https://aegis.borisinc.com/merchants.md and tell it:
Read https://aegis.borisinc.com/merchants.md and follow the guide to make my API discoverable and payable by agents. Only ask me questions if you need input you can't determine yourself.
License
MIT. Built and operated in production by Boris Inc — every borisinc.com service runs this exact stack on mainnet.
Release files for aegis-router 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aegis_router-0.1.0.tar.gz | 13.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aegis_router-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.1 kB
Release files / aegis_router-0.1.0.tar.gz
| Download URL | aegis_router-0.1.0.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4705431dc581aa48db937fe3b6fed9b2417f8b5192353e12ac23212e3800cd8
|
|
BLAKE2b-256 checksum How to use checksums |
68522441c02340e1bfc427bed1cbfcd8b24babcef8879fcfbc22f70169b93355
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / aegis_router-0.1.0-py3-none-any.whl
| Download URL | aegis_router-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73cf06d4518bf16d560ef022007f76a30c5790145a9716fe36936feb1e1b2fec
|
|
BLAKE2b-256 checksum How to use checksums |
c81fa8cfac41a005c40b4cb7b9d0a9137266b19bf7b859ae8e54cda9cec10673
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|