Nevermined Payments

Integrate Nevermined for AI payments, subscriptions, and access control

Overview

The "Nevermined Payments" node integrates with the Nevermined platform to manage AI-related payments, subscriptions, and access control. Specifically, the Check Balance operation validates whether a user has sufficient credits under a subscription plan to access a particular resource or perform an API call.

This operation is useful in scenarios where you want to enforce usage limits or subscription checks before allowing access to AI services or APIs. For example, before processing a request to an AI model, you can verify if the user has enough credits left on their plan to proceed, ensuring fair usage and monetization.

Practical examples:

  • Validating API calls from users against their subscription plans.
  • Checking if a user can access premium AI features based on remaining credits.
  • Enforcing credit-based billing for AI service consumption.

Properties

Name Meaning
Request Parameters JSON object containing the request details to validate. Must include the fields: userId, planId, requestType, and resource. Example: { "userId": "user_123", "planId": "plan_456", "requestType": "api_call", "resource": "/api/v1/chat" }
Agent ID Optional string specifying an Agent ID to validate the request against a specific agent. If provided, the validation ensures the request is allowed for this particular agent.

Output

The output JSON contains detailed information about the validation result of the user's balance and subscription status:

  • isValid: Boolean indicating if the user is a subscriber and has sufficient credits.
  • validationId: A unique identifier for this validation event.
  • timestamp: The time when the validation was performed.
  • request: Echoes back the parsed request parameters.
  • subscription: Object detailing subscription status and credits:
    • isSubscriber: Whether the user is currently subscribed.
    • totalCredits: Total credits allocated in the plan.
    • usedCredits: Credits already used.
    • remainingCredits: Credits still available.
  • If valid (isValid is true and credits remain):
    • accessGranted: Object specifying the resource, permissions granted (e.g., "read", "write"), and number of credits to deduct (usually 1).
  • If invalid:
    • accessDenied: Object explaining the reason ("Insufficient credits" or "Not a subscriber") and suggested action (e.g., purchase additional credits or a plan).
  • environment: Indicates the environment used ("production" or "test").
  • message: Human-readable summary of the validation outcome.

No binary data is output by this operation.

Dependencies

  • Requires an API key credential for authenticating with the Nevermined Payments API.
  • The node makes HTTP requests to the Nevermined API endpoints, which differ based on environment (production or test).
  • Proper configuration of the API base URLs and credentials is necessary.
  • The node depends on n8n's HTTP request helper for making authenticated API calls.

Troubleshooting

  • Missing or invalid API key: The node will throw an error if no API key is provided or if authentication fails. Ensure the API key credential is correctly configured.
  • Invalid JSON in Request Parameters: If the JSON input for request parameters is malformed, the node throws an error. Validate JSON syntax before running.
  • Missing required fields: The request parameters must include userId, planId, requestType, and resource. Omitting any causes an error.
  • API errors: If the Nevermined API returns an error status, the node surfaces the message. Check network connectivity, API endpoint correctness, and that the plan ID exists.
  • Access denied due to insufficient credits or non-subscription: The output clearly indicates these cases; users should be advised to purchase or renew plans accordingly.

Links and References

Discussion