Skip to content
Tenzro
← All tutorials
Tutorial · Payments

Pay for inference in stablecoins

Hold USDC in a Bridge.xyz wallet, pay per call for chat, embeddings, audio and vision on Tenzro Network over x402 or MPP, and reconcile every charge.

Beginner15 min

You do not need to hold TNZO to use the network. On Tenzro Network you can keep a stablecoin balance, pay for each inference call in USDC over the open x402 and MPP protocols, and pay gas in stablecoins too. Settlement is metered and per use by default: you pay for what each call actually consumed, and every response tells you what it cost.

This tutorial takes you from an empty wallet to a paid chat completion and a paid transcription, then shows how to reconcile the charges.

Prerequisites

  • A browser and device that support passkeys.
  • Node.js 20 or newer.
  • Background: Stablecoin payments.

1. Create a wallet and add stablecoins

  1. Create a passkey wallet in the console. Link a second device while you are there, so a lost phone never locks you out.
  2. From the wallet page, add a stablecoin wallet. Stablecoin wallets are provided through Bridge.xyz. Deposit USDC to the address it shows.
  3. If you want an agent or a server process to pay rather than your own browser, create a delegated agent in Agents with a daily cap and move an allowance to it. See Build an AI payment agent.

2. See where stablecoin charges can settle

Every charge settles on a rail that can carry it economically. The network publishes the rails it knows, which stablecoins are native on each and whether each speaks x402:

bash
curl -s https://rpc.tenzro.com \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tenzro_settlementNetworks","params":{}}' \
  | jq '.networks[] | {caip2, name, native_stablecoins, x402, min_payment_micro_usd}'

Pass an amount to see how a specific charge would be routed:

bash
curl -s https://rpc.tenzro.com \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tenzro_settlementNetworks","params":{"amount_wei":"1000000000000","asset":"USDC"}}' \
  | jq .result.route

settles_now: true means the charge settles on its own. For charges too small to settle alone, the route says so and suggests the remedy: open a payment channel or an MPP session so many small charges settle together.

3. Pay for a chat completion in USDC

Install the SDK:

bash
npm install tenzro-sdk

Call the route without credentials and the provider answers 402 Payment Required with a challenge naming the price, the asset and the payee. Pay it with the paying account's signer, never more than your budget:

ts
import { TenzroClient } from "tenzro-sdk";
import { signer } from "./signer"; // your passkey wallet or agent hardware key

const client = new TenzroClient({ endpoint: "https://rpc.tenzro.com" });

const res = await fetch("https://rpc.tenzro.com/v1/chat/completions", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({
    model: "qwen3.6-35b-a3b",
    messages: [{ role: "user", content: "List three things to check before renting a GPU by the hour." }],
  }),
});

if (res.status === 402) {
  const challenge = await res.json(); // the price, asset (USDC) and payee
  const receipt = await client.payment.payChallenge(challenge, signer, "did:tenzro:human:<you>", 20_000n); // at most 0.02 USDC
  console.log(receipt);
}

From a terminal, tenzro x402 pay <URL> pays a resource's 402 from your account and fetches it in one step. For long answers that stream token by token, open an MPP session instead, so many small charges settle together; see Payments with MPP.

4. Pay for other modalities

The same flow works for every paid route: embeddings, images, audio, video and the Tenzro vision and timeseries routes. Each answers 402 with its own price, and you pay it the same way. Without the SDK, call any paid route with curl; the 402 response carries the challenge and the price. See Payments with x402.

5. Reconcile every charge

Each paid response reports what was metered and what it cost. JSON-RPC inference responses also carry a settlement object that says how the call was paid and how the payment was split:

json
{
  "units": { "...": "..." },
  "cost_wei": "…",
  "settlement": {
    "status": "settled",
    "via": "transfer",
    "network_wei": "…",
    "provider_wei": "…",
    "margin_wei": "0",
    "provider": "0x<provider-wallet>",
    "app_id": null
  }
}
  • provider_wei went to the operator who served the call; network_wei to the rest of the network.
  • margin_wei is the developer margin when you call through an app that adds one.
  • via is transfer for a direct payment or channel for a debit from an open payment channel.

Look up any payment later by its reference:

bash
curl -s https://rpc.tenzro.com \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tenzro_getPayment","params":{"pay_ref":"<pay-ref>"}}'

6. Pay gas in stablecoins too

On-chain actions, such as funding an agent or registering a resource, need gas. Tenzro Network accepts gas in stablecoins, so a stablecoin-only account can still transact. See Stablecoin payments.

Next steps