anon-router 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,81 @@
1
+ # anon-router CLI — pay crypto for AI inference, privately, from your terminal
2
+
3
+ No account, no card, no email. Deposit crypto, get an anonymous key, call any
4
+ model. Your spends can't be linked to your deposit, and the model provider only
5
+ ever sees the router — never you.
6
+
7
+ > Testnet alpha: deposits use **Sepolia test ETH** (valueless). Don't put real
8
+ > funds in. See [PRIVACY.md](PRIVACY.md) for exactly what is and isn't private.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ python3 -m venv .venv && .venv/bin/pip install . # from this repo (Python 3.10+)
14
+ ```
15
+
16
+ That puts an `anon-router` command on your PATH. It talks to the hosted router by
17
+ default; to use your own set `export ANON_ROUTER_URL=https://your-router` (or
18
+ `--url`).
19
+
20
+ ## Use it
21
+
22
+ ```bash
23
+ # 1. Mint an anonymous key (no signup). This is a wallet — back up ~/.anon-router.
24
+ anon-router account
25
+
26
+ # 2a. Fund it by depositing test ETH on-chain. Put YOUR Sepolia key in a file
27
+ # {"private_key": "0x..."} (or export ANON_DEPOSIT_KEY), then:
28
+ anon-router deposit 0.001 --key myfunding.json # waits for the credit (~30s)
29
+ # ...or 2b. redeem a voucher code someone gave you:
30
+ anon-router redeem ar-XXXXXXXXXXXXXXXXXXXX
31
+
32
+ # 3. Convert your balance into unlinkable ecash (this breaks the deposit link).
33
+ anon-router claim 5000
34
+
35
+ # 4. Chat — paid per request with ecash, unlinkable to your deposit.
36
+ anon-router chat "hello there" --model openai/gpt-4o-mini
37
+ anon-router balance
38
+ anon-router models --search gpt
39
+ ```
40
+
41
+ (Running from the repo without installing? `.venv/bin/python cli.py <same args>`.)
42
+
43
+ ## Use it from your agent / tool ("swap the API")
44
+
45
+ Already have something that speaks the OpenAI API (Cursor, aider, the OpenAI SDK,
46
+ your own agent)? Two ways to point it here:
47
+
48
+ **Private (recommended) — run the local proxy, point your tool at it:**
49
+ ```bash
50
+ anon-router claim 5000 # make sure your wallet has ecash
51
+ anon-router serve # local proxy on http://127.0.0.1:8788/v1
52
+ # then in your tool: base_url = http://127.0.0.1:8788/v1 (api_key = anything)
53
+ ```
54
+ Every request the tool makes is paid with blind-signed ecash — the router can't
55
+ link your tool's requests to each other or to your deposit. No code changes in
56
+ the tool. (Set `ANON_DAEMON_KEY` to require a bearer key on the proxy.)
57
+
58
+ **Convenient (pseudonymous) — no local proxy:** point `base_url` at `<router>/v1`
59
+ and use your `sk-anon-…` account key as the bearer token. Spends the account
60
+ balance directly; simplest, but the router can link that key's requests.
61
+
62
+ ### Claude Code
63
+ The proxy also speaks the Anthropic Messages API (streaming + tool use), so
64
+ Claude Code runs against it with two env vars:
65
+ ```bash
66
+ anon-router serve # local proxy, leave it running
67
+ export ANTHROPIC_BASE_URL=http://127.0.0.1:8788
68
+ export ANTHROPIC_API_KEY=anon-router # any non-empty value
69
+ claude # every request now pays private ecash
70
+ ```
71
+ The model names Claude Code sends are mapped to a valid router model
72
+ automatically; full agentic tool use works.
73
+
74
+ ## Or just chat in the terminal
75
+ `anon-router chat "…"` — private (ecash), no other tool needed.
76
+
77
+ ## Privacy hygiene
78
+ Fund from a fresh wallet, deposit a common round amount, spend over time, and
79
+ rotate keys (`cli.py account`) so sessions don't link. Reach the router over its
80
+ Tor `.onion` (`--tor`) to hide your IP. The model still reads your prompt — for
81
+ content privacy use a `local/*` model.
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: anon-router
3
+ Version: 0.1.0
4
+ Summary: Pay crypto for AI inference, privately, from your terminal
5
+ License: MIT
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: httpx>=0.27
9
+ Requires-Dist: web3>=7
10
+ Requires-Dist: eth-account>=0.13
11
+ Requires-Dist: socksio>=1.0
12
+
13
+ # anon-router CLI — pay crypto for AI inference, privately, from your terminal
14
+
15
+ No account, no card, no email. Deposit crypto, get an anonymous key, call any
16
+ model. Your spends can't be linked to your deposit, and the model provider only
17
+ ever sees the router — never you.
18
+
19
+ > Testnet alpha: deposits use **Sepolia test ETH** (valueless). Don't put real
20
+ > funds in. See [PRIVACY.md](PRIVACY.md) for exactly what is and isn't private.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ python3 -m venv .venv && .venv/bin/pip install . # from this repo (Python 3.10+)
26
+ ```
27
+
28
+ That puts an `anon-router` command on your PATH. It talks to the hosted router by
29
+ default; to use your own set `export ANON_ROUTER_URL=https://your-router` (or
30
+ `--url`).
31
+
32
+ ## Use it
33
+
34
+ ```bash
35
+ # 1. Mint an anonymous key (no signup). This is a wallet — back up ~/.anon-router.
36
+ anon-router account
37
+
38
+ # 2a. Fund it by depositing test ETH on-chain. Put YOUR Sepolia key in a file
39
+ # {"private_key": "0x..."} (or export ANON_DEPOSIT_KEY), then:
40
+ anon-router deposit 0.001 --key myfunding.json # waits for the credit (~30s)
41
+ # ...or 2b. redeem a voucher code someone gave you:
42
+ anon-router redeem ar-XXXXXXXXXXXXXXXXXXXX
43
+
44
+ # 3. Convert your balance into unlinkable ecash (this breaks the deposit link).
45
+ anon-router claim 5000
46
+
47
+ # 4. Chat — paid per request with ecash, unlinkable to your deposit.
48
+ anon-router chat "hello there" --model openai/gpt-4o-mini
49
+ anon-router balance
50
+ anon-router models --search gpt
51
+ ```
52
+
53
+ (Running from the repo without installing? `.venv/bin/python cli.py <same args>`.)
54
+
55
+ ## Use it from your agent / tool ("swap the API")
56
+
57
+ Already have something that speaks the OpenAI API (Cursor, aider, the OpenAI SDK,
58
+ your own agent)? Two ways to point it here:
59
+
60
+ **Private (recommended) — run the local proxy, point your tool at it:**
61
+ ```bash
62
+ anon-router claim 5000 # make sure your wallet has ecash
63
+ anon-router serve # local proxy on http://127.0.0.1:8788/v1
64
+ # then in your tool: base_url = http://127.0.0.1:8788/v1 (api_key = anything)
65
+ ```
66
+ Every request the tool makes is paid with blind-signed ecash — the router can't
67
+ link your tool's requests to each other or to your deposit. No code changes in
68
+ the tool. (Set `ANON_DAEMON_KEY` to require a bearer key on the proxy.)
69
+
70
+ **Convenient (pseudonymous) — no local proxy:** point `base_url` at `<router>/v1`
71
+ and use your `sk-anon-…` account key as the bearer token. Spends the account
72
+ balance directly; simplest, but the router can link that key's requests.
73
+
74
+ ### Claude Code
75
+ The proxy also speaks the Anthropic Messages API (streaming + tool use), so
76
+ Claude Code runs against it with two env vars:
77
+ ```bash
78
+ anon-router serve # local proxy, leave it running
79
+ export ANTHROPIC_BASE_URL=http://127.0.0.1:8788
80
+ export ANTHROPIC_API_KEY=anon-router # any non-empty value
81
+ claude # every request now pays private ecash
82
+ ```
83
+ The model names Claude Code sends are mapped to a valid router model
84
+ automatically; full agentic tool use works.
85
+
86
+ ## Or just chat in the terminal
87
+ `anon-router chat "…"` — private (ecash), no other tool needed.
88
+
89
+ ## Privacy hygiene
90
+ Fund from a fresh wallet, deposit a common round amount, spend over time, and
91
+ rotate keys (`cli.py account`) so sessions don't link. Reach the router over its
92
+ Tor `.onion` (`--tor`) to hide your IP. The model still reads your prompt — for
93
+ content privacy use a `local/*` model.
@@ -0,0 +1,132 @@
1
+ # anon-router
2
+
3
+ Pay crypto for AI inference. An OpenAI-compatible endpoint where you deposit
4
+ ETH/USDC, get an API key, and call any model — the provider never sees a name
5
+ or a card, and the payment rail can't link a request to the deposit that
6
+ funded it.
7
+
8
+ ## Try the demo (local)
9
+
10
+ ```bash
11
+ ./run_e2e.sh # anvil + contracts + router + watcher, asserts 7/7 stages
12
+ # then open the site:
13
+ # http://127.0.0.1:8402 (KEEP=1 ./run_e2e.sh leaves it running)
14
+ ```
15
+
16
+ The site (`web/index.html`): click **Get API key** (no signup), **deposit ETH**
17
+ from any wallet, watch credits land in ~2s, and **chat** — or point Cursor / any
18
+ OpenAI client at the base URL with that key. Fewer steps than OpenRouter.
19
+
20
+ ## What's built
21
+
22
+ | Lane | What it gives you | Trust |
23
+ |---|---|---|
24
+ | **Simple** (`sk-anon-*` bearer key + `CreditVault`) | deposit → key → any OpenAI client | custodial (operator holds float) |
25
+ | **Ecash** (blind-signed tokens) | unlinkable prepaid credits | trusted mint |
26
+ | **Channel** (confetti zk payment channels, on-chain escrow) | deposits escrowed on-chain, unlinkable per-request payments | trust-minimized: operator can't steal/freeze |
27
+ | **Free** (`local/*`) | self-hosted models, no payment | — |
28
+
29
+ **Verification:** the on-chain contract has three independent code reviews
30
+ (Fable, Codex, Kimi) plus a machine-checked Lean proof of its safety core
31
+ (conservation, no-theft, terminality) — see [VERIFICATION.md](VERIFICATION.md).
32
+ The settlement core is also written in the [Verity](https://veritylang.com) Lean
33
+ EDSL that compiles to EVM. Testnet-only; nothing is deployed to a public chain.
34
+
35
+ ---
36
+
37
+ Payer-anonymous, OpenAI-compatible inference proxy. Prepay for credits, spend them as blind-signed bearer tokens: the router can verify every payment but cannot link any request to the deposit that funded it, or link two requests to each other.
38
+
39
+ v1 rail is Cashu-style blind signatures (BDHKE) with a trusted mint. The channel lane replaces the trusted mint with confetti zk payment channels (see `../zk-payments-confetti/PROTOCOL.md`) so the router also cannot steal or freeze deposits.
40
+
41
+ ## How it works
42
+
43
+ 1. Deposit (dev: free faucet; prod: USDC) and receive blind-signed tokens in power-of-two credit denominations. 1 credit = $0.0001.
44
+ 2. Each `/v1/chat/completions` request attaches tokens in the `X-Cash` header as prepayment.
45
+ 3. The router verifies + burns the tokens, proxies to the upstream (OpenRouter), reads the exact USD cost from usage accounting, and holds the overpayment under a one-time receipt (`X-Change-Receipt` response header).
46
+ 4. The wallet redeems the receipt for fresh blind-signed change tokens.
47
+
48
+ Blinding means the mint signs tokens without seeing them, so issued tokens and spent tokens are cryptographically unlinkable. Amount is bound by using one mint key per denomination.
49
+
50
+ ## Quickstart
51
+
52
+ ```bash
53
+ python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
54
+ cp .env.example .env # set OPENROUTER_API_KEY
55
+ .venv/bin/uvicorn server:app --host 127.0.0.1 --port 8402
56
+
57
+ # in another shell
58
+ .venv/bin/python cli.py topup 50000 # $5 of dev credits
59
+ .venv/bin/python cli.py chat "hello there" # pays per request
60
+ .venv/bin/python cli.py balance
61
+ ```
62
+
63
+ Any OpenAI-compatible client works against `http://127.0.0.1:8402/v1` if it can attach the `X-Cash` header per request (the CLI/wallet does this automatically).
64
+
65
+ ## Selling credits (vouchers)
66
+
67
+ The MVP resale loop: the operator funds an OpenRouter account wholesale, sells voucher codes through any channel (USDC, WeChat, resellers), and buyers redeem codes for anonymous credits. The mint sees which voucher a redemption came from but cannot link the resulting tokens to any later request (blind signatures).
68
+
69
+ ```bash
70
+ # operator, on the router box:
71
+ .venv/bin/python admin.py issue 50000 # prints a code worth $5
72
+ .venv/bin/python admin.py list # ledger of issued/redeemed
73
+
74
+ # buyer, anywhere:
75
+ python cli.py redeem ar-XXXXXXXXXXXXXXXXXXXX # code → anonymous credits
76
+ python cli.py chat "hello" --model openai/gpt-4o-mini
77
+ ```
78
+
79
+ Set `DEV_FAUCET=0` in `.env` for any deployment where credits are sold.
80
+
81
+ ## Trust-minimized channel lane (confetti, M4a)
82
+
83
+ An opt-in payment lane where the buyer's deposit is governed by the confetti
84
+ zk payment channel instead of trusting the mint. See [confetti/README.md](confetti/README.md).
85
+
86
+ ```bash
87
+ python cli.py channel open 5000 # deposit 5000 credits
88
+ python cli.py chat "hello" --model openai/gpt-4o-mini --channel
89
+ python cli.py channel status
90
+ ```
91
+
92
+ Each request builds a payment proof, the router verifies and countersigns it,
93
+ and a stale/rolled-back close is provably challengeable. M4a runs off-chain
94
+ against an in-memory referee with the reference (non-ZK) prover; M4b adds the
95
+ on-chain contract and the real STARK prover.
96
+
97
+ ## Free local lane
98
+
99
+ Models prefixed `local/` route to a free upstream (RTX 3080 PC running Ollama, reached via ssh tunnel) and require no payment. For user testing without spending credits:
100
+
101
+ ```bash
102
+ ssh -f -N -L 11435:127.0.0.1:11434 pc3080 # once per boot
103
+ .venv/bin/python cli.py chat "hello" --model local/qwen3:8b
104
+ ```
105
+
106
+ Override the upstream with `LOCAL_UPSTREAM` in `.env`.
107
+
108
+ ## Honest limitations (v1)
109
+
110
+ - The mint is trusted with float: it could refuse redemption. v2 (confetti channels) removes this.
111
+ - Payment unlinkability is not payer anonymity: use fresh connections/proxy for transport privacy. Requests within one HTTP session are linkable by the connection itself.
112
+ - Prepay is a fixed amount per request, not a per-model max-cost estimate.
113
+ - Streaming change redemption requires polling the receipt after the stream ends.
114
+ - Dev faucet stands in for the USDC deposit watcher.
115
+
116
+ ## Milestones
117
+
118
+ - **v0** — blind-signature mint, OpenRouter proxy, exact-cost metering. Done.
119
+ - **Voucher resale** — operator sells codes, buyers redeem for anonymous credits. Done.
120
+ - **Simple lane** — `CreditVault` deposit → bearer key → any OpenAI client; site + watcher. Done.
121
+ - **M4a** — confetti off-chain channel protocol + router lane. Done.
122
+ - **M4b** — on-chain escrow (`ConfettiChannels`), deposits leave custody, 3-reviewer + Lean-proof gate. Done (local Anvil).
123
+ - **Verity** — settlement core written in Lean, compiled to EVM. In progress.
124
+ - **M4b-real** — SP1 Groth16 verifier replacing the mock. In progress (Docker/colima).
125
+
126
+ ## Roadmap
127
+
128
+ - USDC deposit lane (same as `CreditVault`, ERC-20 `transferFrom`)
129
+ - Known-answer sampling audits of upstreams, published scores
130
+ - new-api/one-api payment module (中转站 integration)
131
+ - Durable persistence of the router's off-chain state (dedup/inbox/XMSS)
132
+ - Public deploy to Ethereum Sepolia (operator holds the key; counsel gate first)
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: anon-router
3
+ Version: 0.1.0
4
+ Summary: Pay crypto for AI inference, privately, from your terminal
5
+ License: MIT
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: httpx>=0.27
9
+ Requires-Dist: web3>=7
10
+ Requires-Dist: eth-account>=0.13
11
+ Requires-Dist: socksio>=1.0
12
+
13
+ # anon-router CLI — pay crypto for AI inference, privately, from your terminal
14
+
15
+ No account, no card, no email. Deposit crypto, get an anonymous key, call any
16
+ model. Your spends can't be linked to your deposit, and the model provider only
17
+ ever sees the router — never you.
18
+
19
+ > Testnet alpha: deposits use **Sepolia test ETH** (valueless). Don't put real
20
+ > funds in. See [PRIVACY.md](PRIVACY.md) for exactly what is and isn't private.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ python3 -m venv .venv && .venv/bin/pip install . # from this repo (Python 3.10+)
26
+ ```
27
+
28
+ That puts an `anon-router` command on your PATH. It talks to the hosted router by
29
+ default; to use your own set `export ANON_ROUTER_URL=https://your-router` (or
30
+ `--url`).
31
+
32
+ ## Use it
33
+
34
+ ```bash
35
+ # 1. Mint an anonymous key (no signup). This is a wallet — back up ~/.anon-router.
36
+ anon-router account
37
+
38
+ # 2a. Fund it by depositing test ETH on-chain. Put YOUR Sepolia key in a file
39
+ # {"private_key": "0x..."} (or export ANON_DEPOSIT_KEY), then:
40
+ anon-router deposit 0.001 --key myfunding.json # waits for the credit (~30s)
41
+ # ...or 2b. redeem a voucher code someone gave you:
42
+ anon-router redeem ar-XXXXXXXXXXXXXXXXXXXX
43
+
44
+ # 3. Convert your balance into unlinkable ecash (this breaks the deposit link).
45
+ anon-router claim 5000
46
+
47
+ # 4. Chat — paid per request with ecash, unlinkable to your deposit.
48
+ anon-router chat "hello there" --model openai/gpt-4o-mini
49
+ anon-router balance
50
+ anon-router models --search gpt
51
+ ```
52
+
53
+ (Running from the repo without installing? `.venv/bin/python cli.py <same args>`.)
54
+
55
+ ## Use it from your agent / tool ("swap the API")
56
+
57
+ Already have something that speaks the OpenAI API (Cursor, aider, the OpenAI SDK,
58
+ your own agent)? Two ways to point it here:
59
+
60
+ **Private (recommended) — run the local proxy, point your tool at it:**
61
+ ```bash
62
+ anon-router claim 5000 # make sure your wallet has ecash
63
+ anon-router serve # local proxy on http://127.0.0.1:8788/v1
64
+ # then in your tool: base_url = http://127.0.0.1:8788/v1 (api_key = anything)
65
+ ```
66
+ Every request the tool makes is paid with blind-signed ecash — the router can't
67
+ link your tool's requests to each other or to your deposit. No code changes in
68
+ the tool. (Set `ANON_DAEMON_KEY` to require a bearer key on the proxy.)
69
+
70
+ **Convenient (pseudonymous) — no local proxy:** point `base_url` at `<router>/v1`
71
+ and use your `sk-anon-…` account key as the bearer token. Spends the account
72
+ balance directly; simplest, but the router can link that key's requests.
73
+
74
+ ### Claude Code
75
+ The proxy also speaks the Anthropic Messages API (streaming + tool use), so
76
+ Claude Code runs against it with two env vars:
77
+ ```bash
78
+ anon-router serve # local proxy, leave it running
79
+ export ANTHROPIC_BASE_URL=http://127.0.0.1:8788
80
+ export ANTHROPIC_API_KEY=anon-router # any non-empty value
81
+ claude # every request now pays private ecash
82
+ ```
83
+ The model names Claude Code sends are mapped to a valid router model
84
+ automatically; full agentic tool use works.
85
+
86
+ ## Or just chat in the terminal
87
+ `anon-router chat "…"` — private (ecash), no other tool needed.
88
+
89
+ ## Privacy hygiene
90
+ Fund from a fresh wallet, deposit a common round amount, spend over time, and
91
+ rotate keys (`cli.py account`) so sessions don't link. Reach the router over its
92
+ Tor `.onion` (`--tor`) to hide your IP. The model still reads your prompt — for
93
+ content privacy use a `local/*` model.
@@ -0,0 +1,26 @@
1
+ CLI.md
2
+ README.md
3
+ anthropic_proxy.py
4
+ cli.py
5
+ ec.py
6
+ mint.py
7
+ pyproject.toml
8
+ serve_ecash.py
9
+ wallet.py
10
+ anon_router.egg-info/PKG-INFO
11
+ anon_router.egg-info/SOURCES.txt
12
+ anon_router.egg-info/dependency_links.txt
13
+ anon_router.egg-info/entry_points.txt
14
+ anon_router.egg-info/requires.txt
15
+ anon_router.egg-info/top_level.txt
16
+ confetti/__init__.py
17
+ confetti/chain.py
18
+ confetti/channel.py
19
+ confetti/hashes.py
20
+ confetti/merkle.py
21
+ confetti/relation.py
22
+ confetti/sp1.py
23
+ confetti/wire.py
24
+ confetti/wots.py
25
+ tests/test_confetti.py
26
+ tests/test_sp1_prover.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ anon-router = cli:main
@@ -0,0 +1,4 @@
1
+ httpx>=0.27
2
+ web3>=7
3
+ eth-account>=0.13
4
+ socksio>=1.0
@@ -0,0 +1,7 @@
1
+ anthropic_proxy
2
+ cli
3
+ confetti
4
+ ec
5
+ mint
6
+ serve_ecash
7
+ wallet