Skip to main content
This guide shows you how to use AI-generated images as scene backgrounds in your videos. Instead of stock visuals, generate custom images from text prompts using a variety of AI image models — each with different quality levels and AI credit costs.

What You’ll Learn

AI Image Generation

Generate unique images with AI instead of stock visuals

Image Models

Choose from Flux, Seedream, Nano Banana, and Nano Banana Pro

Media Styles

Apply styles like photorealistic, artistic, cartoon, and more

AI Credit Costs

Understand per-image credit costs for each model

Before You Begin

Make sure you have:
  • A Pictory API key (get one here)
  • Node.js or Python installed on your machine
  • Sufficient AI credits in your account
  • Basic understanding of AI image generation concepts
npm install axios

How It Works

When you set background.type to "image" and provide an aiVisual configuration, Pictory generates a unique AI image for the scene background:
  1. Prompt Processing — Your text prompt (or auto-generated prompt from story text) is analyzed
  2. Style Application — The selected mediaStyle is applied to shape the visual output
  3. AI Generation — The chosen image model creates a unique image
  4. Scene Integration — The generated image is used as the scene background
AI image generation takes additional processing time compared to stock visuals. The time varies by model — faster models like Flux generate in seconds, while higher-quality models take longer.

Configuration Reference

Background Object

When using AI-generated images, set the background object on a scene as follows:
ParameterTypeRequiredDescription
typestringYesMust be "image" for AI-generated images
aiVisualobjectYesAI image generation configuration (see below)
Mutually Exclusive: The background object can only have one of visualUrl, color, or aiVisual. You cannot combine them in the same scene.

aiVisual Parameters

ParameterTypeRequiredDescription
promptstringNoText description of the image to generate (max 500 characters). If omitted, a prompt is auto-generated from the scene’s story text.
modelstringYesThe AI image model to use. See Available Image Models.
mediaStylestringNoVisual style to apply. See Available Media Styles.
The videoDuration parameter is not allowed when type is "image". It is only used for AI-generated video clips.

Available Image Models

Each model has different strengths and AI credit costs. Choose based on your quality requirements and budget.
Model IDDisplay NameAI Credits (per image)Best ForSupported Aspect Ratios
flux-schnellFlux0.6Reliable for basic layouts1:1, 16:9, 9:16
seedream3.0Seedream2Reliable for text and numbers1:1, 16:9, 9:16
nanobananaNano Banana4Excels at details1:1, 16:9, 9:16
nanobanana-proNano Banana Pro14Superior cinematic quality1:1, 16:9, 9:16
Model Selection Strategy:
  • Use flux-schnell (0.6 credits) for quick iterations, testing, and drafts
  • Use seedream3.0 (2 credits) when your image includes text or numbers
  • Use nanobanana (4 credits) when you need fine detail and precision
  • Use nanobanana-pro (14 credits) for premium, cinematic-quality final output

Available Media Styles

The mediaStyle parameter shapes the look and feel of the generated image. It is optional — if omitted, the model uses its default rendering style.
StyleVisual CharacteristicsBest Used For
photorealisticRealistic photographs, natural lightingCorporate videos, professional presentations, realistic scenarios
artisticArtistic renderings, painterly effectsCreative content, brand storytelling, abstract concepts
cartoonCartoon-style imagery, bold colorsChildren’s content, educational videos, fun marketing
minimalistSimple, clean designs, reduced detailsModern branding, tech content, professional minimalism
vintageRetro aesthetic, aged appearanceNostalgia marketing, historical content, unique branding
futuristicModern, sci-fi look, high-tech feelTechnology content, innovation topics, forward-thinking brands

Examples

Example 1: Single Story Without Prompt

One scene with a story paragraph. The system splits the story into multiple scenes using createSceneOnEndOfSentence and auto-generates a visual prompt for each scene from its story text.
import axios from "axios";

const API_BASE_URL = "https://api.pictory.ai/pictoryapis";
const API_KEY = "YOUR_API_KEY";

