AIU. - Artificial Intelligence Utility

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Image Generation >

AIU. - Artificial Intelligence Utility

AIU.GenerateFile

Previous Top Next


MiniRobotLanguage (MRL)

 

AIU.GenerateFile
Generate an Image and Save to a File

 

Intention

 

GenerateFile Command: Saving AI-Generated Images Locally
 
The GenerateFile command generates an image from a text prompt and saves it to a specified file path on your system.

This is perfect for scenarios where you need to store and manage images locally for later use.

It’s part of the AIU - OpenAI API suite.

 

What is the GenerateFile Command?

 

The GenerateFile command uses the OpenAI API to create an image based on a text prompt and saves it as a file at a user-specified location.

It returns the file path, which can be stored in a variable or copied to the clipboard, with image settings controlled by prior configuration commands.

 

Why Do You Need It?

 

This command is valuable for:

Archiving AI-generated images for offline use or long-term storage.

Integrating images into local applications or workflows.

Ensuring persistent access to visuals without relying on external hosting.

 

How to Use the GenerateFile Command?

 

Specify a text prompt and a file path where the image will be saved, with optional parameters for storing the path and clipboard output.

Preconfigure image settings with commands like AIU.SetImageSize and AIU.SetImageResponseFormat.

Available models and their prices (as of March 18, 2025, from OpenAI’s pricing page) include:

gpt-4o: $5.00/1M input tokens, $15.00/1M output tokens (multimodal, 128K context).

gpt-4o-mini: $0.15/1M input tokens, $0.60/1M output tokens (cost-effective, 128K context).

gpt-4-turbo: $10.00/1M input tokens, $30.00/1M output tokens (high performance, 128K context).

gpt-3.5-turbo: $0.50/1M input tokens, $1.50/1M output tokens (dialog-optimized, 16K context).

o1-preview: $15.00/1M input tokens, $60.00/1M output tokens (advanced reasoning, 128K context).

o1-mini: $3.00/1M input tokens, $12.00/1M output tokens (reasoning, cost-effective, 128K context).

 

Example Usage

 

AIU.GenerateFile|A futuristic cityscape|C:\Images\city.png|$$PAT|1

DBP.Image saved at: $$PAT

 

This generates an image of a futuristic cityscape, saves it to C:\Images\city.png, stores the path in $$PAT, and copies it to the clipboard.

 

Illustration

 

┌────────────────────────────┐

│ Prompt: "Futuristic city"  │

├────────────────────────────┤

│ File: C:\Images\city.png   │

└────────────────────────────┘

The command saves the generated image to a local file.

 

Syntax

 

AIU.GenerateFile|P1|P2[|P3][|P4]

AIU.Generate_File|P1|P2[|P3][|P4]

 

Parameter Explanation

 

P1 - The text prompt describing the image to generate (required).

P2 - The file path where the image will be saved (required).

P3 - (Optional) The variable to store the file path. If omitted, the path is placed on the Top of Stack (TOS).

P4 - (Optional) A flag (1 or 0). If 1, the file path is copied to the clipboard; if 0 or omitted, it is not.

 

Example

 

AIU.SetImageQuality|high

AIU.GenerateFile|A cozy cabin in the woods|C:\Images\cabin.png|$$PAT|1

DBP.File saved at: $$PAT

ENR.

 

Remarks

 

- The target directory must exist or be writable; the command does not create directories.

- Requires a valid API key set via AIU.SetKey.

 

Limitations

 

- Disk space and write permissions are required at the specified path.

- Subject to OpenAI’s image generation limits and costs.

 

See also:

 

AIU.GenerateURL

AIU.SetImageSize

AIU.SetImageResponseFormat

Image Generation