AI agents can call our OpenAI-compatible gateway with a signed Qubic tx instead of an API key. The gateway returns 402 Payment Required. The agent pays. The agent retries. The agent gets the response.
x402 is an open protocol for machine-paid HTTP. Aigarth ships it on QUBIC today, with USDT and USDC in a follow-up phase.
POST /v1/chat/completions with your model and messages. No Bearer header.
The gateway returns HTTP 402 with the cost, the pay-to address, and a single-use nonce.
Sign a Qubic tx for the cost, add an X-PAYMENT header with proof of payment, retry.
The 200 OK comes back with an X-PAYMENT-RESPONSE header. The receipt is auditable on chain.
An API key is a shared secret the agent has to store, rotate, and pass across every call. x402 replaces it with a per-call signed payment. The wallet is the identity. The chain is the audit log.
Stored as a long-lived secret in agent config.
No key. The wallet proves the caller each request.
Fixed usage tiers, monthly subscriptions, surprise overages.
Pay what you use, in QUBIC. No subscription. No minimums.
Agent has to estimate and pre-buy credits. Refunds are friction.
No pre-funding. The cost is in the 402. The agent can refuse expensive calls before paying.
The SDK handles the 402 → sign → retry flow on the caller's behalf. One signer per process.
import { Aigarth } from "@aigarth/sdk";
import { payAndCall, QubicSigner } from "@aigarth/sdk/x402";
// One signer per process. The wallet is the identity.
const signer = await QubicSigner.fromEnv("QUBIC_MNEMONIC");
const { body, receipt } = await payAndCall(
{
gatewayURL: "https://api.aigarth.cloud",
method: "POST",
resource: "/v1/chat/completions",
body: {
model: "aigarth-meridian-1",
messages: [{ role: "user", content: "Hello" }],
},
},
signer,
);
console.log(receipt.txHash);
// optional: claim the receipts into a full account at
// POST /v1/x402/claim?wallet=<your-address>QUBIC is what compute providers on Aigarth already earn. x402 closes the loop without an FX step.
QUBIC is what compute providers on Aigarth earn when they serve work. When an agent pays in QUBIC, the loop closes: the agent’s payment goes to the same token that the GPU operator receives. No FX, no bridging, no oracle.
The gateway verifies payments against the chain itself through our own services/qubic. No external facilitator, no third-party dependency, no shared custody.
USDT and USDC slot into the same scheme dispatcher in the next phase. The protocol envelope is identical. Agents switch rails without code changes, only a different signer.
Every x402 call gets an on-chain receipt. Sign up later, link the same wallet, and the receipts fold into your full account. No receipts lost.
Wallet is the identity. The gateway never stores anything for the agent.
x402 is the protocol. We don't shoehorn it onto Stripe.
Pays the same currency that the compute layer earns.
Same /v1/chat/completions, /v1/embeddings, /v1/images/generations routes.
Every receipt has a txHash. Settled in 20 ticks on Qubic mainnet.
The protocol spec lives in docs/x402.md. Anyone can implement a client.