Hybrid Model
Subscriptions and Topups
Many AI platforms start with subscriptions and later add topups to handle usage spikes.
Usage spikes can dramatically increase infrastructure spend, making subscription-only models insufficient for real-world profitability. That’s why a hybrid billing model, combining stable subscriptions with usage-based topups, is becoming prevalent in the AI economy.
Credyt supports this hybrid approach even if your subscriptions are already managed externally.
- Subscriptions remain outside Credyt - you keep using your existing PSP and billing system.
- Credyt is informed when a subscription payment succeeds via the Adjustments API, which credits the customer’s wallet.
- Topups for additional usage can be handled in two ways:
- Through Credyt - using the Billing Portal or topup API (requires connecting a Stripe account).
- Outside Credyt - process the payment with your PSP, then notify Credyt using the Adjustments API.
This lets you add real-time usage billing without rebuilding your subscription flow or changing payment providers.
Implementation guide
Reflect Subscription Payments in Credyt
When a subscription renews in your PSP, call the Adjustments API to increase the wallet balance:
- REST API
- TypeScript SDK
- Python SDK
{
"transaction_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"account_name": "default",
"asset": "USD",
"amount": 25,
"description": "Monthly Subscription",
"reason": "external_topup",
"expires_at": "2024-07-29T15:51:28.071Z",
"metadata": {
"psp": "stripe",
"payment_intent": "pi_3RjbbNJNSIruR1rb0GwMGpH0"
}
}
Response
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_at": "2024-07-29T15:51:28.071Z"
}
await client.customerWalletOps.createAdjustment("cust_473cr1y0ghbyc3m1yfbwvn3nxx", {
transactionId: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
accountName: "default",
asset: "USD",
amount: 25,
description: "Monthly Subscription",
reason: "external_topup",
expiresAt: "2024-07-29T15:51:28.071Z",
metadata: {
psp: "stripe",
paymentIntent: "pi_3RjbbNJNSIruR1rb0GwMGpH0",
},
});
SDK response object
const response = {
id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
createdAt: "2024-07-29T15:51:28.071Z",
};
response = client.customer_wallet_ops.create_adjustment(
customer_id="cust_473cr1y0ghbyc3m1yfbwvn3nxx",
body={
"transaction_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"account_name": "default",
"asset": "USD",
"amount": 25,
"description": "Monthly Subscription",
"reason": "external_topup",
"expires_at": "2024-07-29T15:51:28.071Z",
"metadata": {
"psp": "stripe",
"payment_intent": "pi_3RjbbNJNSIruR1rb0GwMGpH0",
},
},
)
SDK response object
response = {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_at": "2024-07-29T15:51:28.071Z",
}
Wallet account balance increases by the subscription value.
Handle Topups for Additional Usage
Option A: Use Credyt’s Payment Rails (Stripe Checkout)
- Customer tops up via Billing Portal (self-service) or Topup API (your UI). Read about Topups.
- Credyt processes the payment through Stripe.
- Requires either creating a new Stripe account or connecting your existing one via Credyt.
Option B: Keep Topups External
- Process the payment with your PSP.
- Call the Adjustments API to reflect the new balance in Credyt.
- REST API
- TypeScript SDK
- Python SDK
{
"transaction_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"account_name": "default",
"asset": "USD",
"amount": 25,
"description": "Ad-hoc usage",
"reason": "external_topup",
"expires_at": "2024-07-29T15:51:28.071Z",
"metadata": {
"psp": "stripe",
"payment_intent": "pi_3RjbbNJNSIruR1rb0GwMGpH0"
}
}
Response
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_at": "2024-07-29T15:51:28.071Z"
}
await client.customerWalletOps.createAdjustment("cust_473cr1y0ghbyc3m1yfbwvn3nxx", {
transactionId: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
accountName: "default",
asset: "USD",
amount: 25,
description: "Ad-hoc usage",
reason: "external_topup",
expiresAt: "2024-07-29T15:51:28.071Z",
metadata: {
psp: "stripe",
paymentIntent: "pi_3RjbbNJNSIruR1rb0GwMGpH0",
},
});
SDK response object
const response = {
id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
createdAt: "2024-07-29T15:51:28.071Z",
};
response = client.customer_wallet_ops.create_adjustment(
customer_id="cust_473cr1y0ghbyc3m1yfbwvn3nxx",
body={
"transaction_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"account_name": "default",
"asset": "USD",
"amount": 25,
"description": "Ad-hoc usage",
"reason": "external_topup",
"expires_at": "2024-07-29T15:51:28.071Z",
"metadata": {
"psp": "stripe",
"payment_intent": "pi_3RjbbNJNSIruR1rb0GwMGpH0",
},
},
)
SDK response object
response = {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_at": "2024-07-29T15:51:28.071Z",
}
Send Usage Events
Once the wallet is funded (from subscription or topups), usage events will deduct balances in real time:
- REST API
- TypeScript SDK
- Python SDK
{
"customer_id": "cust_473cr1y0ghbyc3m1yfbwvn3nxx",
"events": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"event_type": "message_completed",
"occurred_at": "2024-07-29T15:51:28.071Z",
"subject": "chat_5f53d23a4958",
"description": "Chat message completed",
"data": {
"model": "gpt-4-1",
"input_tokens": 2353,
"output_tokens": 34697
}
}
]
}
await client.events.sendUsage({
customerId: "cust_473cr1y0ghbyc3m1yfbwvn3nxx",
events: [
{
id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
eventType: "message_completed",
occurredAt: "2024-07-29T15:51:28.071Z",
subject: "chat_5f53d23a4958",
description: "Chat message completed",
data: {
model: "gpt-4-1",
inputTokens: 2353,
outputTokens: 34697,
},
},
],
});
response = client.events.send_usage(
body={
"customer_id": "cust_473cr1y0ghbyc3m1yfbwvn3nxx",
"events": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"event_type": "message_completed",
"occurred_at": "2024-07-29T15:51:28.071Z",
"subject": "chat_5f53d23a4958",
"description": "Chat message completed",
"data": {
"model": "gpt-4-1",
"input_tokens": 2353,
"output_tokens": 34697,
},
},
],
},
)