Skip to main content

OpenAI Images

Generate, edit, and vary images with OpenAI from any workflow.

This Module turns text prompts into images, applies prompt-guided edits to existing images (optionally constrained by a mask), and produces variations of an input image. Results land in a Session variable as a URL or a base64 data URL, ready to send to the user or store.

How it works

Each Task sends one request to OpenAI's image endpoints and saves the result. Image inputs accept an https://… URL, a data:image/...;base64,… data URL, or a {variable} containing one of those. Generated images come back either as an OpenAI-hosted URL (expires after a while) or — when you ask for base64 — as a self-contained data URL you can store with a file-storage Task.

Configuration

Each OpenAI Module is configured separately, per Environment — this Module has its own API key, so you can reuse the key you set on the core OpenAI Module or use a dedicated one (for example to track this capability's spend on its own).

FieldTypeRequiredExampleDescription
OpenAI API KeystringYessk-...Your OpenAI API key for this Module. Stored securely. Find it in OpenAI Console → API keys → Create new secret key.
OpenAI OrganizationstringNoorg-abc123Your OpenAI organization ID, if your account belongs to one.

Tasks

All Tasks in this Module are Generic (all Channels) — they run the same regardless of how the Session was started.

Output fields: type a variable name without braces (for example image) and pick its type (string, number, true/false, object, date). The Task saves its result there, and any later Task can use it by writing {image}.

OpenAIGenerateImageTask

Generates an image from a text prompt.

PropertyTypeRequiredExampleDescription
ModelstringYesdall-e-3dall-e-3, dall-e-2, or gpt-image-1.
SizestringNo1024x1024e.g. 1024x1024. Allowed values depend on the model.
QualitystringNohdstandard or hd. Empty → model default.
StylestringNovividvivid or natural. Empty → model default.
PromptstringYes{imagePrompt}Text prompt. Supports {variable} placeholders.
Output VariablestringYesimageVariable name (no braces). Receives the URL or data: URL.
Return as Base64 Data URLboolNocheckedDefault off. When on, the result is data:image/png;base64,... for downstream storage.

Example: Set Model = dall-e-3, Size = 1024x1024, Prompt = {imagePrompt}, Output Variable = image, Return as Base64 Data URL = off. With {imagePrompt} = "A watercolor lighthouse at dawn", the Task saves an OpenAI-hosted image URL to image; a later Task sends it with {image}.

OpenAIEditImageTask

Edits an existing image with a text prompt and an optional mask. Transparent pixels in the mask mark the areas to edit.

PropertyTypeRequiredExampleDescription
ModelstringYesdall-e-2dall-e-2 or gpt-image-1.
Image SourcestringYes{imageUrl}URL, data URL, or {variable} containing one of those.
Image File NamestringNoinput.pngFilename including extension. Default input.png.
Mask SourcestringNo{maskUrl}Optional. Same format as Image Source. Transparent pixels in the mask mark areas to edit.
Mask File NamestringNomask.pngFilename including extension. Default mask.png.
PromptstringYes{editPrompt}Text prompt describing the edit. Supports {variable} placeholders.
Output VariablestringYeseditedImageVariable name (no braces). Receives the resulting image URL or data URL.

Example: Set Model = dall-e-2, Image Source = {imageUrl}, Mask Source = {maskUrl}, Prompt = Replace the sky with a starry night, Output Variable = editedImage. The Task edits only the transparent mask area and saves the result to editedImage.

OpenAIVariationImageTask

Generates N variations of an input image (no prompt).

PropertyTypeRequiredExampleDescription
ModelstringYesdall-e-2dall-e-2.
Image SourcestringYes{imageUrl}URL, data URL, or {variable} containing one of those.
Image File NamestringNoinput.pngFilename including extension. Default input.png.
CountstringNo3Number of variations to generate (110). Default 1.
Output VariableobjectYesvariationsVariable name (no braces). Receives a list of image URLs (one per variation).

Example: Set Model = dall-e-2, Image Source = {imageUrl}, Count = 3, Output Variable = variations. The Task saves a list of three image URLs to variations.

Common recipes

Ask the user what to draw, generate the image, and reply with the hosted URL. Input and Output Tasks come from the Standard Module.

  1. InputTask — Output Variable = imagePrompt (e.g. the user types "A watercolor lighthouse at dawn").
  2. OpenAIGenerateImageTask — Model = dall-e-3, Size = 1024x1024, Prompt = {imagePrompt}, Return as Base64 Data URL = off, Output Variable = image.
  3. OutputTask — Message = Here is your image: {image}. The hosted URL expires after a while — if the user needs a permanent copy, store the image (for example with the Google Drive Module) and send that link instead.

Best practices

  1. Prefer hosted URLs for immediate delivery — leave Return as Base64 Data URL off when the user just needs to see the image; the URL is small and the Session stays lean.
  2. Store before the URL expires — OpenAI-hosted image URLs are temporary; for anything the user keeps, save the image to permanent storage right after generation.
  3. Match the model to the jobdall-e-3 for prompt-faithful generation, dall-e-2 for edits and variations, gpt-image-1 for the newest generation/edit quality.

Troubleshooting

data: URL is huge

Storing a multi-megabyte image as a base64 data URL in the Session bloats the execution. Save the image to external storage (for example with the Google Drive Module) immediately after generation, then keep only the link.

Error codes

CodeNameDescription
3005TaskInvalidDataA required property is missing or an output field is not a valid variable name — details
4001ModuleExceptionOpenAI rejected the request (e.g. unsupported size or a policy-violating prompt) — details
4008ModuleMissingConfigurationThe OpenAI API key is not set in the OpenAI Module's Environment configuration — details
4009ModuleInputEmptyThe prompt or image source resolved to an empty value — details
4012ModuleInvalidDataThe Session data could not be read or the image response could not be processed — details

See the Error Code Reference for the full list.

  • OpenAI Module — the family core; the API key is configured there.