async function createImagesWithAutoPrompt() {
  const response = await axios.post(
    `${API_BASE_URL}/v2/video/storyboard/render`,
    {
      videoName: "ai-images-auto-prompt",
      language: "en",
      backgroundMusic: { enabled: true, autoMusic: true, volume: 0.5 },
      voiceOver: {
        enabled: true,
        aiVoices: [{ speaker: "Jackson", speed: 100, amplificationLevel: 0 }]
      },
      scenes: [
        {
          story: "Every day, millions of content creators, educators, and marketers face the same challenge. They need professional-quality videos but do not have a production team. Hours are spent searching stock libraries for footage that almost fits. Days are lost waiting for design assets. AI-powered video creation changes everything. With a simple text prompt, you can generate custom visuals tailored to your exact narrative. No more settling for generic stock footage. Whether you are building an online course, launching a campaign, or growing your social media presence, AI visuals give you the power to create stunning content in minutes.",
          createSceneOnNewLine: true,
          createSceneOnEndOfSentence: true,
          background: {
            type: "image",
            aiVisual: {
              model: "nanobanana",
              mediaStyle: "photorealistic"
            }
          }
        }
      ]
    },
    { headers: { "Content-Type": "application/json", Authorization: API_KEY } }
  );

  const jobId = response.data.data.jobId;
  console.log("Job ID:", jobId);

  let jobCompleted = false;
  while (!jobCompleted) {
    const statusResponse = await axios.get(
      `${API_BASE_URL}/v1/jobs/${jobId}`,
      { headers: { Authorization: API_KEY } }
    );
    const status = statusResponse.data.data.status;
    console.log("Status:", status);
    if (status === "completed") {
      jobCompleted = true;
      console.log("Video URL:", statusResponse.data.data.videoURL);
    } else if (status === "failed") {
      throw new Error("Failed: " + JSON.stringify(statusResponse.data));
    }
    await new Promise((resolve) => setTimeout(resolve, 10000));
  }
}

createImagesWithAutoPrompt();

Example 2: Single Story with Creative Direction

Same as Example 1, but with a prompt that acts as creative direction for the entire video. Since the story is split into multiple scenes, the prompt guides the overall visual tone rather than describing a specific scene. A good creative direction prompt follows this structure: [Action/Movement] + [Scene/Environment] + [Camera Technique] + [Visual Style].
import axios from "axios";

const API_BASE_URL = "https://api.pictory.ai/pictoryapis";
const API_KEY = "YOUR_API_KEY";

async function createImagesWithCreativeDirection() {
  const response = await axios.post(
    `${API_BASE_URL}/v2/video/storyboard/render`,
    {
      videoName: "ai-images-creative-direction",
      language: "en",
      backgroundMusic: { enabled: true, autoMusic: true, volume: 0.5 },
      voiceOver: {
        enabled: true,
        aiVoices: [{ speaker: "Jackson", speed: 100, amplificationLevel: 0 }]
      },
      scenes: [
        {
          story: "Every day, millions of content creators, educators, and marketers face the same challenge. They need professional-quality videos but do not have a production team. Hours are spent searching stock libraries for footage that almost fits. Days are lost waiting for design assets. AI-powered video creation changes everything. With a simple text prompt, you can generate custom visuals tailored to your exact narrative. No more settling for generic stock footage. Whether you are building an online course, launching a campaign, or growing your social media presence, AI visuals give you the power to create stunning content in minutes.",
          createSceneOnNewLine: true,
          createSceneOnEndOfSentence: true,
          background: {
            type: "image",
            aiVisual: {
              model: "nanobanana",
              mediaStyle: "photorealistic",
              prompt: "Wide-angle establishing shots of diverse professionals in bright, airy coworking spaces with large windows and natural daylight"
            }
          }
        }
      ]
    },
    { headers: { "Content-Type": "application/json", Authorization: API_KEY } }
  );

  const jobId = response.data.data.jobId;
  console.log("Job ID:", jobId);

  let jobCompleted = false;
  while (!jobCompleted) {
    const statusResponse = await axios.get(
      `${API_BASE_URL}/v1/jobs/${jobId}`,
      { headers: { Authorization: API_KEY } }
    );
    const status = statusResponse.data.data.status;
    console.log("Status:", status);
    if (status === "completed") {
      jobCompleted = true;
      console.log("Video URL:", statusResponse.data.data.videoURL);
    } else if (status === "failed") {
      throw new Error("Failed: " + JSON.stringify(statusResponse.data));
    }
    await new Promise((resolve) => setTimeout(resolve, 10000));
  }
}

