• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
stevekrouse

stevekrouse

stevekrouse_dot_com

The personal site of Steve Krouse, stevekrouse.com
Public
Like
stevekrouse_dot_com
Home
Code
9
posts
12
PostTemplate.tsx
README.md
analytics.ts
helpers.tsx
index.tsx
H
main.tsx
post-helpers.tsx
rss.tsx
Connections
Environment variables
Branches
2
Pull requests
Remixes
4
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
posts
/
x402.md
Code
/
posts
/
x402.md
Search
…
Viewing readonly version of main branch: v797
View latest version
x402.md
title:
What if you never had to get an API key ever again?
tags:
x402, http, payments, apis, crypto, dx
date:
2026-03-08T00:00:00.000Z

What if you never had to get an API key ever again?

I care a lot about developer experience, so it kills my soul to watch someone get an API key.

I'm the founder of Val Town, a developer platform, so I spend a lot of time watching people run into this.

In the age of vibe coding, getting API keys is particularly egregious. It takes your agent 5 minutes to write the code, but takes you 30 minutes to get the key. Most of the time of making an app is getting API keys!

The worst part is that before you can try an API, you usually have no idea:

  1. How long sign-up will take
  2. Whether you'll need a credit card
  3. Whether the API is actually useful

You're at the mercy of the provider, and you just pray they care about developer experience.

Workarounds

This problem has bothered me enough that we've tried our best to route around it at Val Town.

The easiest workaround is to push users towards free APIs that don't require keys, like open-meteo for weather.

For premium APIs, we've created a series of hosted proxies that give users a taste of the API without needing a key. We call this our "Standard Library", and it includes sending emails, OpenAI, Blob Storage, and SQLite. We're also experimenting with a proxy for Clay (for enrichments), and in the past had a Twitter proxy.

But that puts Val Town in the unenviable position of rate-limiting, fighting abuse, etc, in an ad-hoc way. It's annoying and doesn't scale.

The Dream

The dream is:

  1. Users show up to any API with cash
  2. Send micropayments to try stuff out
  3. Minimal processing fees
  4. Open protocol > closed app store

Think "OpenRouter for everything. But as a protocol".

Surprise! It already exists.

x402

It's called x402.

And yes, unfortunately, this is the part where I tell you it has to do with crypto.

I regret to inform you that we may have found a real use-case for crypto.

x402 is a new protocol created by Coinbase in May 2025 for making paid HTTP requests. It's built on top of the pre-existing 402 HTTP status code, Payment Required.

Any HTTP API server can now optionally support x402 by returning 402 Payment Required, explaining the price, and what crypto wallet to send payment to.

The client can then make a payment on the blockchain, and retry the request with the proof of payment. The server verifies the payment, and release the premium API response.

Rendering mermaid diagram...

The code is elegant. You add your wallet's private key to your env vars, and then wrap your fetch with the x402 client. The SDK takes care of the payment flow for you.

const signer = privateKeyToAccount(process.env.PRIVATE_KEY); const client = new x402Client(); registerExactEvmScheme(client, { signer }); const paidFetch = wrapFetchWithPayment(fetch, client); const res = await paidFetch( "https://x402.browserbase.com/browser/session/create", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ duration: 5 }), }, );

You can think of it as attaching a wallet to fetch for it to autopay for premium requests.

This is the dream. We can make a paid a API request without ever going to that API's website, signing up, getting an API key, attaching a credit card, etc. In the above example, we're just showing up to Browserbase with a penny, and they are giving us a websocket URL to a 5-minute browser session.

You can try out a running demo of this flow here.

Accepting payments

Once I was able to make paid requests, I wanted to see how hard it was to accept payments.

In theory, because it's a protocol, not an app store, it should just be a couple lines of code to hang my shingle, and accept payments into the same wallet I created to make payments.

So I made the world's most expensive Math.random(). If you show up with a tenth of a penny, I will give you a random number.

const seller = privateKeyToAccount(process.env.PRIVATE_KEY); const payTo = seller.address; app.use( paymentMiddleware( { "GET /api/random": { accepts: { scheme: "exact", price: "$0.001", network: "eip155:8453", // Base payTo, }, description: "A premium random number", mimeType: "application/json", }, }, resourceServer, ), ); app.get("/api/random", (c) => c.json({ random: Math.random() }));

You can try out a running demo of this flow here.

Getting a wallet

If you want the full walkthrough, including the wallet setup and all the rough edges, I made a video version.

Now, to be clear, the getting a wallet and adding USDC is still not great. It took me an annoying 20 minutes the first time, and even the second time, when I knew what I was doing, it still took 10 minutes.

But the shape of this feels right. And, importantly, this is a one-time cost and it should unlock all the world's APIs from this single private key. It's like I got a debit card for APIs and now I can walk into any API store and swipe it immediately without first pre-registering.

The brave new world

I think the end state looks something like this:

  1. You sign up to Val Town (or Replit, Lovable, Vercel, etc)
  2. The platform creates a wallet for your app, or lets you import one
  3. The platform gives you a few free pennies to play with (or you add your own via credit card or whatever)
  4. You vibe code an app in minutes; it uses who-cares-how-many APIs
  5. It works. The app is done in minutes. You never got any API keys.

The beauty is you don't even have to know about which APIs are being used anymore, because you don't have to click around in a web browser to get API keys. Your agent can just start making paid requests to prototype with any API that supports x402.

We need more sellers on x402. I'm honestly confused why there isn't more of a gold rush here. Anyone can take any premium API – OpenAI, Anthropic, etc – and create a paid proxy with x402 and start earning money. There's an OpenRouter shaped opportunity here to be the reputable proxy on top of all the world's APIs – until the API providers themselves catch up and put themselves on x402, like Browserbase did.

We also need the crypto wallet onramp to get much easier. The experience of getting crypto, transferring it to a new wallet, etc, is still pretty bad. The better the onramp, the more buyers and sellers we'll get, and the faster this will grow.

Here at Val Town, we're continuing to watch x402 developments with great interest, with an eye towards integrating these wallets into our platform natively. The dream of never again getting an API key is close at hand.

Edit: dt made a good point that this infra could also help end-users pay for API costs directly. For example, I could make an app that uses Browserbase (and a dozen other x402 premium APIs), but then not provide my own developer app wallet. Instead my app could ask ask my users to provide their own wallet to pay for their usage of these services directly. I could even imagine a "Login with Coinbase" flow to provide your wallet credentials securely. This way your app could go viral without breaking the bank or having to deal with payments, rate-limits, etc.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.