Skip to content

Add x402 monetization - let AI agents pay per API call#2238

Open
sam00101011 wants to merge 1 commit intoupstash:masterfrom
sam00101011:add-x402-monetization
Open

Add x402 monetization - let AI agents pay per API call#2238
sam00101011 wants to merge 1 commit intoupstash:masterfrom
sam00101011:add-x402-monetization

Conversation

@sam00101011
Copy link

@sam00101011 sam00101011 commented Mar 15, 2026

What is this?

x402 is an open protocol that lets AI agents pay for API calls using the HTTP 402 status code. Instead of API keys and billing dashboards, agents pay per call in USDC on Base.

This PR adds the foundation for monetizing upstash/context7's API endpoints. We found 4 endpoints in your README that agents could pay to access.

Why agents would pay for upstash/context7

Each of these capabilities becomes a pay-per-call endpoint that AI agents discover and pay for automatically:

  • Inject real-time, version-specific library documentation into AI prompts — agents pay per call instead of needing credentials or rate-limited free tiers
  • Eliminate AI hallucinations by providing verified, up-to-date API references — agents pay per call instead of needing credentials or rate-limited free tiers
  • Automate library configuration and setup with context-aware code examples — agents pay per call instead of needing credentials or rate-limited free tiers
  • Enable native documentation retrieval for AI agents via MCP integration — agents pay per call instead of needing credentials or rate-limited free tiers

With x402, every feature above is instantly monetizable. Agents on Claude, Cursor, and any MCP client can discover and pay for access via 402.bot.

What's included

File Purpose
.well-known/x402.json Declares your endpoints, pricing, and wallet address - agents and routing networks use this for discovery
x402-middleware-example.ts Drop-in middleware that returns 402 and verifies payments

How it works

Agent -> calls your API
     <- 402 Payment Required (price: $0.01, wallet, network)
Agent -> signs USDC payment on Base
     -> retries with x-payment header
     <- normal API response

Settlement is instant. No intermediary holds funds. Revenue goes directly to your wallet.

What you'd earn

~$600/mo projected (4 endpoints x ~150 agent calls/mo x $0.01)

To activate

  1. Replace YOUR_WALLET_ADDRESS in .well-known/x402.json with your Base wallet
  2. Add the middleware to your server (see x402-middleware-example.ts)
  3. Deploy - your API is now discoverable by every agent on the 402.bot routing network

Your endpoints will automatically appear in Claude, Cursor, and any MCP-compatible agent via the 402.bot MCP server.

Live demo

See how upstash/context7 works on the x402 network ->

Links


This PR was opened by 402.bot. x402 is an open protocol - you keep 100% of revenue. We just route agents to providers. If this isn't relevant, feel free to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant