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 X-Payment-Tx header
  5. 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

DetailValue
NetworkBase (Coinbase L2)
CurrencyUSDC
SettlementInstant (~2 seconds)
Gas cost~$0.001 per transaction
Resource descriptor/.well-known/x402
Treasury0x2870C66dA1A8D26A73c61EfCc17C6Ef93e513eFF

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/clientTypeScriptOfficial Coinbase x402 client
@x402/svmTypeScriptSolana x402 support
@hober/x402-aiTypeScriptAI inference cost estimator + model registry