tryx402 — the gateway behind tryx402.app
A safe, provider-agnostic wrapper over AgentCash / x402. Not limited to prospecting — it drives any endpoint, and adds what AgentCash itself lacks and we learned we need the hard way:
- hard budget caps — stop before overspending
- idempotency — never pay twice for the same call (the $0.83 double-charge lesson)
- cost ledger — USD spent, reconciled, grouped by origin / account
- multi-currency billing + margin — end users pay in THEIR currency (EUR, USD, GBP, JPY…), never touch the wallet
Two faces, one engine
| Face | Who | Module |
|---|---|---|
| Power-tool (option 3) | you / an agent drive the whole catalogue safely | gateway.cli, gateway.client |
| Fiat gateway (option 2) | end users pay in their own currency, you resell x402 with a margin | gateway.accounts (Stripe stubbed) |
Prospecting (../prospect_relay) is just one application on top of this core.
Embed it (for agents)
Python — one import:
from gateway import Gateway
gw = Gateway(max_budget_usd=1.0) # safe by default
data = gw.call("https://stable-deepline.dev/api/email/validate",
body={"email": "x@y.com"}, price=0.03)
print(gw.spent_usd) # 0.03
Terminal — one command (like agentcash), after pip install -e .:
gateway call https://stable-deepline.dev/api/email/validate \
--body '{"email":"x@y.com"}' --price 0.03 --max-budget 0.10
MCP — the agent-native form (like AgentCash's own MCP, zero dependencies):
{
"command": "python3",
"args": ["-m", "gateway.mcp_server"],
"env": { "GATEWAY_MAX_BUDGET_USD": "1.00" }
}
The agent gets four tools — gateway_search, gateway_discover, gateway_call
(budget-capped, idempotent), gateway_spent — sharing one session-wide budget
and cost ledger across every call.
Layout
gateway/
├── client.py # SafeClient: any endpoint + budget + idempotency + timeout + ledger
├── ledger.py # cost events, USD/EUR totals, by-origin / by-account
├── catalog.py # search(intent) / discover(origin) over the AgentCash catalogue
├── accounts.py # per-currency balances (integer minor units), margin, authorize/charge — Stripe stub
├── cli.py # power-tool CLI (drives both faces)
└── tests/ # offline: budget, idempotency, EUR billing (no spend)
Use
Discover (free — no payment):
python3 -m gateway.cli search "find work email"
python3 -m gateway.cli discover https://stable-deepline.dev
Call any endpoint safely (spends USDC — budget-capped, idempotent):
python3 -m gateway.cli call https://stable-deepline.dev/api/email/validate \
--body '{"email":"foo@bar.com"}' --price 0.03 --max-budget 0.10
Run it as a fiat gateway — the caller pays in their own currency, never sees the wallet:
python3 -m gateway.cli account create acme --currency GBP --margin 0.30
python3 -m gateway.cli account fund acme --amount 20 # 20 GBP — Stripe stub
python3 -m gateway.cli call https://stable-deepline.dev/api/email/validate \
--body '{"email":"foo@bar.com"}' --price 0.03 --account acme
# -> billed 0.04 GBP to acme (margin 30%, balance 19.96 GBP)
Provider cost stays in USD (the rail settles in USDC); each account is billed in
its own currency via FxRates (a stub table today — wire a live FX feed in prod).
Non-2-decimal currencies (JPY, KWD…) are handled.
What's real vs stubbed
- Real: the safe caller, budget cap, idempotency, cost ledger, multi-currency/margin math (integer minor units), catalogue search/discover.
- Stubbed: funding an account (
fund_eur) stands in for the Stripe webhook. Wire real Stripe → callfund_euroncheckout.session.completed. Everything downstream already works. - Deliberately off: auto-retry of paid calls (default
max_retries=0) — retrying a possibly-paid call is what double-charged us; opt in only if the server honors theIdempotency-Keyheader.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tryx402-0.1.0.tar.gz.
File metadata
- Download URL: tryx402-0.1.0.tar.gz
- Upload date:
- Size: 32.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e907eed46baf198900393cb69113fc27a10bbdbe59f3221f36d8b352d6e90a8
|
|
| MD5 |
38901d5165c6eb6880cdd08641f46ff4
|
|
| BLAKE2b-256 |
f56c77e46a31295f51d52bede874a1191390b98f65cea40f8e0e7f04cc11b1f0
|
File details
Details for the file tryx402-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tryx402-0.1.0-py3-none-any.whl
- Upload date:
- Size: 38.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b73b16c6383c2012d9bb9770fd51394b8ff660840f9083f571a2a46852bf9e8
|
|
| MD5 |
a92409adc47da4527c23213ee34c0072
|
|
| BLAKE2b-256 |
1cd1f9f6406f3dcc879dd60e44c0d5529bb248b1de6122f1ddf6f206345756dc
|