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

# Script to Video Example

> Create videos from scripts with AI-generated or custom media

## Overview

Transform written scripts into engaging videos with voice narration and auto-generated or custom visuals. Script to Video is perfect for educational content, social media videos, and marketing materials.

## With AI-Generated Images

```javascript theme={null}
const response = await fetch('https://api.slidevid.ai/v1/project/create/script-to-video', {
  method: 'POST',
  headers: {
    'x-api-key': process.env.SLIDEVID_API_KEY,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    script: 'Artificial intelligence is transforming the way we work and live. From smart assistants to self-driving cars, AI is everywhere.',
    voiceId: 'confident_voice_id',
    presetSettings: {
      mediaType: "ai-images",
      preset: "realistic",
      quality: "pro"
    },
    musicId: "2",
    aspectRatio: 'ratio_9_16',
    caption: {
      preset: 'beast',
      alignment: 'bottom',
      disabled: false
    },
    language: 'en',
    addStickers: true,
    audio: {
      speed: 1,
      stability: 0.5,
      similarityBoost: 0.75,
      style: 0,
      useSpeakerBoost: true
    },
    webhook: 'https://yoursite.com/webhook',
    metadata: {
      contentType: 'educational',
      topic: 'artificial-intelligence'
    }
  })
});

const data = await response.json();
console.log('Video ID:', data.data.videoId);
console.log('Project ID:', data.data.projectId);
```

## With AI-Generated Videos

```javascript theme={null}
const createAIImageVideo = async () => {
  const response = await fetch('https://api.slidevid.ai/v1/project/create/script-to-video', {
    method: 'POST',
    headers: {
      'x-api-key': process.env.SLIDEVID_API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'AI Technology Explainer',
      script: 'Artificial intelligence is transforming the way we work and live. From smart assistants to self-driving cars, AI is everywhere. Let\'s explore how this technology is shaping our future.',
      voiceId: 'confident_voice_id',
      presetSettings: {
        mediaType: 'ai-videos',
        preset: 'anime',
        quality: 'base'
      },
      musicId: 'music_ambient_01',
      aspectRatio: 'ratio_9_16',
      caption: {
        preset: 'modern',
        alignment: 'bottom',
        disabled: false
      },
      language: 'en',
      addStickers: true,
      audio: {
        speed: 1,
        stability: 0.5,
        similarityBoost: 0.75,
        style: 0,
        useSpeakerBoost: true
      },
      webhook: 'https://yoursite.com/webhook',
      metadata: {
        contentType: 'educational',
        topic: 'artificial-intelligence'
      }
    })
  });

  return await response.json();
};
```

## With Custom Media

```javascript theme={null}
const createCustomMediaVideo = async () => {
  const response = await fetch('https://api.slidevid.ai/v1/project/create/script-to-video', {
    method: 'POST',
    headers: {
      'x-api-key': process.env.SLIDEVID_API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Product Showcase',
      script: 'Introducing our revolutionary new product. It\'s designed to make your life easier and more productive. Watch as we demonstrate its incredible features.',
      voiceId: 'enthusiastic_voice_id',
      media: [
        {
          id: 'intro_shot',
          type: 'video',
          title: 'Product Intro',
          url: 'https://your-cdn.com/intro.mp4',
          durationInFrames: 150,
          isAIGenerated: true
        },
        {
          id: 'demo_shot',
          type: 'video',
          title: 'Product Demo',
          url: 'https://your-cdn.com/demo.mp4',
          durationInFrames: 200,
          isAIGenerated: false
        },
        {
          id: 'feature_image',
          type: 'image',
          title: 'Feature Highlight',
          url: 'https://your-cdn.com/feature.jpg',
          durationInFrames: 75,
          isAIGenerated: false
        }
      ],
      musicId: 'music_upbeat_01',
      aspectRatio: 'ratio_9_16',
      caption: {
        preset: 'wrap1',
        alignment: 'bottom',
        disabled: false
      },
      presetSettings: {
        mediaType: 'media'
      },
      language: 'en',
      addStickers: true,
      audio: {
        speed: 1,
        stability: 0.5,
        similarityBoost: 0.75,
        style: 0,
        useSpeakerBoost: true
      },
      webhook: 'https://yoursite.com/webhook',
      metadata: {
        contentType: 'educational',
        topic: 'artificial-intelligence'
      }
    })
  });

  return await response.json();
};
```

