How to use AI to generate Instagram Reels at scale
A step-by-step tutorial on using CDNZero's AI video generation API to create, optimize, and publish Instagram Reels automatically at scale.
Creating one Instagram Reel takes time. Creating 50 per month — for multiple brands, consistently, at quality — used to require a team. This guide shows how to use CDNZero's API to automate Reel generation, optimisation, and publishing at scale.
The automation pipeline
A complete automated Reel pipeline has four stages: prompt construction (turning your content brief into a structured video prompt), generation (calling the AI to produce the video), storage and transcoding (getting the video into the right format), and scheduling (queuing the post for the optimal publish time).
All four stages are available via the CDNZero API. You can run the entire pipeline from a script, a CI job, or a backend service.
Step 1: Construct your prompt
The quality of AI-generated video depends heavily on prompt structure. Vague prompts produce generic content. Specific prompts — with style direction, subject matter, mood, and duration — produce usable content.
function buildReelPrompt(product, campaign) {
return {
prompt: `Product showcase for ${product.name}.
Style: ${campaign.style}.
Mood: ${campaign.mood}.
Duration: 15 seconds.
Aspect ratio: 9:16.`,
style: campaign.videoStyle, // "cinematic", "social", "product-demo"
duration: 15,
aspect_ratio: "9:16",
quality: "high",
};
}Step 2: Generate via API
Video generation is asynchronous. The API returns a job ID immediately. Poll the status endpoint until the job completes, then retrieve the video URL.
async function generateReel(prompt) {
// Start generation
const job = await fetch("https://api.cdnzero.com/v1/generate/video", {
method: "POST",
headers: { "Authorization": `Bearer ${API_KEY}` },
body: JSON.stringify(prompt),
}).then((r) => r.json());
// Poll until complete
while (true) {
const status = await fetch(
`https://api.cdnzero.com/v1/generate/jobs/${job.id}`,
{ headers: { "Authorization": `Bearer ${API_KEY}` } }
).then((r) => r.json());
if (status.state === "complete") return status.asset_url;
if (status.state === "failed") throw new Error(status.error);
await new Promise((r) => setTimeout(r, 3000));
}
}Step 3: Schedule for publishing
Once you have the asset URL, schedule it for Instagram. The publishing API accepts a caption, hashtags, account ID, and publish time.
async function scheduleReel(assetUrl, caption, publishAt) {
return fetch("https://api.cdnzero.com/v1/publishing/schedule", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
platform: "instagram",
type: "reel",
asset_url: assetUrl,
caption,
publish_at: publishAt.toISOString(),
}),
}).then((r) => r.json());
}Batch processing
For a monthly content calendar, generate all your videos in a batch job at the start of the month and schedule them across optimal posting windows. A typical setup generates 20–30 Reels in a single overnight job and distributes them across the month's calendar.
Rate limits apply to both generation (concurrent jobs) and publishing (posts per day per account). Check the API documentation for current limits on your plan.
Measuring results
CDNZero's publishing analytics show impressions, reach, and engagement per post. For a scaled operation, pull the analytics API weekly and feed the performance data back into your prompt construction — posts that perform well become training examples for better prompts.
More Guide articles
Start hosting files the simple way
Create a workspace, upload your first asset and copy its CDN URL. The free plan includes 3 GB of storage and 15 GB of transfer.
No credit card required · Cancel anytime