credit-based-billing

Implements prepaid credit billing with grants, ledger deductions, rollover, expiry, and overage via Dodo Payments.

6|1|Updated Apr 21, 2026
One-click install
npx skills add https://github.com/dodopayments/dodo-agent-plugin --skill credit-based-billing-dodopayments
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: credit-based-billing
Source: https://github.com/dodopayments/dodo-agent-plugin/tree/main/plugins/dodopayments/skills/credit-based-billing
Command: npx skills add https://github.com/dodopayments/dodo-agent-plugin --skill credit-based-billing-dodopayments

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires dodopayments.

What problem does it solve? Building prepaid or included-credit billing for AI tokens, API calls, or compute requires correctly wiring credit entitlements, balances, ledger entries, rollover, expiry, and overage rules—mistakes cause double-charging, lost audit trails, or race conditions in enforcement. ## Core Features & Use Cases - Credit Entitlement Setup: Create custom-unit or fiat credit entitlements with precision, expiry, rollover, and overage configuration using the Dodo Payments TypeScript SDK. - Balance & Ledger Operations: Read customer balances, grant or deduct credits with idempotency keys, and iterate the immutable ledger for audit trails. - Meter-to-Credit Automation: Link usage-based meters to credit pools with meter_units_per_credit conversion and FIFO deduction, plus handle credit webhooks like credit.balance_low. - Use Case: An AI SaaS includes 100,000 token credits per subscription cycle, deducts credits from metered model usage, notifies customers at low balance, and sells one-time top-up packs through checkout sessions. ## Quick Start Ask your agent to create a Dodo Payments credit entitlement for AI tokens with rollover and overage, then wire it to a subscription product and a usage meter.

Frequently Asked Questions about credit-based-billing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a credit entitlement in Dodo Payments?

Call client.creditEntitlements.create with name, unit, precision (0-10, immutable), rollover settings, and overage options. When overage is enabled, price_per_unit is required, and a price requires a currency.

How do I deduct credits from a customer balance?

Use client.creditEntitlements.balances.createLedgerEntry with the customer ID first, entry_type 'debit', a decimal-string amount, and a stable idempotency key. Debits consume oldest grants first and return 400 on insufficient balance.

What is the difference between creditEntitlements and entitlements in the Dodo SDK?

client.creditEntitlements manages credit definitions, balances, and ledgers, while client.entitlements handles feature, file, and license fulfillment. Credit balances do not live under client.entitlements.grants.

Can I use the credit balance for strict per-request authorization?

No. Meter-to-credit deduction is asynchronous (about one minute), so balance reads are not a reservation. Use atomic idempotent debits for fixed costs or local reservations with webhook reconciliation for variable costs.

How does credit rollover and expiry work?

Rollover carries a configurable percentage (0-100) of unused credits forward, requiring both rollover_timeframe_count and rollover_timeframe_interval together. Rollover applies before expiry; only the remainder expires after expires_after_days.

Why did my usage event not reduce the credit balance immediately?

A background worker processes usage events approximately every minute before converting meter units into credit deductions. An accepted ingestion response does not mean the balance reflects the deduction yet.