## With Gameplay

```javascript theme={null}
const createGamingVideo = async () => {
  const response = await fetch('https://api.slidevid.ai/v1/project/create/script-to-video', {
    method: 'POST',
    headers: {
      'x-api-key': process.env.SLIDEVID_API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Gaming Tips Video',
      script: 'Want to level up your gaming skills? Here are three pro tips that will help you dominate your opponents. Tip one: always check your surroundings...',
      voiceId: 'energetic_voice_id',
      presetSettings: {
        mediaType: 'gameplay',
      },
      gameplaySettings: {
        selectedGame: 'minecraft',
        selectedVideo: 'minecraft-1'
      },
      musicId: 'music_upbeat_01',
      aspectRatio: 'ratio_9_16',
      caption: {
        preset: 'beast',
        alignment: 'top',
        disabled: false
      },
      language: 'en',
      addStickers: true,
      audio: {
        speed: 1,
        stability: 0.5,
        similarityBoost: 0.75,
        style: 0,
        useSpeakerBoost: true
      },
      webhook: 'https://yoursite.com/webhook',
      metadata: {
        contentType: 'educational',
        topic: 'artificial-intelligence'
      }
    })
  });

  return await response.json();
};
```

## Tips for Script to Video

<Tip>**Structure your script**: Break content into clear sections with natural pauses for better pacing</Tip>
<Tip>**Match media to content**: Use ai-images for explainers, gameplay for gaming, custom media for brands</Tip>
<Tip>**Keep it concise**: 30-90 seconds works best for social media content</Tip>
<Tip>**Choose the right voice**: Match voice tone to your content - energetic for gaming, professional for business</Tip>
<Tip>**Use background music**: Add music to enhance engagement without overpowering the narration</Tip>

## Media Types

| Type           | Best For                                      |
| -------------- | --------------------------------------------- |
| `ai-images`    | Educational content, explainers, storytelling |
| `ai-videos`    | Dynamic content, trailers, teasers            |
| `media`        | Stock footage for generic content             |
| `gameplay`     | Gaming tips, tutorials, compilations          |
| Custom `media` | Brand content, product showcases              |

## Caption Presets

Available caption presets for the `caption.preset` field:

| Preset     | Description                                              |
| ---------- | -------------------------------------------------------- |
| `default`  | Default caption style with bold text and shadow effects  |
| `beast`    | Bold uppercase style with Komika font                    |
| `umi`      | Yellow glowing text style                                |
| `tiktok`   | Viral & trendy style, perfect for social media           |
| `wrap1`    | Wrapped style with red background highlight              |
| `wrap2`    | Wrapped style with blue background highlight (uppercase) |
| `ariel`    | Bold uppercase style with purple highlight               |
| `slidevid` | Brand style with purple background                       |
| `classic`  | Clean, simple captions with black background (Default)   |
| `active`   | Green background with bold text                          |
| `bubble`   | White background bubble style                            |
| `glass`    | Glassmorphic transparency effect                         |
| `comic`    | Comic Sans font with colorful style                      |
| `glow`     | Pink and orange glow effects                             |
| `pastel`   | Soft pastel pink background                              |
| `neon`     | Green neon glow effect                                   |
| `retroTV`  | Retro TV style with cyan glow                            |
| `red`      | Red glow effect with white text                          |
| `marker`   | Yellow marker/highlighter style                          |
| `modern`   | Contemporary white background style                      |
| `blue`     | Blue background style                                    |
| `vivid`    | Vibrant pink background with uppercase text              |

***

## Use Cases

* **Educational Content**: Explainers, tutorials, how-to videos
* **Social Media**: TikTok, Instagram Reels, YouTube Shorts
* **Marketing**: Product showcases, brand stories, promotions
* **Gaming**: Tips, tutorials, compilations
* **News & Updates**: Company announcements, industry updates

## Handling the Webhook Response

```javascript theme={null}
// Express.js webhook handler
app.post('/webhook', (req, res) => {
  const { data, status, message } = req.body;

  if (status === "COMPLETED") {
    const { videoId, status: videoStatus, url, shareUrl, metadata } = data;
    console.log('Video completed!');
    console.log('Video ID:', videoId);
    console.log('Download URL:', url);
    console.log('Share URL:', shareUrl);
    console.log('Content Type:', metadata.contentType);

    // Save to your database, notify team, etc.
  }

  res.status(200).send('OK');
});
```
