Pro: 1,000 credits a month for $20. An image costs 1 credit, an HD image 4, a PDF export 3.Credits give customers one balance that pays for everything in your product, and give you a single lever to price each action by what it costs you. A
credits feature spends from one shared credit pool. Each feature has a creditCost, how many credits one use spends, and plans grant monthlyCredits rather than uses. One balance then covers every action, so 1,000 credits buy 1,000 images, 250 HD images, or any mix, and you can price an expensive action higher without a new plan. When each action should have its own allowance instead, use metered allowances.
The catalog
type defaults to credits, so a feature with only a creditCost is a credits feature. A credits feature needs no plan item: every plan’s monthlyCredits pays for it. The one item a credits feature takes is unlimited: true, which makes it free on that plan (Studio’s standard images above).
creditCost belongs to the feature, so it is the same on every plan and for every customer. Model a per-plan price as its own feature: define generate_image_business at creditCost: 2 and send its featureId from your code for customers on that plan. Every plan’s credits pay for every credits feature, and an item makes one unlimited. Overrides set a customer’s overage terms.
What check and track return
check answers { "allowed": true, "availableCredits": 996, "creditCost": 4 }. The track answers what it spent:
Response
check answers allowed: false with reason: "insufficient_credits" and the customer’s plan, and track is refused with 409 insufficient_credits, with availableCredits and creditCost in the body. Nothing is charged. On a plan that makes the feature unlimited, check answers creditCost: 0 and unlimited: true, and the track spends nothing.
Several uses at once
Sendquantity to check and track when one request is several uses, such as a batch of 10 HD images. It costs quantity × creditCost: 40 credits here, decided all or nothing.
Variable costs
creditCost is the price of one unit, and quantity says how many units a use took. When the size depends on the work, price the feature by its unit and send the real count: a video render at creditCost: 2 a second tracks quantity: 160 for a 160-second video and spends 320 credits.
When you work out the price yourself, such as model tokens at cost or GPU time, give the feature creditCost: 1 and send the cost in credits as quantity. Prepaid dollar balance builds a whole balance this way.
To make sure the customer can cover the work before it starts, check with reserve: { quantity: estimate } and a request_id first: the check holds the estimate, and the track with the same request_id and the real quantity settles it and gives back the rest. Reservations covers reserve and settle in full.
Cheaper at volume
creditCostTiers makes an action cost less the more a customer uses it in a period: the first 1,000 images of the month cost 2 credits each, every one after that 1.
- Graduated by use. Each band’s
upTois its last use of the period, and every use is charged at its own band: a track of 3 uses from the 999th costs 2 + 2 + 1. - Counted per period. Uses are counted per customer over the allowance period (each month of an annual plan that resets monthly, the calendar month without a plan) and start again from 1 each period.
- Exact under load. Concurrent tracks are counted one after another, so a burst across a band costs exactly what the same uses one at a time would.
- Check and reserve agree.
checkanswers the cost at the bands the uses would reach. A reservation holds its uses at the next use’s band, and the track that settles it charges the bands its uses reach then, counting them toward the period.
Choosing costs
- Start from your own cost. If an HD image costs you four times a standard one, make it 4 credits. Set plan credits so the plan’s price covers a heavy month.
- Keep costs whole numbers.
creditCostis a whole number above 0. For cheap actions, make a credit worth less: 10 credits per message rather than 0.1. - Changing a cost applies from then on. Usage already tracked keeps the cost it was charged at, and a feature change doesn’t create a plan version.
Rules
creditCostgoes on credits features. It’s required there and refused on metered, held and boolean features.- Credit cost tiers go on credits features.
creditCostis the first band’s cost, eachupTois above the one before, and the last band’supToisnull. - Credits last one period. Unspent plan credits end with the period, and the next one starts with a fresh
monthlyCredits, unless the plan has rollover. Credit pack and top-up credits never expire, and grant code credits last as long as you set. Balances has the spend order. - All or nothing. A use is charged in full or refused; with overage, the part past the balance is billed later instead.
- Entities. To split a customer’s credits between users or workspaces, see Entities.
Related
- Credit packs: sell more credits as a one-time purchase.
- Top-ups and auto top-ups: any amount, or bought automatically when the balance runs low.
- Overage: bill credits past the allowance.
- Metered allowances: one balance per feature instead.