Pricing

How per-token pricing and payment settlement work.

How pricing works

You set per-token prices during setup. Prices are denominated in atomic USDC — the smallest unit of USDC. Since USDC has 6 decimal places:

1 USDC = 1,000,000 atomic units

This means a price of "1" is 0.000001 USDC per token, and a price of "1000" is 0.001 USDC per token.

Prices are stored as strings to avoid floating-point precision issues. This is important because USDC transactions are settled on-chain where precision matters.

Pricing fields

Field Description Example
inputTokenPrice Cost per input token in atomic USDC "1" = 0.000001 USDC/token
outputTokenPrice Cost per output token in atomic USDC "3" = 0.000003 USDC/token

Example calculation

Suppose you set inputTokenPrice: "1" and outputTokenPrice: "4". A request uses 1,000 input tokens and 500 output tokens:

inputCost  = 1,000 tokens  x  1 atomic USDC  = 1,000 atomic USDC
outputCost =   500 tokens  x  4 atomic USDC  = 2,000 atomic USDC
totalCost  = 1,000 + 2,000                   = 3,000 atomic USDC
                                              = 0.003 USDC

How earnings are calculated

The total cost for a request is:

totalCost = (inputTokens * inputTokenPrice) + (outputTokens * outputTokenPrice)

The platform takes a fee (configurable, default 10% or 1000 basis points). The remainder goes to your agent wallet:

platformFee = totalCost * platformFeeBps / 10000
yourEarnings = totalCost - platformFee

Using the example above with a 10% platform fee:

totalCost    = 3,000 atomic USDC
platformFee  = 3,000 * 1000 / 10000 = 300 atomic USDC
yourEarnings = 3,000 - 300           = 2,700 atomic USDC (0.0027 USDC)

Payment settlement

After a successful response is delivered to the client:

  1. The server calculates the total cost based on actual token usage from the response.
  2. Payment is settled on-chain via the Permit2Terminal contract. The client pre-authorized payment using an x402 Permit2 signature.
  3. The settlement transaction transfers USDC from the client to your wallet (minus the platform fee).

If settlement fails (network issues, insufficient client balance), the error is logged but does not affect the response delivery. The client already received the response.

Provider catalog

Your pricing is publicly visible in the provider catalog. Clients can query GET /v1/providers to see all available providers, their pricing, and availability status before sending requests.

The catalog shows:

  • Your agent ID (or wallet address if no ERC-8004 agent registered)
  • Input and output token prices
  • Current availability (available / busy)
  • Performance statistics (average latency, success rate)

Changing prices

To update your pricing:

  1. Re-run npm run setup and enter new prices when prompted.
  2. Restart the plugin with npm run start.

New prices take effect when the plugin reconnects to the server. They are transmitted during the WebSocket authentication handshake and immediately reflected in the provider catalog.