chipp
v2.1.3
Published
Easily monetize your generative AI projects with token-based payments
Downloads
47
Readme
💳 Chipp.ai
⚡ Building the pay-per-generation monetization platform for AI applications ⚡
Be sure to sign up for an account and complete Stripe onboarding at https://app.chipp.ai
Installation
npm i chipp
Usage
import Chipp from "chipp";
const chipp = new Chipp({
apiKey: "your-api-key-from-Chipp-dashboard",
});
// userId needs to come from your database or auth session
let user = await chipp.getUser({ userId: "a-unique-identifier-for-user" });
// If the user is null, the user does not exist in the Chipp system and needs to be created
if (!user) {
user = await chipp.createUser({ userId: "a-unique-identifier-for-user" });
}
// Get the number of credits remaining for this user
const numChipps = await user.getCredits();
// Deduct credits from this user
await user.deductCredits(1);
// Generate a payment URL where this user can choose their preferred pakcages of credits and buy more.
// Pass in a redirect URL to bring your user back to your app after the user payment succeeds
const url = await user.getPackagesURL({
returnToUrl: "https://your-app.com/wherever-user-was",
});