Use Claude Code, Cursor & Cline Without a Credit Card: Local HTTP x402 USDC Proxy (Open Source)
I built a small open-source local proxy (x402-llm-proxy, MIT, single dependency on viem) that bridges standard OpenAI (/v1/chat/completions) and Anthropic (/v1/messages) clientsβlike Claude Code, Cursor, Cline, and the P
I built a small open-source local proxy (x402-llm-proxy, MIT, single dependency on viem) that bridges standard OpenAI (/v1/chat/completions) and Anthropic (/v1/messages) clientsβlike Claude Code, Cursor, Cline, and the Python/Node SDKsβto HTTP x402 pay-per-call LLM endpoints.
Why: Existing coding tools and SDKs cannot natively handle HTTP 402 challenges or sign EIP-3009 USDC payment headers. If you want pay-per-call frontier model access without a credit card or monthly subscription, you need a local shim that stays strictly on 127.0.0.1.
- Repo: https://github.com/mazhic87/x402-llm-proxy
- npm: https://www.npmjs.com/package/x402-llm-proxy
- Default upstream gateway & pricing (disclosure: I operate this Cloudflare Workers gateway): https://sage-x402-tools.sage-ibis.workers.dev
How it works
- Free dry-run connectivity & 402 quote check ($0 spent):
npx x402-llm-proxy --test
npx x402-llm-proxy --models
- Mode A β Pay-per-call with Base USDC (HTTP x402 v2, 0 ETH gas, no account):
BASE_PRIVATE_KEY=0x... npx x402-llm-proxy --max-call-usd 0.05 --max-session-usd 2.00
The private key never leaves 127.0.0.1. On an HTTP 402 response, the proxy checks the quoted amount against --max-call-usd and --max-session-usd, signs a single EIP-3009 TransferWithAuthorization payload locally, and retries with the PAYMENT-SIGNATURE header.
-
Mode B β Prepaid API key (Base or Solana USDC, native streaming + full tool use):
If you prefer not to put a hot wallet key in an env var, you can fund a prepaid key (
$0.10min via 0-gas browser wallet or direct Base/Solana USDC transfer) at https://sage-x402-tools.sage-ibis.workers.dev/topup:
SAGE_API_KEY=sk-sage-... npx x402-llm-proxy
- Point Claude Code / Cursor / SDK at localhost:
ANTHROPIC_BASE_URL=http://127.0.0.1:4020 ANTHROPIC_API_KEY=x402 claude
# or OPENAI_BASE_URL=http://127.0.0.1:4020/v1
You can also pass --upstream to point it at any other x402 v2 compatible gateway. Happy to hear feedback on the x402 v2 signing flow, SSE wrapping, or security defaults.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.