You can create Payment Plans and register AI Agents manually or programatically:

Nevermined App

Go to the Nevermined App and click on “My agents” or “My pricing plans” to crete Payment Plans and register your AI Agents.

Payments Libraries

Use the Payments Libraries to programmatically create Payment Plans and register AI Agents.
In this guide, we will focus on how to register AI Agents and create Payment Plans using the Payments Libraries.
Once you have a Payments instance, you can start creating Plans and registering AI Agents.

Creating a Payment Plan

Payment Plans give AI Builders the ability to control how and when users can use an AI Agent or service. They are entirely controlled and managed by the AI Builder that creates them with no interference from Nevermined. Nevermined Payment Plans enable time-based or request-based gating of an AI Agent.

Creating Credit-Based Plans

Provides user access with per-request pricing. Builders can manage the cost per request to access their AI service. This is done by setting the price to purchase a bundle of credits and the number of credits redeemed for each request (call onfigured during Plan creation). Each time a request is made, user credits are validated and redeemed. If the user does not have enough credits, they will be prompted to purchase more and denied access until they do so.
// This is the USDC ERC20 address in the test network (sandbox)    
const USDC_ERC20_TESTING = '0x036CbD53842c5426634e7929541eC2318f3dCF7e'

const planMetadata = {
  name: 'My Credits Plan',
  tags: ['test']
}

// The price is 20 USDC (20_000_000) in the sandbox network
const priceConfig = getERC20PriceConfig(20_000_000n, USDC_ERC20_TESTING, builderAddress)
// The subscriber receives 100 credits upon purchasing the plan
const creditsConfig = getFixedCreditsConfig(100n)
// Register the plan
const { planId } = await payments.plans.registerCreditsPlan(
  planMetadata, 
  priceConfig, 
  creditsConfig
)

Creating a Time-Based Plan

Provides user access on a time-gating basis. Builders can set the time period that a user is allowed access to the AI (e.g. 1 year, 1 month, 1 hour, etc.). When a user makes their first request, the corresponding access credit is redeemed, granting access for the designated period. Once the time period has elapsed, the user will no longer have access and will need to redeem another credit for continued access.
// The price is 5 USDC (5_000_000) in the sandbox network
const priceConfig = getERC20PriceConfig(5_000_000n, ERC20_ADDRESS, builderAddress)
// The plan is valid for 1 day
const oneDayPlanConfig = getExpirableDurationConfig(ONE_DAY_DURATION)
// Register the plan
const { planId } = await payments.plans.registerTimePlan(
  planMetadata, 
  priceConfig, 
  oneDayPlanConfig
)

Creating a Trial Plan

A Trial Plan is a special type of Payment Plan that allows users to try out an AI Agent for a limited time (typically for free). A Trial Plan can only be obtained once by each user.
const trialPlanMetadata: PlanMetadata = {
  name: 'Try it for one day before you buy it',
}
// The price is free
const freeConfig = getFreePriceConfig()
// The plan is valid for 1 day
const oneDayPlanConfig = getExpirableDurationConfig(ONE_DAY_DURATION)
// Register the trial plan
const { planId } = await payments.plans.registerTimeTrialPlan(
  trialPlanMetadata, 
  freeConfig, 
  oneDayPlanConfig
)

Registering an AI Agent

When you register an Agent, you need to provide the API endpoints for accessing the AI Agent, including all relevant HTTP(s) methods, URL patterns and wildcards.
Before registering an AI Agent, you need to have a Payment Plan created.
// When you register an agent, you need to provide the endpoints that the agent exposes and are protected by the Payment Plan
// You must specify the HTTP method and the URL pattern that the agent exposes
// You can use wildcards (like :agentId in the example) to match any string
// See more information about the wildcards supported here: https://github.com/pillarjs/path-to-regexp

const agentMetadata: AgentMetadata = {
  name: 'E2E Payments Agent',
  tags: ['test'],
  dateCreated: new Date(),
  description: 'Description for the E2E Payments Agent'
}

// You can use wildcards (like :agentId in the example) to match any string in your endpoints
const agentApi = {
  endpoints: [
    { 'POST': 'https://example.com/api/v1/agents/:agentId/tasks' },
    { 'GET': 'https://example.com/api/v1/agents/:agentId/tasks/invoke' }
  ],
  openEndpoints: ['https://example.com/api/v1/rest/docs-json']
}
const paymentPlans = [creditsPlanId, expirablePlanId]

const { agentId } = await payments.agents.registerAgent(
  agentMetadata, 
  agentApi, 
  paymentPlans
)

Register an AI Agent and Payment Plan in One Step

This method allows you to create the plan and attach the agent to it in one step.
const agentMetadata = { 
  name: 'My AI Payments Agent', 
  tags: ['test2'], 
  description: 'Description for my AI Payments Agent' 
}
const agentApi = { endpoints: [{ 'POST': 'http://example.com/test/:agentId/tasks' }] }

const cryptoPriceConfig = getNativeTokenPriceConfig(500n, builderAddress)
// Non expirable payment plan
const nonExpirableConfig = getNonExpirableDurationConfig()

const { agentId, planId } = await paymentsBuilder.agents.registerAgentAndPlan(
  agentMetadata,
  agentApi,
  planMetadata,
  cryptoPriceConfig,
  nonExpirableConfig,
)

Key Concepts

Endpoint Protection

When registering an AI Agent, you specify:
  • Protected Endpoints: Require payment/subscription to access
  • Open Endpoints: Free to access (e.g., documentation, health checks)
  • URL Patterns: Support wildcards for dynamic routing

Payment Plan Types

Credits-Based

Sets the price per-request. Users buy a bundle of credits that are redeemed against usage.

Time-Based

Users get unlimited access for a specific time period (hours, days, months).

Trial Plans

Free access for limited time or credits to let users test your service.

Best Practices

Next Steps

Once you have registered your agents and plans, you can: