x402 Payments
x402 is an HTTP payment protocol created by Coinbase that adds native payments to the web. Instead of depositing credits upfront or managing billing accounts, you simply pay for each AI request with USDC on Base at the moment you make it. No account, no API key, no signup — just a wallet.
This is how machines pay machines. When an autonomous AI agent needs to call Hober for inference, it doesn't need someone to manually deposit credits. It just sends USDC alongside the request and gets a response. Settlement is instant (~2 seconds on Base) and costs about $0.001 in gas per transaction.
x402 works alongside API key auth — you can use both. Many developers use API keys for their backend servers and x402 for their autonomous agents.
How It Works
- Send a request to Hober without payment headers
- Hober responds with
402 Payment Required+ payment details - Your wallet signs a USDC transfer on Base to the payment address
- Retry the request with
X-Payment-Txheader - Hober verifies the payment on-chain and processes the inference
Example
// Using @x402/client (Coinbase official SDK)
import { x402Fetch } from "@x402/client";
import { createWalletClient, http } from "viem";
import { base } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
const wallet = createWalletClient({
account: privateKeyToAccount("0x..."),
chain: base,
transport: http(),
});
const response = await x402Fetch(
"https://hober-gateway.fly.dev/v1/chat/completions",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "deepseek-chat",
messages: [{ role: "user", content: "Hello" }],
}),
},
wallet,
);
const data = await response.json();
console.log(data.choices[0].message.content);Payment Details
| Detail | Value |
|---|---|
| Network | Base (Coinbase L2) |
| Currency | USDC |
| Settlement | Instant (~2 seconds) |
| Gas cost | ~$0.001 per transaction |
| Resource descriptor | /.well-known/x402 |
| Treasury | 0x2870C66dA1A8D26A73c61EfCc17C6Ef93e513eFF |
Fee Structure
x402 payments include Hober's 5% service fee (or 4.0-4.5% with volume tiers). The provider receives 100% of their listed price. See Pricing for full details.
SDKs
| Package | Language | Description |
|---|---|---|
| @x402/client | TypeScript | Official Coinbase x402 client |
| @x402/svm | TypeScript | Solana x402 support |
| @hober/x402-ai | TypeScript | AI inference cost estimator + model registry |