createImagesWithCreativeDirection();

Example 3: Multiple Scenes with Prompts

Three separate scenes, each with a one-sentence story and a scene-specific prompt. The prompt directly describes the visual for that scene.
import axios from "axios";

const API_BASE_URL = "https://api.pictory.ai/pictoryapis";
const API_KEY = "YOUR_API_KEY";

async function createImagesWithScenePrompts() {
  const response = await axios.post(
    `${API_BASE_URL}/v2/video/storyboard/render`,
    {
      videoName: "ai-images-scene-prompts",
      language: "en",
      backgroundMusic: { enabled: true, autoMusic: true, volume: 0.5 },
      voiceOver: {
        enabled: true,
        aiVoices: [{ speaker: "Jackson", speed: 100, amplificationLevel: 0 }]
      },
      scenes: [
        {
          story: "Content creators struggle to find the perfect visuals for their videos.",
          background: {
            type: "image",
            aiVisual: {
              model: "nanobanana",
              mediaStyle: "photorealistic",
              prompt: "A frustrated creator scrolling through endless stock footage on a laptop in a dimly lit room"
            }
          }
        },
        {
          story: "AI-powered tools generate custom visuals from simple text prompts in minutes.",
          background: {
            type: "image",
            aiVisual: {
              model: "nanobanana",
              mediaStyle: "photorealistic",
              prompt: "A bright modern workspace with AI-generated visuals appearing on a large monitor"
            }
          }
        },
        {
          story: "Professional-quality videos are now accessible to educators and marketers everywhere.",
          background: {
            type: "image",
            aiVisual: {
              model: "nanobanana",
              mediaStyle: "photorealistic",
              prompt: "Diverse professionals confidently presenting polished video content on various devices"
            }
          }
        }
      ]
    },
    { headers: { "Content-Type": "application/json", Authorization: API_KEY } }
  );

  const jobId = response.data.data.jobId;
  console.log("Job ID:", jobId);

  let jobCompleted = false;
  while (!jobCompleted) {
    const statusResponse = await axios.get(
      `${API_BASE_URL}/v1/jobs/${jobId}`,
      { headers: { Authorization: API_KEY } }
    );
    const status = statusResponse.data.data.status;
    console.log("Status:", status);
    if (status === "completed") {
      jobCompleted = true;
      console.log("Video URL:", statusResponse.data.data.videoURL);
    } else if (status === "failed") {
      throw new Error("Failed: " + JSON.stringify(statusResponse.data));
    }
    await new Promise((resolve) => setTimeout(resolve, 10000));
  }
}

createImagesWithScenePrompts();

Example 4: Multiple Scenes Without Prompts

Three separate scenes, each with a one-sentence story. No prompts are provided, so the system auto-generates a visual prompt from each scene’s story text.
import axios from "axios";

const API_BASE_URL = "https://api.pictory.ai/pictoryapis";
const API_KEY = "YOUR_API_KEY";

async function createImagesAutoScenes() {
  const response = await axios.post(
    `${API_BASE_URL}/v2/video/storyboard/render`,
    {
      videoName: "ai-images-auto-scenes",
      language: "en",
      backgroundMusic: { enabled: true, autoMusic: true, volume: 0.5 },
      voiceOver: {
        enabled: true,
        aiVoices: [{ speaker: "Jackson", speed: 100, amplificationLevel: 0 }]
      },
      scenes: [
        {
          story: "Content creators struggle to find the perfect visuals for their videos.",
          background: {
            type: "image",
            aiVisual: {
              model: "nanobanana",
              mediaStyle: "photorealistic"
            }
          }
        },
        {
          story: "AI-powered tools generate custom visuals from simple text prompts in minutes.",
          background: {
            type: "image",
            aiVisual: {
              model: "nanobanana",
              mediaStyle: "photorealistic"
            }
          }
        },
        {
          story: "Professional-quality videos are now accessible to educators and marketers everywhere.",
          background: {
            type: "image",
            aiVisual: {
              model: "nanobanana",
              mediaStyle: "photorealistic"
            }
          }
        }
      ]
    },
    { headers: { "Content-Type": "application/json", Authorization: API_KEY } }
  );

  const jobId = response.data.data.jobId;
  console.log("Job ID:", jobId);

  let jobCompleted = false;
  while (!jobCompleted) {
    const statusResponse = await axios.get(
      `${API_BASE_URL}/v1/jobs/${jobId}`,
      { headers: { Authorization: API_KEY } }
    );
    const status = statusResponse.data.data.status;
    console.log("Status:", status);
    if (status === "completed") {
      jobCompleted = true;
      console.log("Video URL:", statusResponse.data.data.videoURL);
    } else if (status === "failed") {
      throw new Error("Failed: " + JSON.stringify(statusResponse.data));
    }
    await new Promise((resolve) => setTimeout(resolve, 10000));
  }
}

