Overview
This node calculates credit usage based on one or more provided metrics. Each metric includes token usage, a credits conversion rate, and a description. The node multiplies the usage by the conversion rate for each metric to compute individual credit amounts, then sums these to produce a total credit value.
This node is useful in scenarios where you need to track or report credit consumption across multiple categories or metrics, such as monitoring API usage costs, billing calculations, or resource consumption summaries.
Example:
You provide metrics like "API calls" with usage 1000 and rate 0.01, and "Data processed" with usage 500 and rate 0.02. The node outputs the credits consumed per metric and the total credits used.
Properties
| Name | Meaning |
|---|---|
| Metrics | One or more groups of metrics, each containing: |
| - Usage: Number representing token usage | |
| - Credits Conversion Rate: Number representing how many credits each token costs | |
| - Description: Text describing the metric |
Output
The output is an array of JSON objects:
For each metric, an object with:
usage: The token usage number.rate: The credits conversion rate.description: The user-provided description.credits: The calculated credits for that metric (usage × rate).
A final object summarizing the total credits consumed across all metrics:
totalCredits: The sum of all individual credits.
No binary data is produced.
Dependencies
- No external services or API keys are required.
- The node operates purely on input data provided via its properties.
Troubleshooting
- Empty or missing metrics: If no metrics are provided, the node will output zero total credits but no detailed entries. Ensure at least one metric group is added.
- Non-numeric inputs: Providing non-numeric values for usage or rate may cause calculation errors or unexpected results. Validate inputs before execution.
- Large numbers: Very large usage or rate values might lead to floating-point precision issues; consider rounding if necessary.
Links and References
- No external links available for this custom node implementation.