> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slidevid.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Class Video Example

> Create an educational video with an AI avatar

## Overview

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

## Complete Code Example

<CodeGroup>
  ```javascript Node.js theme={null}
  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();
  ```

  ```python Python theme={null}
  import requests
  import os

  API_KEY = os.getenv('SLIDEVID_API_KEY')
  BASE_URL = 'https://api.slidevid.ai/v1'

  def create_class_video():
      headers = {'x-api-key': API_KEY}
      
      # 1. Get avatars
      avatars = requests.get(
          f'{BASE_URL}/avatar/list',
          params={'type': 'library'},
          headers=headers
      ).json()
      
      professional_avatar = next(
          (a for a in avatars['data']['avatars'] 
           if 'Professional' in a.get('situation', []) and not a['isPro']),
          avatars['data']['avatars'][0]
      )
      
      # 2. Get voices
      voices = requests.get(
          f'{BASE_URL}/voice/list',
          params={'language': 'English'},
          headers=headers
      ).json()
      
      clear_voice = voices['data']['voices'][0]
      
      # 3. Create project
      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.
      """.strip()
      
      project = requests.post(
          f'{BASE_URL}/project/create',
          headers={**headers, 'Content-Type': 'application/json'},
          json={
              'type': 'class',
              'name': 'Product Tutorial - Getting Started',
              'script': script,
              'avatarId': professional_avatar['id'],
              'voiceId': clear_voice['voiceId'],
              'aspectRatio': 'ratio_16_9',
              'captions': True,
              'webhook': 'https://yoursite.com/api/webhook'
          }
      ).json()
      
      print(f"Project created: {project['data']['projectId']}")
      return project

  if __name__ == '__main__':
      create_class_video()
  ```
</CodeGroup>

## Webhook Handler

```javascript Express.js theme={null}
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

<AccordionGroup>
  <Accordion title="Script Structure" icon="list">
    * Start with a clear introduction
    * Break content into logical sections
    * Use transition words ("First", "Next", "Finally")
    * End with a call to action or summary
  </Accordion>

  <Accordion title="Choose the Right Format" icon="rectangle-wide">
    * **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
  </Accordion>

  <Accordion title="Avatar Selection" icon="user">
    * Choose professional or business avatars
    * Match avatar's age/gender to your target audience
    * Use HD avatars for better quality
  </Accordion>

  <Accordion title="Voice Tips" icon="microphone">
    * Select clear, articulate voices
    * Match voice gender to avatar for authenticity
    * Use professional or narrator-style voices
  </Accordion>
</AccordionGroup>

## Use Cases

<CardGroup cols={2}>
  <Card title="Online Courses" icon="graduation-cap">
    Create lesson videos for online learning platforms
  </Card>

  <Card title="Product Tutorials" icon="box">
    Explain how to use your product or service
  </Card>

  <Card title="Training Videos" icon="users">
    Employee onboarding and training content
  </Card>

  <Card title="How-To Guides" icon="book">
    Step-by-step instructional content
  </Card>
</CardGroup>

## 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
