Submit a text prompt to create AI-powered video content for a specific chapter. The system processes the prompt and automatically creates video content, typically completing in 30-90 seconds.
If a chapter already has a prompt being processed, this endpoint returns a 409 Conflict error unless you set force: true to override.
curl -X POST https://api.babou.ai/api/v1/projects/prj_abc123xyz/chapters/cht_def456uvw/prompt \ -H "Authorization: Bearer $BABOU_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content": "Create an engaging introduction about AI-powered video creation. Include dynamic text animations and smooth transitions." }'
Another prompt is already being processed for this chapter
Copy
{ "error": "A prompt is already being processed for this chapter", "code": "CONFLICT", "hint": "Wait for the current prompt to complete or set force: true to override"}
Be specific about what you want in your video. Include details about:
Visual style and aesthetics
Text content and messaging
Transitions and animations
Mood and tone
Copy
const prompt = `Create a professional introduction video for a tech startup.- Show the company logo with a zoom-in animation- Display the tagline "Innovating the Future" in bold text- Use a modern, clean aesthetic with blue and white colors- Add smooth fade transitions between scenes- Duration: 15 seconds`;await submitPrompt(projectId, chapterId, prompt);
Wait for processing to complete
After submitting a prompt, the video content is created asynchronously. Use the Get Chapter endpoint to check when processing is complete:
Copy
async function waitForPromptCompletion( projectId: string, chapterId: string, maxAttempts = 20) { for (let i = 0; i < maxAttempts; i++) { const chapter = await getChapter(projectId, chapterId); const latestPrompt = chapter.prompts[chapter.prompts.length - 1]; if (latestPrompt.status === 'completed') { return latestPrompt; } if (latestPrompt.status === 'failed') { throw new Error('Prompt processing failed'); } await new Promise(r => setTimeout(r, 5000)); // Wait 5s } throw new Error('Timeout waiting for prompt completion');}
Handle conflicts gracefully
If you get a 409 error, decide whether to:
Wait for the current prompt to complete
Override with force: true (use cautiously)
Copy
async function submitPromptSafe( projectId: string, chapterId: string, content: string) { try { return await submitPrompt(projectId, chapterId, content); } catch (error: any) { if (error.message.includes('already being processed')) { console.log('Waiting for current prompt to complete...'); await waitForPromptCompletion(projectId, chapterId); // Retry submission return await submitPrompt(projectId, chapterId, content); } throw error; }}
Reference uploaded assets
If you’ve uploaded assets, reference them in your prompts:
Copy
// Upload asset firstconst logo = await uploadAsset('./company-logo.png', 'image/png');// Reference in promptconst prompt = `Create an intro video using the uploaded company logo (${logo.url}).Animate the logo with a fade-in effect over 3 seconds.Add the text "Welcome" below the logo.`;await submitPrompt(projectId, chapterId, prompt);