Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 1 min read

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.

How it works

  1. Free dry-run connectivity & 402 quote check ($0 spent):
npx x402-llm-proxy --test
npx x402-llm-proxy --models
  1. 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.

  1. 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.10 min 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
  1. 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.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.