Video Generation

Generate professional avatar videos programmatically using the KonPro API. Create videos with AI-powered avatars speaking your custom text with natural voices.

About Video Generation

The KonPro video generation API allows you to create high-quality videos featuring AI avatars that speak your text with natural voices. Videos are generated asynchronously, and you can track their progress through job status endpoints or webhooks.

Key Features:

  • AI-powered avatars with natural lip-sync and expressions
  • Multiple voice options in various languages
  • Customizable video settings (resolution, format, background)
  • Asynchronous processing with status tracking
  • Webhook support for real-time notifications

How Video Generation Works

  1. Create a video generation job: Submit a request to the Create Avatar Video endpoint with your avatar, voice, and text.
  2. Receive a job ID: The API returns a job_id that you can use to track the video generation progress.
  3. Monitor progress: Use the Retrieve Video Status endpoint to check the job status, or set up webhooks to receive notifications automatically.
  4. Retrieve the video: Once the status is completed, the video URL will be available in the response.

Create Video Avatar Endpoint

The main endpoint for generating avatar videos:

POST/v1/video-avatars

Request Parameters

ParameterTypeRequiredDescription
avatar_idstringYesID of the avatar to use. See List All Avatars for available avatars.
voice_idstringYesID of the voice to use. See List All Voices for available voices.
textstringYesThe text that the avatar will speak in the video.
settingsobjectNoOptional settings for video generation (resolution, format, background, webhook_url).
settings.resolutionstringNoVideo resolution (e.g., 1080p, 720p).
settings.formatstringNoVideo format (e.g., mp4, webm).
settings.backgroundstringNoBackground type or URL (e.g., office, transparent).
settings.webhook_urlstringNoURL to receive webhook notifications when video generation completes.

Response

The API returns a job object with the following structure:

json
{
  "job_id": "job-456",
  "status": "processing",
  "estimated_time": 120,
  "message": "Video generation started"
}

Complete Example

Here's a complete example showing how to generate a video and monitor its progress:

javascript
async function generateAvatarVideo() {
    const apiKey = 'YOUR_API_KEY';
    const apiUrl = 'https://api.konpro.ai/v1/video-avatars';
    
    try {
        // Step 1: Create video generation job
        const response = await fetch(apiUrl, {
            method: 'POST',
            headers: {
                'x-api-key': apiKey,
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                avatar_id: 'avatar-3655',
                voice_id: 'voice-123',
                text: 'Welcome to our platform! Let me show you around.',
                settings: {
                    resolution: '1080p',
                    format: 'mp4',
                    background: 'office'
                }
            })
        });
        
        const { job_id } = await response.json();
        console.log('Job created:', job_id);
        
        // Step 2: Poll for completion (or use webhooks)
        let videoUrl = null;
        while (!videoUrl) {
            await new Promise(resolve => setTimeout(resolve, 5000));
            
            const statusResponse = await fetch(`https://api.konpro.ai/v1/video-avatars/${job_id}`, {
                headers: {
                    'x-api-key': apiKey
                }
            });
            
            const status = await statusResponse.json();
            
            if (status.status === 'completed') {
                videoUrl = status.video_url;
            } else if (status.status === 'failed') {
                throw new Error('Video generation failed');
            }
        }
        
        console.log('Video generated:', videoUrl);
        return videoUrl;
    } catch (error) {
        console.error('Error generating video:', error);
        throw error;
    }
}

Best Practices

  • Use webhooks: Instead of polling for status, set up webhooks to receive notifications when videos are ready. This is more efficient and reduces API calls.
  • Handle errors gracefully: Implement proper error handling for failed video generations and provide user feedback.
  • Optimize text length: Longer text will result in longer processing times. Consider breaking very long videos into segments.
  • Cache video URLs: Once a video is generated, cache the URL to avoid unnecessary API calls.
  • Monitor rate limits: Be aware of rate limits when generating multiple videos in quick succession.
  • Choose appropriate settings: Higher resolutions and certain formats may take longer to process. Choose settings that match your use case.
  • Test with short text first: When integrating, start with short text samples to verify your implementation before processing longer content.

Notes

  • Video generation is asynchronous - the API returns immediately with a job ID.
  • Processing time varies based on video length, resolution, and current system load.
  • Videos are typically available within 1-5 minutes, but complex videos may take longer.
  • Generated videos are stored temporarily. Download and store them in your own storage if you need long-term access.
  • For production applications, always use webhooks instead of polling to reduce API calls and improve efficiency.
  • See Error Responses for information on handling errors during video generation.

Table of Contents