const API_URL = 'https://sdk.senso.ai/api/v1';
const API_KEY = 'YOUR_API_KEY';
async function generateContent() {
try {
// Generate a product overview
const overviewResponse = await fetch(`${API_URL}/generate`, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
content_type: 'product features and benefits',
instructions: 'Create a comprehensive product overview suitable for new customers',
max_results: 10, // Use up to 10 source chunks
save: false // Don't save this generation
})
});
const overview = await overviewResponse.json();
console.log('Generated Content:');
console.log(overview.generated_text);
console.log('\nBased on', overview.sources.length, 'sources');
// Generate and save FAQ content
const faqResponse = await fetch(`${API_URL}/generate`, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
content_type: 'common customer questions',
instructions: 'Generate a FAQ section with at least 10 questions and detailed answers',
save: true // Save this as new content
})
});
const faq = await faqResponse.json();
console.log('\nFAQ Generated and Saved!');
console.log('Content ID:', faq.content_id);
console.log('Preview:', faq.generated_text.substring(0, 200) + '...');
} catch (error) {
console.error('Error generating content:', error);
}
}
generateContent();