> ## Documentation Index
> Fetch the complete documentation index at: https://neverminedag-sync-api-errors-9d14109.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Register a Plan & AI Agent

> Have an agent publish an AI agent and a priced payment plan on Nevermined — fiat or crypto, fixed credits or time-based — so others can discover and buy it.

Before anyone can pay for your service, it has to exist on Nevermined: an **agent** (what you sell) linked to a **plan** (how it's priced). An agent can do this for you in one call — the SDK builds the on-chain price and credits configuration, registers both, and returns the IDs you'll reference everywhere else.

<Note>
  This is a **seller** task. If you only want to **buy or use** an agent, you don't register one — see [Buy & Call a Paid Agent](/docs/getting-started/ai-agent-purchase).
</Note>

## Useful for

* **Going to market**: publishing a new AI agent or API and pricing access in one step.
* Choosing a **pricing model** — fixed credits, time-based, pay-as-you-go, or a free trial — without learning the on-chain details.
* Selling in **fiat or crypto**: priced in USD (Stripe / Braintree / Visa) or in USDC / EURC.

## Try it yourself

```text theme={null}
You are my autonomous payments agent. Register a new AI agent and a payment plan on Nevermined sandbox using the @nevermined-io/payments SDK. Follow the Nevermined `nevermined-payments` skill (https://github.com/nevermined-io/docs/tree/main/skills/nevermined-payments) (section A6) for method signatures.

- Agent: "Weather Agent" — description "On-demand weather forecasts", endpoint POST https://my-agent.example.com/forecast
- Plan: "Weather Starter" — 100 credits for $10, paid by card (fiat, Stripe default), 1 credit per request
- My builder wallet (receives payments): <your-builder-wallet>
- Environment: sandbox (NVM_API_KEY is set — never print it)

Build the config with the SDK helpers, then call payments.agents.registerAgentAndPlan(agentMetadata, agentApi, planMetadata, priceConfig, creditsConfig):
- Price: payments.plans.getFiatPriceConfig(amount, builderAddress, 'USD'). The fiat amount is in 6-decimal units (USDC convention), NOT cents — so $10 = 10_000_000n. Arg order is (amount, receiver, currency). All helper numeric args are BigInt — use the n suffix.
- Credits: payments.plans.getFixedCreditsConfig(100n, 1n) (100 granted, 1 per request).
- agentApi = { endpoints: [{ POST: 'https://my-agent.example.com/forecast' }] }.

Print the agentId and planId, then confirm with real REST calls:
1. GET /api/v1/protocol/plans/{planId} (public) → check metadata.curation.isListed === true, registry.price.isCrypto === false (fiat), registry.credits.amount === "100", and that the SUM of registry.price.amounts equals "10000000" ($10). Note: Nevermined takes a ~2% platform fee, so the array splits into ["9800000","200000"] across two receivers — verify the sum, not index 0; index 0 (9800000) is your wallet's net.
2. GET /api/v1/protocol/agents/{agentId}/plans (public) → confirm the plan id appears in plans[] (the plan is linked to the agent).

Report both IDs and the confirmation results. (Fiat provider defaults to Stripe and is not echoed in the plan JSON, so you can only confirm "fiat" via isCrypto:false, not "Stripe" specifically.)
```

## How it works

<Steps>
  <Step title="Build the price and credits config">
    Pick one **price** helper and one **credits** helper — they produce the on-chain config so you don't hand-build it:

    <Tabs>
      <Tab title="TypeScript">
        ```typescript theme={null}
        // Price: fiat (Stripe/Braintree/Visa) — amount in 6-decimal units ($10.00)
        const priceConfig = payments.plans.getFiatPriceConfig(10_000_000n, BUILDER_ADDRESS, 'USD')
        // or crypto: getERC20PriceConfig(10_000_000n, USDC_ADDRESS, BUILDER_ADDRESS)

        // Credits: 100 granted, 1 burned per request
        const creditsConfig = payments.plans.getFixedCreditsConfig(100n, 1n)
        // or getExpirableDurationConfig(...) (time-based) · getPayAsYouGoCreditsConfig() (per-call)
        ```
      </Tab>

      <Tab title="Python">
        ```python theme={null}
        # Price: fiat — amount in 6-decimal units ($10.00)
        price_config = payments.plans.get_fiat_price_config(10_000_000, BUILDER_ADDRESS, "USD")
        # or crypto: payments.plans.get_erc20_price_config(10_000_000, USDC_ADDRESS, BUILDER_ADDRESS)

        # Credits: 100 granted, 1 burned per request
        credits_config = payments.plans.get_fixed_credits_config(100, 1)
        ```
      </Tab>
    </Tabs>

    <Note>
      In TypeScript, plan config amounts are `BigInt` — always pass `…n` (e.g. `10_000_000n`).
    </Note>
  </Step>

  <Step title="Register the agent and plan together">
    One call publishes both and links them:

    <Tabs>
      <Tab title="TypeScript">
        ```typescript theme={null}
        const { agentId, planId } = await payments.agents.registerAgentAndPlan(
          { name: 'Weather Agent', description: 'On-demand forecasts', tags: ['weather'], dateCreated: new Date() },
          { endpoints: [{ POST: 'https://my-agent.example.com/forecast' }] },
          { name: 'Weather Starter', description: '100 requests for $10', dateCreated: new Date() },
          priceConfig,
          creditsConfig,
        )
        console.log({ agentId, planId })
        ```
      </Tab>

      <Tab title="Python">
        ```python theme={null}
        result = payments.agents.register_agent_and_plan(
            agent_metadata={'name': 'Weather Agent', 'description': 'On-demand forecasts', 'tags': ['weather']},
            agent_api={'endpoints': [{'POST': 'https://my-agent.example.com/forecast'}]},
            plan_metadata={'name': 'Weather Starter', 'description': '100 requests for $10'},
            price_config=price_config,
            credits_config=credits_config,
        )
        print(result['agentId'], result['planId'])
        ```
      </Tab>
    </Tabs>

    The `endpoints` are optional — omit them for an open agent, or include them so the platform enforces route-level access on top of your own middleware.
  </Step>

  <Step title="Confirm it's published">
    List what you've published to verify the agent and plan are live:

    ```http theme={null}
    GET {API_BASE}/protocol/agents
    Authorization: Bearer <api-key>
    ```

    Each item is the full record — read the name from `metadata.main.name` and the id from `id`. Then point buyers at your organization's `agentic-instructions.md`, where published plans and agents appear automatically.
  </Step>
</Steps>

<Note>
  Prefer no code? You can register and price everything in the web app — see [Register Agents](/docs/products/nevermined-app/register-agents).
</Note>

## Related

<CardGroup cols={2}>
  <Card title="Add payments to your agent" icon="plug" href="/docs/agents-guide/add-payments">
    Gate the registered agent's endpoints behind the plan.
  </Card>

  <Card title="Register Agents (App)" icon="store" href="/docs/products/nevermined-app/register-agents">
    The no-code path to publishing agents and plans.
  </Card>

  <Card title="Check revenue" icon="chart-line" href="/docs/agents-guide/check-revenue">
    Track sales once buyers start arriving.
  </Card>

  <Card title="Order Plans" icon="cart-shopping" href="/docs/development-guide/order-plans">
    How buyers purchase the plan you just created.
  </Card>
</CardGroup>
