従量課金と使用量ベースの価格設定
Stripeに使用量を報告し、従量課金の価格を設定し、AI SaaS向けの使用量ベースの料金段階を構築して、顧客が実際に使った分だけ課金します。
「従量課金と使用量ベースの価格設定」はCoddyKit上の無料AI Powered SaaS: Stripe + Auth + Billing + Deployレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはAI Powered SaaS: Stripe + Auth + Billing + Deploy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 AI Powered SaaS: Stripe + Auth + Billing + Deployコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Why Usage-Based Pricing?
Flat subscriptions do not fit products where cost scales with consumption — like AI tokens or API calls. Metered billing charges customers for actual usage, aligning revenue with cost.
Licensed vs Metered Prices
Stripe prices come in two usage types:
- Licensed: a fixed quantity (e.g. 5 seats)
- Metered: quantity reported over time and billed at period end
Creating a Metered Price
Define a recurring price with usage_type: metered. Stripe sums reported usage for each billing cycle.
await stripe.prices.create({
product: productId,
currency: 'usd',
recurring: { interval: 'month', usage_type: 'metered' },
unit_amount: 2
});Subscribing Without a Quantity
For metered items you do not set a quantity at subscription time — Stripe learns it from usage reports.
await stripe.subscriptions.create({
customer: customerId,
items: [{ price: meteredPriceId }]
});Reporting Usage
As customers consume the product, report usage against the subscription item. Use action: increment to add to the running total.
await stripe.subscriptionItems.createUsageRecord(itemId, {
quantity: 1000,
timestamp: Math.floor(Date.now() / 1000),
action: 'increment'
});When to Report
Report at the moment usage happens — for example, after each AI completion count its tokens. Buffer high-frequency events and flush periodically to avoid hitting API limits.
async function onAiCall(itemId, tokens) {
await reportUsage(itemId, tokens);
}Idempotent Reporting
Avoid double-counting on retries by sending an idempotency key. Stripe ignores duplicate requests with the same key.
await stripe.subscriptionItems.createUsageRecord(
itemId,
{ quantity: 1000, action: 'increment' },
{ idempotencyKey: 'usage-' + eventId }
);Tiered Pricing
You can combine metering with tiers: the first 10,000 units cost more per unit, additional units less. Stripe computes the blended total automatically.
recurring: { usage_type: 'metered' },
billing_scheme: 'tiered',
tiers_mode: 'graduated'Showing Usage to Customers
Customers want transparency. Fetch the current period's usage and display it in their dashboard so there are no billing surprises.
const summaries = await stripe.subscriptionItems.listUsageRecordSummaries(itemId);Combining Plans
Many SaaS use a hybrid model: a fixed monthly base fee (licensed) plus metered overage. Add both prices as separate items on one subscription.
items: [
{ price: baseFeePriceId },
{ price: meteredPriceId }
]Best Practices
Run metered billing reliably:
- Use metered prices for consumption-based products
- Report usage with increment and idempotency keys
- Consider tiered pricing for volume
- Show usage to customers for transparency
Quick Check
Test your metered billing knowledge.
Recap
You added usage-based billing:
- Create
meteredprices and subscribe without a quantity - Report usage with
incrementand idempotency keys - Use tiered pricing and hybrid base-plus-overage models
- Surface usage to customers for transparency
Your AI SaaS now charges fairly for what users consume.
AI チューターと学ぶ AI Powered SaaS: Stripe + Auth + Billing + Deploy — 無料
ブラウザでリアルコードを書いて実行し、24/7 の AI チューターから瞬時にサポートを受け、ウェブまたはアプリで続きから学習できます。
- コース
- 12
- レッスン
- 48
よくある質問
「従量課金と使用量ベースの価格設定」レッスンは無料ですか?
はい。「従量課金と使用量ベースの価格設定」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、AI Powered SaaS: Stripe + Auth + Billing + Deployコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 AI Powered SaaS: Stripe + Auth + Billing + Deployコースには全4レッスンが含まれています。
「従量課金と使用量ベースの価格設定」で何を学びますか?
Stripeに使用量を報告し、従量課金の価格を設定し、AI SaaS向けの使用量ベースの料金段階を構築して、顧客が実際に使った分だけ課金します。 ブラウザで直接実行するハンズオンコードでAI Powered SaaS: Stripe + Auth + Billing + Deployを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
AI Powered SaaS: Stripe + Auth + Billing + Deployを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのAI Powered SaaS: Stripe + Auth + Billing + Deployは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「従量課金と使用量ベースの価格設定」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このAI Powered SaaS: Stripe + Auth + Billing + Deployレッスンでコードを書いて実行できますか?
はい。すべてのAI Powered SaaS: Stripe + Auth + Billing + Deployレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- サブスクリプション管理
- Stripe Webhooksの処理
- カスタマーポータルと請求履歴
- 従量課金と使用量ベースの価格設定