Developer Guide
Get started with MPP on Sui — pay for APIs or accept payments on yours.
Quickstart
Pay for any API:
import { Mppx } from 'mppx/client';
import { sui } from '@suimpp/mpp/client';
const mpp = Mppx.create({
methods: [sui({ client, signer })],
});
const res = await mpp.fetch('https://api.example.com/v1/generate', {
method: 'POST',
body: JSON.stringify({ prompt: 'Hello' }),
});Accept payments:
import { Mppx } from 'mppx/nextjs';
import { sui } from '@suimpp/mpp/server';
const mpp = Mppx.create({
methods: [sui({
currency: SUI_USDC,
recipient: '0xYOUR_ADDRESS',
})],
});
export const POST = mpp.charge({ amount: '0.01' })(
async (req) => Response.json({ ok: true })
);Quick start with t2000
Skip the SDK setup — onboard via web app, CLI, or agent skills.
1.Install
Install the MPP client library and the Sui payment method:
npm install mppx @suimpp/mppbash
2.Configure your wallet
Create an mppx client with your Sui keypair. The client handles 402 challenges automatically — when a server requires payment, it pays with your USDC and retries.
import { Mppx } from 'mppx/client';
import { sui } from '@suimpp/mpp/client';
import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
const client = new SuiClient({ url: getFullnodeUrl('mainnet') });
const signer = Ed25519Keypair.deriveKeypair('your mnemonic');
const mpp = Mppx.create({
methods: [sui({ client, signer })],
});3.Make a payment
Use mpp.fetch() just like fetch(). If the API returns 402, payment happens transparently:
const response = await mpp.fetch(
'https://mpp.t2000.ai/openai/v1/chat/completions',
{
method: 'POST',
body: JSON.stringify({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello' }],
}),
}
);
const data = await response.json();4.Custom execution (optional)
Override transaction execution for gas sponsorship, multi-sig, or custom signing flows:
const mpp = Mppx.create({
methods: [sui({
client,
signer,
execute: async (tx) => {
// Custom gas management, sponsored transactions, etc.
const result = await myCustomExecutor(tx);
return { digest: result.digest };
},
})],
});5.What happens under the hood
1.Client sends
POST /v1/chat/completions2.Server returns
402 + WWW-Authenticate: MPP method="sui", amount="0.03", ...3.Client builds & executes USDC transfer on Sui (~400ms)
4.Client retries with
Authorization: MPP digest="..."5.Server verifies on-chain, delivers response
6.Browse servers
Explore MPP servers accepting Sui USDC on the server directory. Each server lists its endpoints, pricing, and capabilities. View the protocol specification in the charge method spec.