Skip to content

sup.ai.image

The sup.ai.image package provides AI-powered image generation and manipulation capabilities. It is accessed through sup.ai.image.

Example sup.ai.image Usage
// Generate a simple image
const image = sup.ai.image.create("a beautiful sunset over mountains");
// Generate with options
const hdImage = sup.ai.image.create("a futuristic cityscape", {
aspectRatio: "16:9",
model: "fast",
quality: "high"
});
// Generate using reference images for style/content
const styledImage = sup.ai.image.create("a cat in this artistic style", {
referenceImages: [sup.asset("style_reference.png")]
});
// Generate with web search for real-time data
const currentImage = sup.ai.image.create("today's news as a painting", {
model: "gemini-3.1-flash-image-preview",
useWebSearch: true
});
// Analyze an image
const description = sup.ai.image.interpret(
image,
"What objects are in this image?"
);
// Edit an image
const editedImage = sup.ai.image.edit(image, "make it more vibrant");
// Edit with style references
const styledEdit = sup.ai.image.edit(image, "apply this style", {
referenceImages: [sup.asset("style.png")]
});

Methods

sup.ai.image.create()

(prompt: string, options?: SupAIImageCreateOptions) → SupImage

// Basic usage - just a prompt
const image = sup.ai.image.create("a beautiful sunset over mountains");
// With options
const hdImage = sup.ai.image.create("a futuristic cityscape", {
aspectRatio: "16:9",
model: "fast",
quality: "high"
});
// With reference images for style or content guidance
const styledCat = sup.ai.image.create("a cat in this artistic style", {
referenceImages: [sup.asset("style_reference.png")]
});
// With multiple reference images
const combined = sup.ai.image.create("combine these characters into one scene", {
referenceImages: [sup.asset("character1.png"), sup.asset("character2.png")]
});
// With web search for real-time information
const currentImage = sup.ai.image.create(
"today's weather in New York as a painting",
{ model: "gemini-3.1-flash-image-preview", useWebSearch: true }
);

Creates an image using AI based on a text prompt, optionally using reference images for style or content guidance.

Parameters:

  • prompt (string): The text description of the image to generate
  • options (optional object):
    • model ('best' | 'fast' | 'gemini-3-pro-image' | 'gemini-3.1-flash-image-preview'): The AI model to use
    • quality ('low' | 'medium' | 'high'): The quality level for generation
    • aspectRatio (string): The desired aspect ratio (e.g., '16:9', '1:1')
    • referenceImages (SupImage[]): Reference images to guide the style/content of the generated image (max 14). Only supported by 'fast', 'gemini-3-pro-image', and 'gemini-3.1-flash-image-preview' models.
    • useWebSearch (boolean): Enable web search grounding for real-time data. Only supported by 'gemini-3-pro-image' and 'gemini-3.1-flash-image-preview' models.

Returns: A SupImage object containing the generated image

sup.ai.image.interpret()

(image: Image, prompt: string) → string

const description = sup.ai.image.interpret(
image,
"What objects are in this image?"
);

Converts an image to text using AI image recognition.

Parameters:

  • image (SupImage): The image to analyze
  • prompt (string): The specific question or instruction for image interpretation

Returns: A string containing the AI’s interpretation of the image

sup.ai.image.edit()

(image: SupImage | SupImage[], prompt: string, options?: SupAIImageEditOptions) → SupImage

// Edit a single image
const editedImage = sup.ai.image.edit(image, "make it more vibrant");
// Edit multiple images with specific quality
const editedImages = sup.ai.image.edit(
[image1, image2],
"combine into a single black and white image",
{ model: "best", quality: "high" }
);
// Edit with style reference images
const styledEdit = sup.ai.image.edit(
image,
"apply this artistic style",
{ referenceImages: [sup.asset("style.png")] }
);
// Edit with web search for current context
const updatedImage = sup.ai.image.edit(
image,
"update the outfit to current fashion trends",
{ model: "gemini-3.1-flash-image-preview", useWebSearch: true }
);

Edits one or more images using AI based on a text prompt.

Parameters:

  • image (SupImage | SupImage[]): A single image or array of images to edit
  • prompt (string): The text description of how to edit the image(s)
  • options (optional object):
    • model ('best' | 'fast' | 'gemini-3-pro-image' | 'gemini-3.1-flash-image-preview'): The AI model to use
    • quality ('low' | 'medium' | 'high'): The quality level for editing
    • mask (SupImage | string): A mask image to specify which areas to edit
    • referenceImages (SupImage[]): Reference images to guide the style of the edited image (max 14). Only supported by 'fast', 'gemini-3-pro-image', and 'gemini-3.1-flash-image-preview' models.
    • useWebSearch (boolean): Enable web search grounding for real-time data. Only supported by 'gemini-3-pro-image' and 'gemini-3.1-flash-image-preview' models.

Returns: A SupImage object containing the edited image


Notes

  • Generated and edited images are returned as SupImage objects which can be displayed by returning them from main().
  • The AI models used may have specific limitations or requirements for prompts.

Model Availability

Feature'best''fast''gemini-3-pro-image''gemini-3.1-flash-image-preview'
referenceImagesNoYesYesYes
useWebSearchNoNoYesYes
  • referenceImages: Allows up to 14 reference images to guide the style or content of generated/edited images. Not available with the 'best' model.
  • useWebSearch: Enables web search grounding for real-time information (e.g., current events, trends). Only available with 'gemini-3-pro-image' and 'gemini-3.1-flash-image-preview'.