Skip to main content
The x402 Facilitator supports multiple payment models to match your product needs across APIs, agents/tools, and protected resources. These models are enabled by Nevermined’s programmable x402 settlement layer (smart accounts + policies + contracts), not just single-transfer pay-per-request flows. If you’re looking for the HTTP handshake details (402 discovery → retry with PAYMENT-SIGNATURE), see: Further reading:

Payment Model Types

Credits-Based

Charge per request or API call. Users purchase credits and consume them with each query.

Time-Based

Subscription access for specific durations. Unlimited usage within the time period.

Dynamic

Variable pricing based on request complexity, token count, or custom metrics.

Hybrid

Combine time-based access with credit limits for balanced monetization.

Credits-Based Plans

Charge users based on actual usage. Each request consumes a configurable number of credits.
import {
  Payments,
  getERC20PriceConfig,
  getFixedCreditsConfig
} from '@nevermined-io/payments'

const payments = Payments.getInstance({
  nvmApiKey: process.env.NVM_API_KEY,
  environment: 'sandbox'
})

// Price: 10 USDC for 100 credits
const priceConfig = getERC20PriceConfig(
  10_000_000n,                    // 10 USDC (6 decimals)
  '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC address
  process.env.BUILDER_ADDRESS     // Your receiving address
)

// Credits: 100 total, 1 per request
const creditsConfig = getFixedCreditsConfig(
  100n,  // Total credits
  1n     // Credits per request
)

const { planId } = await payments.plans.createPlan({
  agentId: 'did:nv:agent-123',
  name: 'Pro Plan - 100 Queries',
  description: 'Access to AI assistant with 100 queries',
  priceConfig,
  creditsConfig,
  accessLimit: 'credits'
})

Time-Based Plans

Provide unlimited access for a specific duration. Great for subscription models.
import { getTimeBasedConfig } from '@nevermined-io/payments'

// Price: 50 USDC for 30 days access
const priceConfig = getERC20PriceConfig(
  50_000_000n,
  '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  process.env.BUILDER_ADDRESS
)

// Duration: 30 days (in seconds)
const timeConfig = getTimeBasedConfig(
  30 * 24 * 60 * 60  // 30 days in seconds
)

const { planId } = await payments.plans.createPlan({
  agentId: 'did:nv:agent-123',
  name: 'Monthly Subscription',
  description: 'Unlimited access for 30 days',
  priceConfig,
  timeConfig,
  accessLimit: 'time'
})

Dynamic Pricing

Charge variable amounts based on request complexity. The x402 max_amount field controls the maximum charge per request.
import { getDynamicCreditsConfig } from '@nevermined-io/payments'

// Dynamic: charge 1-10 credits based on request
const creditsConfig = getDynamicCreditsConfig(
  1n,   // Minimum credits per request
  10n   // Maximum credits per request
)

const { planId } = await payments.plans.createPlan({
  agentId: 'did:nv:agent-123',
  name: 'Pay As You Go',
  description: 'Variable pricing based on complexity',
  priceConfig,
  creditsConfig,
  accessLimit: 'credits'
})

// During settlement, specify actual amount
await payments.facilitator.settlePermissions({
  planId,
  maxAmount: BigInt(actualCreditsUsed), // 1-10 based on request
  x402AccessToken: token,
  subscriberAddress: address
})

Trial Plans

Offer free trials to attract new users.
// Free credits trial
const { planId } = await payments.plans.registerCreditsTrialPlan({
  agentId: 'did:nv:agent-123',
  name: 'Free Trial',
  description: '10 free queries to try the service',
  credits: 10n,
  creditsPerRequest: 1n
})

// Free time-based trial
const { planId: timePlanId } = await payments.plans.registerTimeTrialPlan({
  agentId: 'did:nv:agent-123',
  name: '7-Day Trial',
  description: 'Unlimited access for 7 days',
  duration: 7 * 24 * 60 * 60  // 7 days in seconds
})

Multi-Tier Pricing

Create multiple plans for different user segments:
// Basic tier
const basicPlan = await payments.plans.createPlan({
  agentId,
  name: 'Basic',
  priceConfig: getERC20PriceConfig(5_000_000n, usdcAddress, builderAddress),
  creditsConfig: getFixedCreditsConfig(50n, 1n)
})

// Pro tier
const proPlan = await payments.plans.createPlan({
  agentId,
  name: 'Pro',
  priceConfig: getERC20PriceConfig(20_000_000n, usdcAddress, builderAddress),
  creditsConfig: getFixedCreditsConfig(250n, 1n)  // Better value
})

// Enterprise tier
const enterprisePlan = await payments.plans.createPlan({
  agentId,
  name: 'Enterprise',
  priceConfig: getERC20PriceConfig(100_000_000n, usdcAddress, builderAddress),
  creditsConfig: getFixedCreditsConfig(2000n, 1n)  // Best value
})

Payment Currencies

Cryptocurrency (ERC-20)

Accept any ERC-20 token on supported networks:
// USDC
const usdcConfig = getERC20PriceConfig(
  10_000_000n,
  '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  builderAddress
)

// USDT
const usdtConfig = getERC20PriceConfig(
  10_000_000n,
  '0xdAC17F958D2ee523a2206206994597C13D831ec7',
  builderAddress
)

Fiat (Stripe)

Accept credit card payments via Stripe integration:
const fiatConfig = await payments.plans.getFiatPriceConfig({
  amount: 1000,      // $10.00
  currency: 'USD'
})

// Users purchase via Stripe checkout
const { url } = await payments.plans.orderFiatPlan(planId)
// Redirect user to Stripe checkout URL

Choosing the Right Model

ModelBest ForExample
Credits-basedAPI calls, queries, transactionsAI chatbot, image generation
Time-basedContinuous access, subscriptionsSaaS tools, monitoring
DynamicVariable workloads, token-basedLLM inference, batch processing
HybridBalanced usage with limitsEnterprise subscriptions

Next Steps