How to Sell Services to AI Agents | x402 Goes Live On The Stellar Network
Source: Dev.to
If you want to charge for an API you might issue API keys, set up a payment processor, manage rate limits, and hope your users don’t churn. That model assumes a human is on the other side of the keyboard.
AI agents change the dynamic as they don’t have access or permissions to sign up for credit‑card‑based subscriptions. But what if you could give your agent access to a small amount of digital assets and let it pay for metered access?
This is where x402 comes in. It revives the long‑reserved HTTP status code 402 Payment Required. Instead of redirecting to a checkout page, a server can respond with a machine‑readable payment request. The client signs a transaction providing authentication to route the digital assets and the resource is returned.
No dashboards. No credit cards. No humans in the loop. Just native payments via HTTP.
Why The Stellar Network & USDC
Payment rails matter.
If you’re charging $0.001 per API call, a $0.30 card processing fee is a non‑starter. Settlement times measured in days don’t work either when agents expect instant feedback.
The Stellar network provides the missing foundation:
- Transactions settle in seconds
- Fees are fractions of a cent
- Native USDC support via Circle
- Non‑custodial, on‑chain settlement
That combination makes micropayments via x402 viable—not as a thought experiment, but as robust production architecture.
With x402 integrated on Stellar, an AI agent can find your endpoint, receive a structured payment request in USDC, sign a transaction, and proceed—all within a standard request/response cycle. For the first time, the economics align with the automation, and it’s a great time to be a builder.
What Can You Sell to AI Agents?
The opportunity is not theoretical. Agents already consume:
- Market data
- Code analysis
- Security scanning
- Model inference
- Compute cycles
- Private datasets
- Execution endpoints
Right now, most of these are gated by API keys or subscription contracts. That friction limits experimentation and composability.
With x402, you can expose a service and receive payment directly based on the volume of usage. The agent doesn’t need an account or any intermediary.
Think about what Claude Code and OpenClaw are doing: they allow agents to navigate repositories, execute commands, install dependencies, and reason about systems. Now imagine those agents discovering your paid endpoint in the process.
- They attempt a request.
- Your server responds with 402 Payment Required and provides payment options in USDC on the Stellar network.
- The agent evaluates the cost, signs the transaction, and resubmits.
- You receive the digital assets in your wallet.
No onboarding call. No SaaS sales funnel. No subscription churn. Your API becomes economically composable.
Developers often talk about “the machine economy” in abstract terms. This is what it will look like in the next few years: small, verifiable, programmatic payments flowing between autonomous systems.
Simplicity For Developers
One of the most compelling aspects of x402 is how little it actually demands from developers.
- Server side: When payment is required, the endpoint responds with a 402 Payment Required status, includes structured payment instructions, and verifies on‑chain settlement before delivering the resource.
- Client side: The client detects the 402 response, signs the required transaction, and retries the request with proof of payment. Beyond that exchange, everything else runs on standard HTTP infrastructure, without introducing complex new layers or bespoke protocols.
Example Middleware (Node.js)
// npm middleware from Coinbase
const app = express();
app.get("/", (_, res) =>
res.json({ route: ROUTE_PATH, price: PRICE, network: NETWORK })
);
app.use(
paymentMiddlewareFromConfig(
{
[`GET ${ROUTE_PATH}`]: {
accepts: {
scheme: "exact",
price: PRICE,
network: NETWORK,
payTo: PAY_TO,
},
},
},
new HTTPFacilitatorClient({ url: FACILITATOR_URL }),
[{ network: NETWORK, server: new ExactStellarScheme() }]
)
);AI agents are becoming more capable, moving from passive assistants to active operators. As that shift accelerates, the demand for machine‑to‑machine services will grow with it. Developers who expose programmable, metered services early will shape that ecosystem.
x402 on the Stellar network provides the missing payment primitive to support it—a small extension to HTTP backed by a network built for fast, low‑cost global settlement.
If you’re building tools, datasets, models, or infrastructure that agents can use, the question is no longer whether machines will consume your services. It’s whether they’ll be able to pay you directly when they do.