Getting Started

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

  1. Send a request to Hober without payment headers
  2. Hober responds with 402 Payment Required + payment details
  3. Your wallet signs a USDC transfer on Base to the payment address
  4. Retry the request with the payment payload in the X-PAYMENT header
  5. Hober verifies the payment on-chain and processes the inference

Example

// Using @x402/fetch (Coinbase official SDK)
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { createWalletClient, http, publicActions } from "viem";
import { base } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";

const wallet = createWalletClient({
  account: privateKeyToAccount("0x..."),
  chain: base,
  transport: http(),
}).extend(publicActions);

const client = new x402Client().register("eip155:8453", new ExactEvmScheme(wallet));
const fetchWithPay = wrapFetchWithPayment(fetch, client);

const response = await fetchWithPay("https://api.hober.dev/v1/chat/completions", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "deepseek/v3.2",
    messages: [{ role: "user", content: "Hello" }],
  }),
});

const data = await response.json();
console.log(data.choices[0].message.content);

Payment Details

DetailValue
NetworkBase (Coinbase L2)
CurrencyUSDC
SettlementInstant (~2 seconds)
Gas cost~$0.001 per transaction
Resource descriptor/.well-known/x402
Payment destinationAdvertised per request in the 402 response, not a fixed address

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

PackageLanguageDescription
@x402/fetchTypeScriptOfficial Coinbase x402 fetch wrapper
@hober/x402-aiTypeScriptAI inference cost estimator + model registry