Machine Payments Protocol (MPP) on Tempo
The Machine Payments Protocol lets a wallet pay for an API call when the server quotes a price. Paid REST endpoints and MCP tools on glim.sh accept USDC.e on Tempo through MPP, alongside x402 and account keys, at the same per-call prices.
Make your first paid request
Use x402-proxy 0.12.3 or newer. Run setup if you need a wallet, then send USDC.e on Tempo mainnet to the Tempo address shown by the wallet command.
npx x402-proxy setup
npx x402-proxy walletWeb search costs $0.01 per call. Select MPP to have the proxy sign the challenge and retry automatically.
npx x402-proxy --protocol mpp --method POST \
--header "Content-Type: application/json" \
--body '{"query":"Machine Payments Protocol"}' https://glim.sh/api/v1/web/searchSign a charge with the mppx CLI
An unpaid REST request returns HTTP 402 with both PAYMENT-REQUIRED (x402) and WWW-Authenticate: Payment ... (MPP). Sign the intent="charge" challenge. Retry the same request with the credential in Authorization. A successful charge returns the data and a Payment-Receipt header confirming settlement.
Use a funded account from npx mppx account list. To set one up, run npx mppx account create -a main --network mainnet and fund its address with USDC.e on Tempo. The example uses the account named main.
node --input-type=module <<'JS'
import { execFileSync } from "node:child_process";
const url = "https://glim.sh/api/v1/web/search";
const headers = { "Content-Type": "application/json" };
const request = { method: "POST", body: JSON.stringify({ query: "Machine Payments Protocol" }) };
const unpaid = await fetch(url, { ...request, headers });
const charge = unpaid.headers.get("WWW-Authenticate")?.split(/,\s*(?=Payment )/)
.find(value => value.includes('intent="charge"'));
if (unpaid.status !== 402 || !charge) throw Error("Expected an MPP charge challenge");
const credential = execFileSync("npx", ["-y", "mppx", "sign", "-a", "main", "--challenge", charge],
{ encoding: "utf8" }).trim();
const paid = await fetch(url, { ...request, headers: { ...headers, Authorization: credential } });
if (!paid.ok || !paid.headers.has("Payment-Receipt")) throw Error("No settled charge");
console.log(await paid.json());
JSPay from JavaScript
Install the mppx SDK and viem with npm install mppx viem. In a server-side Node.js module, supply your funded Tempo wallet's hex private key through the TEMPO_PRIVATE_KEY environment variable.
import { Mppx, tempo } from "mppx/client";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.TEMPO_PRIVATE_KEY);
const client = Mppx.create({ methods: [tempo.charge({ account })], polyfill: false });
const res = await client.fetch("https://glim.sh/api/v1/web/search", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ query: "Machine Payments Protocol" }),
});
if (!res.ok || !res.headers.has("Payment-Receipt")) throw Error("No settled charge");
console.log(await res.json());Streaming inference
For streaming inference, send stream: true to POST /api/v1/inference/v1/chat/completions. Pay the quoted maximum price once before the stream starts. The response carries the charge receipt in the Payment-Receipt header.
MPP over MCP
At https://glim.sh/mcp, a wallet can send an MPP charge credential in _meta["org.paymentauth/credential"] on a tool call and read the receipt from _meta["org.paymentauth/receipt"]. An initial unpaid tool call returns an HTTP 200 tool error with an x402 challenge. With x402-proxy 0.12.3, mcp --protocol mpp returns that error to the client because it has no MPP challenge to sign. Use REST for automatic MPP payments, or follow the MCP quickstart for x402 or account access.
Prices and discovery
Use the amount and currency in the live challenge as your quote. The realm for the public API is glim.sh. MPPscan lists the service and its endpoints. For billing from a prepaid balance, see Payments & auth.
Troubleshooting
memo is not bound to this challengewith an older x402-proxy: upgrade to 0.12.3 or newer and request a fresh challenge.Transaction hash has already been usedmeans that payment was presented before. To make another paid call, request a fresh challenge and sign it.