> ## Documentation Index
> Fetch the complete documentation index at: https://beta-docs.nevermind.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Register Agent and Plan

> Registers a new AI agent along with a payment plan.

Registers a new AI agent along with a payment plan in a single transaction using the Nevermined Payments API.

This is the most common entrypoint for AI Builders looking to monetize their services immediately after deploying them.

## Example Usage

```ts theme={null}
import { Payments } from '@nevermined-io/payments'

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

const agentMetadata = {
  name: 'Corporate Swiss Law assistant',
  tags: ['legal', 'assistant'],
  dateCreated: new Date('2024-12-31')
}

const agentApi = {
  endpoints: [{ POST: 'https://example.com/api/query' }]
}

// Configure pricing - 10 USDC fixed price
const priceInUSDC = getERC20PriceConfig(10_000_000n, USDC_ERC20_ADDRESS, builderAddress)

// Configure credits - 100 credits with 5 credits per request
const fiveCreditsPerRequest = getFixedCreditsConfig(100n, 5n)

const { agentId, planId } = await payments.registerAgentAndPlan(
  agentMetadata,
  agentApi,
  priceInUSDC,
  fiveCreditsPerRequest
)
```

## Parameters

* `agentMetadata`: Metadata about the AI agent including name, tags, and creation date.
* `agentApi`: Defines the query endpoints the agent exposes.
* `price`: Configuration object describing cost, token type, and receiver(s).
* `credits`: Defines what the subscriber gets (number of credits, expiration, etc.).

## Returns

```ts theme={null}
{
  agentId: string
  planId: string
}
```

Returns the unique identifiers of the newly created agent and the payment plan.

## Notes

* You must initialize the `Payments` client before calling this method.
* The plan will immediately be associated with the registered agent.
* All pricing and credit logic is enforced on-chain.


## OpenAPI

````yaml POST /agent
openapi: 3.1.0
info:
  title: Nevermined API
  description: >-
    API for managing AI agents, payment plans, and subscriptions in the
    Nevermined ecosystem
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: http://sandbox.mintlify.com
security:
  - bearerAuth: []
paths:
  /agent:
    post:
      tags:
        - Agents
      summary: Register Agent and Plan
      description: Registers a new AI agent along with a payment plan.
      operationId: registerAgentAndPlan
      requestBody:
        description: Agent and plan to register
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                agentMetadata:
                  $ref: '#/components/schemas/AgentMetadata'
                agentApi:
                  type: object
                  properties:
                    endpoints:
                      type: array
                      items:
                        type: object
                price:
                  type: object
                credits:
                  type: object
      responses:
        '200':
          description: Agent and plan created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NewAgentResponse'
        '400':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AgentMetadata:
      type: object
      properties:
        name:
          type: string
        tags:
          type: array
          items:
            type: string
        dateCreated:
          type: string
          format: date-time
    NewAgentResponse:
      type: object
      properties:
        agentId:
          type: string
        planId:
          type: string
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````