Credits
Introduction
Credits let you offer prepaid balances to customers. Instead of billing purely on usage after the fact, you can sell credit bundles upfront and deduct from them as your AI agents perform work.
A typical credits workflow:
- Create credit currencies to represent different unit types (e.g., “API Credits”, “Compute Hours”)
- Attach credit benefits to products so that orders grant credits to customers
- Query balances via the API to enforce limits or display remaining credits in your app
Prerequisites
- A Paid API key and the Paid SDK installed in the service that checks balances or sends signals.
- A credit currency configured in Configure > Credits via Create credit currency.
- A product or plan with a credit benefit, plus an active order or checkout-completed purchase that grants credits to the customer.
- Signals that match the product’s credit-backed pricing rule if you want Paid to deduct credits automatically.
Core Concepts
Credit Currencies
A credit currency defines a unit of value. Each organization can have multiple currencies for different billing dimensions.
Credit Balances
A balance represents how many credits a customer has for a given currency. Balances are grouped by:
- Currency: which credit currency the balance is for
- Recipient: whether credits belong to the
organization(shared across all users) or a specificseat
Each balance includes:
Credit precision
Credits are decimal, not whole numbers. Every credit amount you send (a manual grant, a spending limit, a credit cost, a benefit amount) is exact to at most 15 decimal places, so 0.5, 2.75, and 0.000000000000001 are all valid credit amounts. Paid stores credits at the same 15 decimal places, so a stored balance never loses a place.
Fifteen decimal places is a limit, not a rounding target. A value with a 16th decimal place is rejected with a 400; it is never rounded to fit. Sending 0.0000000000000005 fails rather than becoming 0.000000000000001 or 0, so no request can quietly deduct or grant a number you did not send. When Paid prorates a grant itself, the result is rounded down to 15 decimal places: 100 credits prorated over 10 days of a 30-day period is 33.333333333333333.
Numbers and exact decimal strings
A JSON number is a binary float: it holds about 15 significant digits, and most decimals only approximately. So the legacy API (/api/v2) gives each credit field two forms:
- The number field (
available,used,amount, and so on) carries at most six decimal places, cut toward zero, so it never overstates a balance:0.1234567891reads as0.123456. Number fields keep this six-place cut even for an amount with more places. A number is approximate, and sums of it drift, so use it for display, not for accounting. Two number fields are whole credits, cut toward zero:amounton a credit grant result andcreditson pending credit consumption, so0.5reads as0. - The
*Decimalstring field beside it (availableDecimal,usedDecimal,amountDecimal,creditsDecimal, and so on) is the exact value as a decimal string, at any magnitude a balance can reach. Read it whenever the exact value matters, and parse it with a decimal type, not a double.
Inputs work the same way. Where a request takes a credit amount as a number (amount, rolloverAmount, creditCost, creditUnits, and so on), it also takes a *Decimal string (amountDecimal, creditCostDecimal, and so on). Send the string to be exact past what a JSON number carries. If you send both, they must be equal, or the request fails with a 400. A credit amount sent as a JSON number must survive the conversion to a double unchanged; one that would not, such as 9007199254740993 (past ±2^53), is rejected with a 400 rather than rounded.
The API at api.paid.ai/v1 sends and returns every credit amount as a decimal string, so it has no number form to cut.
Credit values in pricing
Credit costs, credit units and benefit amounts on products, plans, pricing and orders are stored as JSON numbers, so each holds about 15 significant digits. A value that a JSON number cannot hold exactly is rejected with a 400, never rounded: 0.000123 and 1234567890.123456 fit, but 12345678901.123456 (17 significant digits) is refused even though it has six decimal places. Product, plan, pricing and order responses return these values as numbers only, with no *Decimal field. With 15 decimal places allowed, 0.000000123456789 fits, but 123.123456789012345 (18 significant digits) is refused.
Signal quantities
The quantity a signal carries is a whole number of your own units. Fractional quantities are not supported: put the fraction in the per-unit credit cost instead.
Querying Credit Balances
Use the API to check a customer’s current credit balances. This is useful for:
- Enforcing credit limits before performing work
- Displaying remaining balances in your app
- Building low-balance alerts
Node.js
Python
cURL
Response
The customer ID parameter accepts both display IDs (
cus_xxx) and UUIDs.
Listing Credit Currencies
Retrieve all credit currencies configured for your organization:
Node.js
Python
cURL
To include archived currencies, pass includeArchived=true:
Example: Enforcing Credit Limits
A common pattern is to check a customer’s credit balance before performing work:
Dynamic Credit Consumption
By default, each signal deducts the fixed credit cost defined in your product’s pricing rule. To consume a variable number of credits per signal, configure your pricing rule with a quantity mapping that reads from signal data, then pass the quantity value in each signal.
With a quantity mapping configured, the credit deduction becomes quantity x creditCost. If the credit cost is 1 and the signal sends quantity: 5, that signal deducts 5 credits. Without the mapping, every signal deducts the fixed credit cost regardless of what you send in data.
The creditCost may be fractional. A credit cost of 0.5 with quantity: 5 deducts 2.5 credits, so a balance of 10 becomes 7.5. quantity is a count of your own units and stays a whole number; creditCost is where sub-unit pricing lives.
This is useful when different actions consume different amounts of credit. For example, a cheap token-level call might cost 0.5 credits while a complex multi-step workflow costs 10.
See First signals for full examples in all SDKs and How credit balances work for the complete set of consumption strategies.
Setting Up Credits
To configure credits for your organization:
- Navigate to Settings in the Paid dashboard
- Create a credit currency with a name and key
- Add credit benefits to a product’s pricing configuration
- Create an order for a customer. Credits are granted when the order activates
Once credits are granted, you can query balances via the API as shown above.