Skip to main content

Overview

This example shows how to create an educational “Class” video - perfect for tutorials, online courses, and training content.

Complete Code Example

const API_KEY = process.env.SLIDEVID_API_KEY;
const BASE_URL = 'https://api.slidevid.ai/v1';

async function createClassVideo() {
  // 1. Get a professional-looking avatar
  const avatarsRes = await fetch(`${BASE_URL}/avatar/list?type=library`, {
    headers: { 'x-api-key': API_KEY }
  });
  const avatars = await avatarsRes.json();
  const professionalAvatar = avatars.data.avatars.find(
    a => a.situation.includes('Professional') && !a.isPro
  );
  
  // 2. Get a clear, articulate voice
  const voicesRes = await fetch(`${BASE_URL}/voice/list?language=English`, {
    headers: { 'x-api-key': API_KEY }
  });
  const voices = await voicesRes.json();
  const clearVoice = voices.data.voices[0];
  
  // 3. Create the project
  const project = await fetch(`${BASE_URL}/project/create`, {
    method: 'POST',
    headers: {
      'x-api-key': API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      type: 'class',
      name: 'Product Tutorial - Getting Started',
      script: `
        Hello and welcome to this tutorial!
        
        Today, I'm going to walk you through the key features of our product.
        
        First, let's talk about setup. The setup process is incredibly simple.
        Just follow these three steps, and you'll be up and running in minutes.
        
        Next, I'll show you the main dashboard. This is where you'll spend most of your time.
        Notice how everything is organized intuitively.
        
        Finally, let's look at some advanced features that will help you work more efficiently.
        
        Thanks for watching! If you have any questions, don't hesitate to reach out.
      `.trim(),
      avatarId: professionalAvatar.id,
      voiceId: clearVoice.voiceId,
      aspectRatio: 'ratio_16_9', // Horizontal for tutorials
      captions: true,
      webhook: 'https://yoursite.com/api/webhook'
    })
  });
  
  const result = await project.json();
  console.log('Project created:', result.data.projectId);
  return result;
}

createClassVideo();

Webhook Handler

Express.js
app.post('/api/webhook', express.json(), (req, res) => {
  const { event, projectId, video } = req.body;
  
  if (event === 'project.completed') {
    // Save video to database
    await db.videos.create({
      projectId,
      url: video.url,
      thumbnail: video.thumbnail,
      duration: video.duration
    });
    
    // Notify user
    await sendEmail(user, {
      subject: 'Your tutorial video is ready!',
      videoUrl: video.url
    });
    
    console.log(`✅ Video ready: ${video.url}`);
  }
  
  res.status(200).send('OK');
});

Tips for Class Videos

  • Start with a clear introduction
  • Break content into logical sections
  • Use transition words (“First”, “Next”, “Finally”)
  • End with a call to action or summary
  • 16:9 (Horizontal): Best for tutorials, can show more content
  • 9:16 (Vertical): Good for mobile-first learning
  • 1:1 (Square): Works well for social media tutorials
  • Choose professional or business avatars
  • Match avatar’s age/gender to your target audience
  • Use HD avatars for better quality
  • Select clear, articulate voices
  • Match voice gender to avatar for authenticity
  • Use professional or narrator-style voices

Use Cases

Online Courses

Create lesson videos for online learning platforms

Product Tutorials

Explain how to use your product or service

Training Videos

Employee onboarding and training content

How-To Guides

Step-by-step instructional content

Expected Output

  • Duration: 60-90 seconds (depending on script length)
  • Format: MP4, H.264 encoding
  • Resolution: 1280x720 (16:9) or 1080x1920 (9:16)
  • Audio: Clear voice with optional background music
  • Captions: Auto-generated, synced subtitles