createImagesAutoScenes();

Tracking AI Credits Used

When your video includes AI-generated visuals, the job response includes an aiCreditsUsed field that reports the total AI credits consumed across all scenes. This field is present only when at least one scene used aiVisual configuration.
{
    "job_id": "a1d36612-326d-4b81-aece-411f8aed4c70",
    "success": true,
    "data": {
        "status": "completed",
        "aiCreditsUsed": 24
    }
}
Use this value to track credit consumption and manage your AI credit budget. For detailed job response documentation, refer to the Get Storyboard Preview Job or Get Video Render Job API reference.

Best Practices

  • Be specific: Include details about composition, lighting, and mood
  • Use descriptive language: “bright morning sunlight streaming through glass walls” vs “sunny room”
  • Mention key elements: “modern office with glass walls and city skyline view”
  • Keep under 500 characters: Concise prompts produce more focused results
  • Avoid negatives: Describe what you want, not what you do not want
Good: “Professional business meeting in modern conference room with natural light and city view”Poor: “Not a dark room, people talking, no clutter”
ScenarioRecommended ModelCost
Testing & draftsflux-schnell0.6 credits
General contentseedream3.02 credits
Detail-rich scenesnanobanana4 credits
Premium final outputnanobanana-pro14 credits
Start with flux-schnell for iteration, then switch to a higher-quality model for production.
  • Corporate/Professional: photorealistic or minimalist
  • Creative/Artistic: artistic or vintage
  • Tech/Innovation: futuristic
  • Educational/Fun: cartoon
  • Consistent branding: Stick to one style across scenes
If your image needs to display readable text or numbers, use seedream3.0 — it is specifically optimized for rendering text and numbers clearly within generated images.

Troubleshooting

  • Make your prompt more specific and detailed
  • Add descriptive adjectives: “bright”, “modern”, “spacious”
  • Specify composition: “aerial view”, “close-up”, “wide angle”
  • Include lighting details: “sunset lighting”, “studio lighting”
  • Try a different model — each interprets prompts differently
  • Switch to a higher-quality model (nanobanana or nanobanana-pro)
  • Avoid overly complex prompts — keep them focused
  • Try a different mediaStyle that suits the content
Ensure your configuration follows these rules:
// Correct
background: {
  type: "image",
  aiVisual: {
    model: "flux-schnell",
    mediaStyle: "photorealistic"
  }
}

// Wrong — missing type
background: {
  aiVisual: { model: "flux-schnell" }
}

// Wrong — mixing background types
background: {
  type: "image",
  visualUrl: "https://...",
  aiVisual: { model: "flux-schnell" }
}

// Wrong — videoDuration not allowed for images
background: {
  type: "image",
  aiVisual: {
    model: "flux-schnell",
    videoDuration: "5s"
  }
}
Each image generation costs AI credits based on the model used. Check your credit balance and consider using a more economical model like flux-schnell (0.6 credits per image).

Next Steps

AI-Generated Video Clips

Use AI-generated video clips as scene backgrounds

AI Voice-Over

Add professional narration to your videos

Brand Settings

Apply consistent branding automatically

Background Music

Add music to complement your visuals

API Reference

Render Storyboard Video

Direct video rendering with AI visuals

Create Storyboard Preview

Create preview before rendering

Get Storyboard Preview Job

Monitor storyboard creation progress

Search Media

Search stock visuals as alternative to AI