← Back to perly.io
Perly

How to charge for an AI agent, API or MCP server

Published November 19, 2026

To charge for an AI agent, an API or an MCP server, pick a unit people understand — a call, a task, a month — and sell it in advance as prepaid credits or a plan. Check the balance on your server before each call, and answer an empty balance with a link to top up. Payment can come by card or in crypto; with stablecoins and a non-custodial gateway it goes from the buyer straight to your own wallet, from most countries.

Pick what you charge for

A usage-based product costs you money on every call: model tokens, compute, other people's APIs. The price should follow the same unit, or a bundle of it a person can reason about.

  • Prepaid credits. A person buys a balance and each call spends part of it. It fits APIs, models and agents whose cost varies by request, and you are paid before you spend.
  • A plan. A monthly or yearly price for a level of use. It fits AI software used steadily; set a fair-use limit so one heavy user cannot cost more than they pay.
  • A license key. A one-off or yearly price for an app or a self-hosted tool, checked when it starts.
  • Access to a bot. A paid Telegram or Discord bot, sold per person for a period.

Why prepaid credits suit agents

An agent can make hundreds of calls in a minute without anyone watching. If you bill afterwards, a loop in someone's code or a leaked key becomes a debt you have to chase. With credits sold in advance, the most anyone can spend is what they already paid, and the person behind the agent decides how much that is. The payment stays with a person: they top up in the browser, and the agent only spends.

Metering: count every call once

  • Check and spend in one step. Take the credits off the balance atomically on your server and refuse the call if the balance would go below zero, so two calls at the same moment cannot both spend the last credit.
  • Use an idempotency key. A request retried after a timeout must not spend twice: the retry sends the same key, and the credits come off once.
  • Spend on your server, never in the client. The balance lives where the agent cannot change it.
  • Warn before zero. A low-balance email to the buyer, or a webhook to your app, saves a task from failing at the worst moment.

When the balance runs out: answer 402

HTTP reserves a status code for this, 402 Payment Required, and leaves its exact use to each API. Return it with a short message and a link where the person can top up, and an agent will show that link to the person it works for instead of failing silently. A paid MCP server can do the same from inside a tool: return the top-up link as the tool's answer, and the assistant passes it on.

Should the agent pay by itself?

There are protocols that let an agent pay for each request from a wallet of its own. They suit payments between machines, but they mean giving software the keys to money, setting limits on it, and accepting payments nobody approved at the time. For most products sold to people today it is simpler and safer for the person to pay, once and in advance, and for the agent to spend a balance it cannot go beyond.

Getting paid: cards or crypto

Cards are familiar, but card processors take a percentage of each payment, can hold back payouts, allow chargebacks, and do not reach every country. Stablecoins such as USDC and USDT (the difference) arrive within a minute on low-fee networks (network fees), from most of the world, and cannot be charged back. With a non-custodial gateway, each top-up gets its own address derived from your public key and lands in your wallet, while the gateway watches the chain and, once a top-up is paid, adds the credits to the buyer's balance or tells your server through a signed webhook. More on the set-ups: how to accept crypto payments.

What to plan for

  • Refunds. Crypto has no chargebacks, so decide your rule for unused credits, and send a refund as a new payment to an address the buyer gives.
  • Prices in your currency. Price credits in dollars or euros and let each invoice set the crypto amount when it opens, so the buyer pays the exact price and you know what each top-up was worth.
  • Records and tax. Record each top-up's value at the time it arrived. Rules differ by country; ask an accountant.
  • Test first. Run the whole loop — the top-up, the spending, the 402 answer, the webhook — in a test mode before real money moves.

Where Perly fits

Short answers

How do I charge for an MCP server?

Sell credits or a plan to the person who uses it, check the balance on your server inside each paid tool, and when it runs out return a link to top up. The assistant shows the link, the person pays, and the tool works again.

What does HTTP 402 Payment Required mean?

HTTP reserves it for requests that need payment and leaves the details open. APIs use it to say a balance or a plan has run out, together with a link or instructions to pay.

Credits or a subscription for an AI API?

Credits fit when use and cost vary from request to request; a plan fits steady use. Many products offer both: a plan with a monthly allowance, and credits for anything above it.

Can an AI agent pay in crypto by itself?

It can be given a wallet, but it is usually simpler to let the person pay instead: they buy credits from their own wallet, and the agent spends the balance without holding any money.

Sources

  1. RFC 9110, HTTP Semantics: 402 Payment Required
  2. Model Context Protocol specification

This guide explains how things work. It is not financial, investment or tax advice. Something wrong? Write to hi@perly.io and we will correct it.

← Back to perly.io

© 2026 Perly. All rights reserved.