AIU. - Artificial Intelligence Utility

<< Click to Display Table of Contents >>

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

AIU. - Artificial Intelligence Utility

AIU.SetImageResponseFormat

Previous Top Next


MiniRobotLanguage (MRL)

 

AIU.SetImageResponseFormat
Set the Response Format for Generated Images

 

Intention

 

SetImageResponseFormat Command: Configuring Image Output Format
 
The SetImageResponseFormat command allows you to specify how generated images from the OpenAI DALL-E 3 API are returned, either as a URL or as a base64-encoded JSON string.

This customization enhances flexibility in handling image data within your automation scripts.

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

 

What is the SetImageResponseFormat Command?

 

This command sets the format in which the OpenAI DALL-E 3 API returns generated images when using commands like AIU.GenerateURL or AIU.GenerateFile.

Supported formats are 'url' (default) for a temporary URL to the image, or 'b64_json' for a base64-encoded image embedded in a JSON response.

 

Why Do You Need It?

 

Setting the image response format is essential for:

Flexibility: Choose between lightweight URL references or direct image data access.

Workflow Integration: Match the format to your script’s needs (e.g., downloading vs. embedding).

Efficiency: Optimize processing based on whether you need immediate data or a reference.

 

How to Use the SetImageResponseFormat Command?

 

Provide a string parameter specifying the desired format: 'url' or 'b64_json'. This setting applies to subsequent image generation calls via the DALL-E 3 API.

For example, setting it to 'b64_json' returns the image data directly, which can be useful for immediate processing without additional HTTP requests.

 

Example Usage

 

AIU.SetImageResponseFormat|url

AIU.GenerateURL|Create a futuristic city|$$URL

DBP.Image URL: $$URL

 

This sets the response format to 'url' and generates an image, returning a URL.

 

Illustration

 

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

│ Response Format      │

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

│ url or b64_json      │

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

Choose how DALL-E 3 returns your generated images.

 

Syntax

 

AIU.SetImageResponseFormat|P1

AIU.Set_ImageResponseFormat|P1

 

Parameter Explanation

 

P1 - A string specifying the response format: 'url' (returns a temporary URL) or 'b64_json' (returns base64-encoded image data in JSON).

 

Example

 

AIU.SetImageResponseFormat|b64_json

AIU.GenerateFile|Draw a cat|$$PAT|$$RES

DBP.Base64 JSON Response: $$RES

ENR.

 

Remarks

 

- The default format is 'url' if not explicitly set.

- URLs returned by 'url' format are temporary and expire after a short period (typically 1 hour with DALL-E 3).

 

Limitations

 

- Only 'url' and 'b64_json' are supported by DALL-E 3 as of March 18, 2025.

- Invalid format values may result in API errors during image generation.

 

See also:

 

AIU.Get_ImageResponseFormat

AIU.Generate_URL

AIU.Generate_File

Image Generation Settings