x402 on Qubic mainnet

Pay per call. No API key.

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.

HTTP 402, done right.

x402 is an open protocol for machine-paid HTTP. Aigarth ships it on QUBIC today, with USDT and USDC in a follow-up phase.

step 01

Call the gateway

POST /v1/chat/completions with your model and messages. No Bearer header.

step 02

Read the 402

The gateway returns HTTP 402 with the cost, the pay-to address, and a single-use nonce.

step 03

Sign and retry

Sign a Qubic tx for the cost, add an X-PAYMENT header with proof of payment, retry.

step 04

Receive the receipt

The 200 OK comes back with an X-PAYMENT-RESPONSE header. The receipt is auditable on chain.

API keys are the wrong tool for agents.

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.

Identification

Stored as a long-lived secret in agent config.

No key. The wallet proves the caller each request.

Billing

Fixed usage tiers, monthly subscriptions, surprise overages.

Pay what you use, in QUBIC. No subscription. No minimums.

Forecasting

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.

Three lines of code.

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>

The currency of the network.

QUBIC is what compute providers on Aigarth already earn. x402 closes the loop without an FX step.

Native settlement

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.

Direct on-chain verification

The gateway verifies payments against the chain itself through our own services/qubic. No external facilitator, no third-party dependency, no shared custody.

USD on the way

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.

Receipts you can claim

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.

No API key required

Wallet is the identity. The gateway never stores anything for the agent.

402 Payment Required, native

x402 is the protocol. We don't shoehorn it onto Stripe.

QUBIC today

Pays the same currency that the compute layer earns.

OpenAI-compatible

Same /v1/chat/completions, /v1/embeddings, /v1/images/generations routes.

On-chain audit

Every receipt has a txHash. Settled in 20 ticks on Qubic mainnet.

Public and open

The protocol spec lives in docs/x402.md. Anyone can implement a client.

Try it with a Qubic wallet.

Fund a wallet on Qubic mainnet, point an AI agent at the gateway, and the rest happens automatically. No human in the loop.

No signup No card on file No key rotation Per-call receipts