> ## 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.

# Redeem Credits

> Redeems a specific number of credits from a subscriber's balance.

Redeems a specific number of credits from a subscriber's balance after a valid request.

This is typically used by builders after validating a request signature.

## Example Usage

```ts theme={null}
// Authorize the user and process the AI request first
// Then redeem credits after successful processing
const creditsToRedeem = 5n 
const result = await payments.redeemCredits(planId, creditsToRedeem, proof)
```

## Parameters

* **planId**: ID of the active payment plan
* **amount**: Number of credits to redeem (BigInt)
* **proof**: Signature or encoded proof provided with the query

## Response

```json theme={null}
{
  "success": true,
  "creditsRedeemed": "number",
  "remainingBalance": "number"
}
```

## Notes

* Credits will be deducted from the user's plan balance
* Will fail if credits are insufficient or the proof is invalid


## OpenAPI

````yaml POST /plan/{planId}/redeem
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:
  /plan/{planId}/redeem:
    post:
      tags:
        - Plans
      summary: Redeem Credits
      description: Redeems a specific number of credits from a subscriber's balance.
      operationId: redeemCredits
      parameters:
        - name: planId
          in: path
          description: The unique identifier of the plan.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Redemption successful
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  creditsRedeemed:
                    type: integer
                  remainingBalance:
                    type: integer
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````