feat(ecosystem): add x402-anthropic (TypeScript + Python)
Summary
Adds two ecosystem entries for x402-anthropic — client-side payment transports for the Anthropic SDK.
- x402-anthropic (TypeScript) —
npm install x402-anthropic - x402-anthropic-python (Python) —
pip install x402-anthropic[evm]
Both wrap the standard Anthropic client so HTTP 402 responses are automatically paid with USDC on EVM (Base, Ethereum) or SVM (Solana). Zero code changes needed beyond swapping the client class.
Category: Client-Side Integrations
🟡 Heimdall Review Status
| Requirement | Status | More Info | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Reviews |
🟡
0/1
|
Denominator calculation
|
Did a quick public/code-only readiness pass on the two linked packages before this is listed as a client-side integration. I did not run wallet signing, payment headers, paid calls, or private endpoints.
What looks good:
- Both packages keep the integration narrow: Anthropic SDK wrapper + x402 transport.
- The Python transport has a useful single-retry behavior for repeated 402s, so it does not loop indefinitely.
- The TypeScript wrapper lazily initializes the x402 client, which is a good shape for normal SDK usage.
Patch notes I would address before/around listing:
- P1: TypeScript
maxAmount()looks like it fails open. Insrc/policies.ts, if all payment requirements are above the cap,affordable.lengthis0and the policy returns the originalreqs, so the later client can still pay above the documented cap. The README saysmaxAmount(1_000_000n)is "max $1 USDC" / skip above cap, so this should return[]or otherwise block when nothing is affordable. - P1: Python README documents
policies=[preferNetwork(...), maxAmount(...)], butx402_anthropic/_client.pydoes not accept or register policies;policieswould be forwarded as a normal Anthropic kwarg instead of enforced by x402. For an auto-paying Anthropic wrapper, the cap example needs to be implemented or removed before users rely on it. - P2: The ecosystem description says "automatically paid with USDC" and "zero code changes". For a wallet-spending SDK, I would add one explicit safety sentence to the package READMEs and/or ecosystem copy: use a restricted wallet and a real max-amount policy before pointing this at an arbitrary gateway.
I tried local tests but the cloned repos did not have dev deps installed in this environment (vitest / pytest missing), so the above is static source/readme review only.
Thanks for the detailed review @TateLyman — all three items addressed:
P1: TypeScript maxAmount fails open — fixed. maxAmount() now returns affordable directly (empty array when nothing is affordable), so payments above the cap are blocked rather than allowed through. commit
P1: Python policies param not wired — fixed. Both X402Anthropic and AsyncX402Anthropic now accept policies: list | None = None and pass them to wallet.build_sync() / build_async(), which calls x402ClientSync.register_policy() for each. Also corrected the README examples from preferNetwork/maxAmount (JS names) to prefer_network/max_amount (Python x402 library names). commit
P2: Safety note — added to both READMEs: "use a dedicated wallet with limited funds and always set a maxAmount/max_amount policy before pointing this at an untrusted gateway."