Twilio uses credits. OpenAI uses tokens. AWS, Azure, and GCP all have their own credit systems. Even AI coding assistants have moved toward compute-based pricing models.
Credit-based pricing is taking over the API world. But while the concept seems simple—“assign points to operations, charge for points”—the math behind setting credit values is surprisingly complex.
Get it right, and you have a pricing model that scales elegantly across use cases. Get it wrong, and you create arbitrage opportunities that sophisticated users will exploit mercilessly.
Let’s dive into the hidden math.
Why Credits Exist
The fundamental problem with per-request pricing: not all requests are equal.
Request A: GET /user/123 → Returns 1KB, takes 5ms
Request B: GET /users?limit=10000 → Returns 10MB, takes 2000ms
Request C: POST /ml/train → Starts a 4-hour jobCharging the same price for these makes no sense. Request C costs you 100,000x more than Request A to serve.
Credits solve this by abstracting away the monetary value and introducing a proxy unit that can be weighted per operation:
Request A: 1 credit
Request B: 100 credits
Request C: 50,000 credits
Price: $1 per 1,000 creditsNow pricing scales appropriately with actual resource consumption.
The Credit Valuation Framework
Setting credit values requires balancing three factors:
1. Infrastructure Cost
What does each operation actually cost you?
interface OperationCost {
compute: number; // CPU/GPU time
memory: number; // RAM allocated
storage: number; // Disk read/write
bandwidth: number; // Data transfer
thirdParty: number; // External API costs
}
function calculateBaseCost(op: OperationCost): number {
return (
op.compute * COMPUTE_RATE +
op.memory * MEMORY_RATE +
op.storage * STORAGE_RATE +
op.bandwidth * BANDWIDTH_RATE +
op.thirdParty
);
}For most APIs, compute dominates. But for data-heavy APIs, bandwidth or storage might be the primary cost driver.
2. Value Delivered
What is the operation worth to the customer?
This is harder to quantify, but consider:
- Does this operation save the customer time?
- Does it enable revenue they couldn’t capture otherwise?
- What’s the alternative cost (building it themselves)?
A fraud detection API call that prevents a $1,000 chargeback is worth more than a simple data lookup, even if they cost the same to serve.
3. Competitive Positioning
What do alternatives charge for equivalent operations?
If competitors charge 10 credits for a similar operation and you charge 100, you need a very good reason—or you’ll lose price-sensitive customers.
The Math: Building a Credit Table
Let’s walk through building a credit table for a hypothetical image processing API.
Step 1: Measure Actual Costs
Profile your operations:
| Operation | Avg CPU (ms) | Avg Memory (MB) | Avg Bandwidth (KB) | Total Cost |
|---|---|---|---|---|
| Image upload | 50 | 100 | 500 | $0.0002 |
| Basic resize | 200 | 256 | 200 | $0.0008 |
| AI analysis | 2000 | 1024 | 50 | $0.0150 |
| Background removal | 5000 | 2048 | 300 | $0.0400 |
| Video processing | 60000 | 4096 | 5000 | $0.5000 |
Step 2: Normalize to a Base Unit
Pick your cheapest common operation as the base unit (1 credit):
Base operation: Image upload = 1 credit = $0.0002 costNow express all operations as multiples:
| Operation | Cost Ratio | Raw Credits |
|---|---|---|
| Image upload | 1x | 1 |
| Basic resize | 4x | 4 |
| AI analysis | 75x | 75 |
| Background removal | 200x | 200 |
| Video processing | 2500x | 2500 |
Step 3: Apply Value Multipliers
Some operations deliver disproportionate value. Adjust accordingly:
AI analysis: 75 base × 1.5 value multiplier = 112.5 → round to 100
Background removal: 200 base × 1.2 value multiplier = 240 → round to 250Value multipliers come from understanding customer willingness to pay. If customers happily pay premium prices for AI features, your multiplier can be higher.
Step 4: Round to Human-Friendly Numbers
Nobody wants to see “113 credits.” Round to memorable numbers:
| Operation | Final Credits |
|---|---|
| Image upload | 1 |
| Basic resize | 5 |
| AI analysis | 100 |
| Background removal | 250 |
| Video processing | 2500 |
Step 5: Set the Credit Price
Work backward from your target margin:
Target margin: 70%
Average blended cost per credit: $0.0003
Price per credit: $0.0003 / 0.3 = $0.001
Rounded: $1 per 1,000 credits (or 1,000 credits = $1)Pro tip:
Round credit prices to easy numbers customers can calculate in their heads. “$1 per 1,000” is better than “$0.87 per 1,000” because customers can instantly estimate costs.
The Arbitrage Problem
Here’s where credit systems get tricky: sophisticated users will find the best deals.
If your credit values don’t accurately reflect costs, users will cluster on the underpriced operations:
Operation A: 10 credits, costs you $0.01 (margin: $0.009)
Operation B: 10 credits, costs you $0.05 (margin: -$0.04)Savvy users will use Operation B heavily, and you’ll lose money on every request.
Detection
Monitor credit consumption vs. actual cost:
// Alert when credit efficiency is too high
const metrics = await db.query(`
SELECT
operation,
SUM(credits_consumed) as total_credits,
SUM(actual_cost) as total_cost,
SUM(credits_consumed) * CREDIT_PRICE as revenue,
(SUM(credits_consumed) * CREDIT_PRICE - SUM(actual_cost)) /
(SUM(credits_consumed) * CREDIT_PRICE) as margin
FROM operation_logs
WHERE timestamp > NOW() - INTERVAL '7 days'
GROUP BY operation
HAVING margin < 0.5 -- Flag operations with <50% margin
`);Correction
When you find underpriced operations:
- Gradual increase: Raise credit costs slowly (10-20% per month)
- Communicate clearly: Tell customers why costs are changing
- Grandfather existing: Consider maintaining old prices for existing heavy users temporarily
Dynamic Credit Pricing
Advanced credit systems adjust pricing based on conditions:
Time-Based Pricing
function getCredits(operation: string, timestamp: Date): number {
const baseCredits = CREDIT_TABLE[operation];
// Off-peak discount
const hour = timestamp.getUTCHours();
if (hour >= 2 && hour <= 6) {
return Math.floor(baseCredits * 0.7); // 30% off overnight
}
return baseCredits;
}This smooths demand by incentivizing off-peak usage.
Load-Based Pricing
function getCredits(operation: string): number {
const baseCredits = CREDIT_TABLE[operation];
const currentLoad = getSystemLoad();
if (currentLoad > 0.9) {
return Math.floor(baseCredits * 1.5); // 50% premium at high load
}
return baseCredits;
}This protects infrastructure during spikes (but requires clear communication to users).
Commitment Discounts
function getCredits(operation: string, customer: Customer): number {
const baseCredits = CREDIT_TABLE[operation];
// Volume discount tiers
const monthlyCommitment = customer.plan.creditCommitment;
if (monthlyCommitment >= 1000000) return baseCredits * 0.6;
if (monthlyCommitment >= 100000) return baseCredits * 0.8;
return baseCredits;
}Credit Bundles and Plans
Most credit systems include bundled credits in subscription plans:
Free: 1,000 credits/month included
Starter: 50,000 credits/month included ($29/month)
Pro: 250,000 credits/month included ($99/month)The Bundle Math
How many credits should each tier include?
Method 1: Cost Multiple
Set included credits at a multiple of the plan price:
$29 plan → $29 / $0.001 per credit = 29,000 credits
Add 75% buffer → 50,000 creditsMethod 2: Use Case Anchor
Define typical use cases and set credits to cover them:
Starter user: ~100 operations/day × 30 days = 3,000 operations
Average 15 credits/operation = 45,000 credits
Round up → 50,000 creditsMethod 3: Competitive Parity
Match competitor offerings:
Competitor A: 40,000 credits at $25
Competitor B: 60,000 credits at $35
Your positioning: 50,000 credits at $29Common mistake:
The most common mistake: including too few credits in plans, causing customers to hit limits immediately. This creates billing surprise and churn. Better to include generous credits and capture expansion revenue from power users.
Communicating Credits to Users
Credits add cognitive overhead. Clear communication reduces confusion.
In Documentation
## Understanding Credits
Every API operation consumes credits from your account:
| Operation | Credits |
| ------------- | ------- |
| Basic request | 1 |
| With caching | 0.5 |
| ML inference | 100 |
Your plan includes 50,000 credits/month. Additional credits are $1 per 1,000.
### Example
Processing 100 images with ML analysis:
- 100 images × 100 credits = 10,000 credits
- Cost if over plan: $10In the Dashboard
┌─────────────────────────────────────────────────────────┐
│ Credit Usage This Month │
│ │
│ Used: 32,450 / 50,000 credits (64.9%) │
│ ████████████████████████░░░░░░░░░░░░░░ │
│ │
│ Breakdown: │
│ • Basic requests: 12,450 credits (38%) │
│ • ML inference: 15,000 credits (46%) │
│ • Data export: 5,000 credits (15%) │
│ │
│ Projected end-of-month: 48,600 credits (within plan) │
└─────────────────────────────────────────────────────────┘In API Responses
{
"data": { ... },
"meta": {
"credits_consumed": 100,
"credits_remaining": 17550,
"credits_reset_at": "2026-03-01T00:00:00Z"
}
}Advanced: Machine Learning for Credit Optimization
Leading API companies use ML to optimize credit values:
# Simplified credit optimization model
def optimize_credits(operations_data, target_margin=0.7):
"""
Find credit values that:
1. Maintain target margin
2. Minimize user confusion (simple numbers)
3. Prevent arbitrage
"""
# Current costs and usage
costs = operations_data['actual_cost']
volumes = operations_data['volume']
current_credits = operations_data['credits']
# Optimize credit values
optimal_credits = []
for op in operations:
base = costs[op] / target_cost_per_credit
# Adjust for price elasticity
elasticity = estimate_elasticity(op, volumes)
adjusted = base * (1 + (1 - elasticity) * margin_buffer)
# Round to human-friendly number
rounded = round_friendly(adjusted)
optimal_credits.append(rounded)
return optimal_creditsThis requires:
- Historical cost data per operation
- Usage patterns by customer segment
- Price elasticity estimates (how volume changes with price)
Usage-Based Metering
Implement credit-based pricing with Zuplo's metering policies—track consumption per operation and sync to your billing provider.
When Credits Go Wrong
Case Study: The Startup That Lost Money
A startup set credit values based purely on operation type, ignoring actual infrastructure costs. Their “AI enhancement” operation cost them $0.08 to serve but was priced at 10 credits ($0.01).
Power users discovered this and hammered the endpoint. The startup’s monthly AWS bill quintupled while revenue stayed flat.
Lesson: Always start with actual cost measurement, not arbitrary assignments.
Case Study: The Complexity Spiral
Another company had 47 different credit tiers for variations of similar operations. Users couldn’t understand what anything cost. Support tickets about billing were 40% of their volume.
They simplified to 5 tiers. Support tickets dropped 60%, and conversion improved because users could actually understand pricing.
Lesson: Simplicity has value. Round aggressively and accept some margin variance.
The Simplicity-Accuracy Tradeoff
Here’s the fundamental tension in credit design:
Perfect accuracy: 1 credit = $0.00001 actual cost
- Requires complex fractional credits
- Hard for users to understand
- Difficult to communicate
Perfect simplicity: All operations = 1 credit
- Easy to understand
- Terrible margin on expensive operations
- Creates arbitrage opportunitiesThe art is finding the middle ground: enough granularity to protect margins, enough simplicity for users to understand.
Most successful credit systems have 5-15 distinct credit levels, with values that are easy multiples of each other (1, 5, 10, 50, 100, 500, 1000).
Conclusion
Credit-based pricing is powerful because it decouples the monetary unit from the consumption unit. This gives you flexibility to:
- Adjust pricing without changing credit values
- Offer bundles and commitments
- Handle wildly different operation costs gracefully
- Communicate consumption in user-friendly terms
But it requires careful math to avoid:
- Arbitrage from underpriced operations
- Confusion from overly complex credit tables
- Margin erosion from inaccurate cost modeling
The companies that win at credit pricing invest in:
- Accurate cost measurement per operation
- Regular review and adjustment of credit values
- Clear communication of what credits mean
- Dashboards that make consumption visible
Do the math. Monitor the margins. Keep it simple enough to explain.
Credits are powerful. Use them wisely.
