Skip to content

OpenAI Generate Image

This module generates images from text using OpenAI’s DALL-E 3 model. Its execution flow is:

  1. Obtains the credentials (apiKey) from the credentials system.
  2. Determines the prompt to use, with priority: data.prompt_image > data.prompt > config.prompt.
  3. Sends a request to the OpenAI image generation API with the DALL-E 3 model and 1024x1024 size.
  4. Downloads the generated image from OpenAI’s temporary URL.
  5. Saves the image locally in the temporal/cli_{client_id}/ directory with a unique UUID name.
  6. Generates a public download URL based on ENGINE_HOST.
  7. Returns the OpenAI URL, public download URL, and local file path.

If the prompt comes from data.prompt_image, the original data is preserved in the response (persistent mode).

ParameterTypeRequiredDescription
credentials_idcredentialsYesOpenAI API credentials (apiKey).
prompttextareaYesText description of the image to generate.
sizetextNoImage size. The module internally uses 1024x1024 with DALL-E 3.

credentials_id is required with an object containing apiKey (OpenAI API key with access to DALL-E).

{
"nextModule": "siguiente-nodo",
"data": {
"imageUrl": "https://oaidalleapiprodscus.blob.core.windows.net/...",
"urlPath": "https://mi-engine.com/download/cli_1/abc123.png",
"localPath": "/app/temporal/cli_1/abc123.png"
},
"_meta_": {
"prompt": "Un gato astronauta en la luna",
"tokens_consumed": 0.4
}
}
{
"credentials_id": "credencial-openai",
"prompt": "Un paisaje futurista de una ciudad con edificios flotantes al atardecer"
}
  • OpenAI Images API: POST https://api.openai.com/v1/images/generations
  • Model: DALL-E 3
  • Authentication: Bearer token with apiKey.
  • Images are always generated at 1024x1024 size with DALL-E 3, regardless of the configured size parameter.
  • The image is saved locally in temporal/cli_{client_id}/ and is accessible via the engine’s download URL.
  • The OpenAI URL (imageUrl) is temporary and expires after some time.
  • The temporary directory is automatically created if it does not exist.
  • The estimated cost is reported as 0.4 in _meta_.tokens_consumed (approximate reference).
  • If data.prompt_image exists, persistent mode is activated which preserves all original data in the response.