# How do I pay for an MPP API?

> Install an MPP client, give it a way to pay, and make your request through it. The reference client, mppx, patches fetch so that a 402 reply is paid and retried for you. With the Tempo method you need a wallet holding a stablecoin on Tempo. Other methods let you pay by card or Lightning. Clients exist for TypeScript, Python, Rust and Go.

## What you need

1. **An MPP client library** for your language.
2. **A way to pay** that the seller accepts. That depends on the payment method: a funded wallet for Tempo, a card for the card method, a Lightning wallet for Lightning.
3. **The address of a paid endpoint.**

Before writing code, paste the endpoint into the [402 checker](https://www.ask402.ai/tools/402-checker). It lists the MPP payment methods the seller offers, so you know what you need to hold.

## Install a client

```bash
npm install accounts mppx viem
```

`mppx` is the reference implementation, in TypeScript. The MPP site also lists `pympp` for Python, `mpp-rs` for Rust and `mpp-go` for Go.

## Make a paid request

This is the pattern from the official client quickstart, using the Tempo payment method.

```typescript
import { privateKeyToAccount } from 'viem/accounts'
import { Mppx, tempo } from 'mppx/client'

// Load the key from the environment. Never paste it into code.
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)

Mppx.create({
  methods: [tempo({ account })],
})

const response = await fetch('https://mpp.dev/api/ping/paid')
```

`Mppx.create` replaces the global `fetch`. After that, an ordinary `fetch` call pays by itself when the seller answers 402, then returns the paid response.

The wallet must hold the currency the seller asks for, on the network it asks for.

## Ways to hold the wallet

The quickstart shows three:

- **A private key** read from the environment on a server.
- **The Accounts SDK**, which connects a user's wallet.
- **A Privy wallet**, where a provider holds the key.

If you would like to approve each payment yourself, the client has a manual mode that hands you the payment to confirm before it is sent.

## Try it from the command line

The `mppx` package includes a command-line tool. To make a paid request on the test network:

```bash
npx mppx account create --network testnet
npx mppx account fund --network testnet
npx mppx https://your-server.example/resource --network testnet
```

Test tokens have no value, so this is the safe way to see a full payment.

## Paying without crypto

MPP is not limited to stablecoins. The payment methods list includes `card`, for card payments through encrypted network tokens, and `stripe`, for traditional payment methods through Stripe. Whether you can use one depends on the seller offering it. See [MPP payment methods](https://www.ask402.ai/x402/mpp-payment-methods).

## Keep it safe

The same habits apply as for x402:

- Use a separate wallet for paying APIs, with a small balance.
- Look at the price and recipient before you pay. The [402 checker](https://www.ask402.ai/tools/402-checker) shows both.
- Be careful giving an autonomous agent a funded wallet. It will pay for whatever it is persuaded to call. See [is x402 safe?](https://www.ask402.ai/x402/is-x402-safe), which covers risks that apply to both protocols.

## If the endpoint also takes x402

Many do. A server can offer both protocols in one 402 reply. If you already have an x402 client and USDC on a network the seller lists, you can pay that way. See [how to pay an x402 API](https://www.ask402.ai/x402/how-to-pay-an-x402-api) and [x402 vs MPP](https://www.ask402.ai/x402/x402-vs-mpp).

## Sources

- [MPP client quickstart, mpp.dev](https://mpp.dev/quickstart/client)
- [MPP server quickstart, mpp.dev (command-line tool)](https://mpp.dev/quickstart/server)
- [MPP payment methods](https://mpp.dev/payment-methods)
- [MPP overview, mpp.dev](https://mpp.dev/overview)

---

Facts checked against the sources above on 2026-11-20. Canonical page: https://www.ask402.ai/x402/how-to-pay-an-mpp-api
