import { SDK } from '@meetkai/mka1';
const mka1 = new SDK({
bearerAuth: `Bearer ${YOUR_API_KEY}`,
});
const headers = { 'X-On-Behalf-Of': 'user-123' };
// 1. Create a prompt with the initial template
const prompt = await mka1.llm.prompts.create({
name: 'support-reply',
template: 'Hi {{customer}}, thanks for contacting us about {{issue}}.',
}, { headers });
console.log('Created:', prompt.id, 'v1');
// 2. Ship v2 with a friendlier tone
const v2 = await mka1.llm.prompts.createVersion({
id: prompt.id,
requestBody: {
template: 'Hey {{customer}}! We got your message about {{issue}} and are on it.',
},
}, { headers });
console.log('Created v2:', v2.version);
// 3. Retrieve the prompt — active version is now v2
const current = await mka1.llm.prompts.get({
id: prompt.id,
variables: JSON.stringify({ customer: 'Alice', issue: 'billing' }),
}, { headers });
console.log('Active:', current.renderedTemplate);
// "Hey Alice! We got your message about billing and are on it."
// 4. Review version history
const history = await mka1.llm.prompts.listVersions({
id: prompt.id,
order: 'asc',
}, { headers });
for (const v of history.data) {
console.log(` v${v.version}: ${v.template}`);
}
// 5. Roll back to v1
const rolledBack = await mka1.llm.prompts.rollback({
id: prompt.id,
requestBody: {
version: 1,
},
}, { headers });
console.log('Rolled back to v' + rolledBack.activeVersion);
// active_version=1, latest_version=2
// 6. Clean up
await mka1.llm.prompts.delete({ id: prompt.id }, { headers });