A free local proxy lets Claude Code, Cursor and Cline pay per call in USDC
An open-source tool lets popular coding assistants pay for AI models with USDC instead of a credit card, but it asks you to trust a wallet key to new code.
The short version
- x402-llm-proxy is MIT-licensed, with a single dependency, viem, and runs only on 127.0.0.1
- It translates OpenAI-style and Anthropic-style requests into x402 pay-per-call requests
- Mode A pays per call from a Base USDC wallet key, with spending caps you set
- Mode B uses a prepaid key, funded from $0.10, with Base or Solana USDC
- The default gateway is run by the proxy's author, who discloses this in the post
What the proxy does
As dev.to reported, a developer has published x402-llm-proxy, a small open-source program that runs on your own computer. It is MIT-licensed, a permissive open-source licence, and depends on just one library, viem. Its job is to sit between your coding tool and a remote AI model and handle the payment.
The problem it solves is a mismatch. Tools like Claude Code, Cursor and Cline, along with the Python and Node SDKs (code libraries developers use to call AI models), speak a standard request format. They cannot handle an HTTP 402 response, which is a web server's way of saying payment is required. They also cannot sign the USDC payment authorization that x402 services expect, which follows a standard called EIP-3009.
The proxy listens locally and accepts requests in two common formats: OpenAI's /v1/chat/completions and Anthropic's /v1/messages. It then forwards them to a pay-per-call endpoint and deals with the payment step itself. Your tool thinks it is talking to an ordinary model provider.
Why it matters
Coding assistants usually assume you have a credit card and a subscription. This proxy shows a path for people without a card, or who want strict pay-per-use billing. It also shows the cost: you run unreviewed code between your editor and the model, and you may keep a funded crypto wallet nearby.
Two ways to pay
The author describes two modes. In the first, you pay per call with USDC, a dollar-linked digital token, on the Base network. The post says this needs no account and no ETH for transaction fees. You put a wallet private key in an environment variable called BASE_PRIVATE_KEY and start the proxy with limits, for example --max-call-usd 0.05 and --max-session-usd 2.00.
When the server answers with a payment request, the proxy compares the quoted price with those two caps. If the price is within bounds, it signs a single payment authorization locally and retries the request with a payment header attached. The post says the private key never leaves 127.0.0.1, your own machine's local address.
The second mode is for people who do not want a wallet key sitting in an environment variable. You fund a prepaid API key instead, starting at $0.10, using a browser wallet or a direct USDC transfer on Base or Solana. The post says this mode supports native streaming and full tool use, meaning the model can call tools during a session. You then set SAGE_API_KEY and start the proxy.
Pointing your tools at it
Setup is mostly redirecting your tool to the local address. For Claude Code, you set ANTHROPIC_BASE_URL to http://127.0.0.1:4020 and use a placeholder API key. OpenAI-style clients get an OPENAI_BASE_URL pointing at the same port with a /v1 path.
There is also a free check. Running the tool with the --test flag does a dry run that confirms connectivity and shows a payment quote, and the post says it costs $0. A --models flag lists what is available.
One detail deserves attention. The default gateway, hosted on Cloudflare Workers, is operated by the same person who wrote the proxy, and the post says so openly. You can pass an --upstream option to use any other gateway that supports x402 version 2.
The trade-offs to weigh
The convenience comes with real exposure. Your prompts and code pass through a program you did not write. Our newsletter has not audited this code, and it noted that readers should look at the source before using it.
The wallet-key mode is the riskier of the two, since a hot wallet key is only as safe as the machine and the software that touch it. The spending caps limit how much a single call or session can cost. They do not replace reviewing the code. The prepaid key avoids storing a wallet key, at the price of trusting a gateway operator with your balance.
The author asked for feedback on three areas: the x402 v2 signing flow, the wrapping of streaming responses, and the security defaults. That suggests the project is young and still open to scrutiny.
Who this is for
The clearest audience is developers who cannot get a credit card on file with a model provider, or who dislike monthly subscriptions and want to pay only for the calls they make. It is also a small demonstration of how pay-per-request web payments could work for software that acts on its own.
For everyone else, the sensible approach is cautious. Start with the free dry run, read the code, and fund any wallet or prepaid key with a small amount. Keep client or private material out of anything routed through a proxy you have not reviewed.
What to watch
- Whether independent developers review the code and the x402 v2 signing flow
- Whether gateways other than the author's adopt x402 v2, so --upstream has real alternatives
- Whether coding tools add native x402 support, making a local proxy unnecessary
Try it
If you are comfortable in a terminal, read the repo first, then run `npx x402-llm-proxy --test` for the $0 dry run that checks connectivity and shows a payment quote.
More stories
ClaudeAnthropic and OpenAI employees tell Axios their unreleased models are hard to control
ClaudeAnthropic and OpenAI staff doubt unreleased models can ship safely
ClaudeWhy are people inside OpenAI and Anthropic afraid their newest AI models may never ship?
ClaudeAI staff at Anthropic and OpenAI debate releasing advanced models
ClaudeAI is accelerating the speed of cyberattacks faster than current defenses
Get The Daily
AI news, explained in 5 minutes a day. Free. The first issue is coming soon.
No password. Unsubscribe any time. Privacy
Say why
Liked it? Say why
Add a line for other readers.
No account needed. We never show your email. Comments with links, ads or abuse are held and not shown. Your comment shows after a quick check.
Sources
The reporting and documents this story is built from. Each link opens the original.
- ReportingDEV Community: the article we sourced dev.to
Written with AI by the SI Agent News Desk from the reporting above. Every number is checked against it.Spot a mistake? Corrections.
