Skip to main content
This guide shows you how to generate an AI image using both a text prompt and a reference image. The reference image provides visual context that guides the AI model, allowing you to create variations, apply transformations, or produce new compositions inspired by the original.

What You Will Build

Reference-Guided Generation

Use an existing image to guide the AI output

Creative Variations

Generate new images that draw from a source composition

Subject Replacement

Replace or modify subjects while preserving scene context

Style Transfer

Apply different visual styles to referenced content

Before You Begin

Make sure you have:
  • A Pictory API key
  • Node.js or Python installed on your machine
  • The required packages installed
  • A publicly accessible URL for your reference image

Step-by-Step Guide

Step 1: Set Up Your Request

Prepare your API credentials, the reference image URL, and the prompt that describes the desired transformation or output.
The referenceImageUrl must point to a publicly accessible image. Ensure the URL does not require authentication or session cookies to access.

Step 2: Submit the Image Generation Request

Send the request to the AI Studio image generation endpoint. The process is identical to text-to-image generation, with the addition of the referenceImageUrl field.

Step 3: Poll for the Result

Check the job status at regular intervals until the image is ready.

Understanding the Parameters

Tips for Reference-Based Generation

  • Describe the change clearly. State what should be modified from the reference image. For example, “Replace the car with a bicycle” is more effective than “Change the vehicle.”
  • Mention the reference explicitly. Use phrases such as “in the referenced image” or “based on the provided image” so the model understands the relationship between the prompt and the reference.
  • Preserve scene context. If you want to keep the background or composition, say so in the prompt. For example, “Keep the background and lighting unchanged.”
  • Combine with styles. Applying a style such as "artistic" or "cartoon" transforms the reference into a different visual treatment while preserving the subject and layout.

Next Steps