AI API
The kittl.ai API provides methods for AI-related operations, such as requesting credit spending from the user.
Spending Credits
Use spendCredits to prompt the user with a confirmation dialog before spending AI credits. This is typically used when your extension performs AI operations (e.g. image generation) that consume credits.
const result = await kittl.ai.spendCredits({
amount: 5,
message: 'Generate an AI image',
onAccept: () => {
console.log('User accepted — starting generation...');
},
onDecline: () => {
console.log('User declined the credit spend.');
},
});
if (result.isOk) {
console.log('Credits spent:', result.result.success);
}
See AI API Reference for full parameter and return type details.