|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Image Generation > AIU. - OpenAI API Operations |
SPR Script Language
AIU.AskVision
Sends a text prompt and an image to a vision-capable AI model for analysis.
Intention
The AIU.AskVision command allows your robot to "see" by sending an image along with a text prompt to a multimodal AI. This is essential for tasks that require visual understanding, such as describing a screenshot, identifying objects in a picture, or reading text from an image. The command requires the image to be Base64 encoded. The AI's text-based response is then returned.
It’s like asking your robot a question and showing it a picture at the same time—AIU.AskVision is the core command for all vision-based analysis.
Syntax
AIU.AskVision|$$PRM|$$B64|$$MIM[|$$RET[|$$CLP]]
Parameter Explanation
P1 - $$PRM - (Variable, String, Required)
The text prompt that accompanies the image (e.g., "What is in this picture?").
P2 - $$B64 - (Variable, String, Required)
A string containing the Base64-encoded image data, without the "data:image/...;base64," prefix. Use the HTP.ToBase64 command to generate this.
P3 - $$MIM - (Variable, String, Required)
The MIME type of the image (e.g., "image/png", "image/jpeg", "image/webp").
P4 - $$RET - (Variable, String, Optional)
The variable to store the AI's text response. If omitted, the response is not stored.
P5 - $$CLP - (Numeric, Optional)
Clipboard flag. 1 = Force copy result to clipboard. 0 = Force disable copy. If omitted, the global setting from AIU.SetClipOutput is used.
Examples
'***********************************
' AIU.AskVision - Sample 1: Describe an image
'***********************************
VAR.$$PTH=?path\my_photo.png
VAR.$$PRM=What is in this image?
VAR.$$MIM=image/png
' Encode the image to Base64
HTP.ToBase64|$$PTH|$$B64
' Set the API key and call the vision model
AIU.SetKey|sk-YourSecretKeyHere
AIU.AskVision|$$PRM|$$B64|$$MIM|$$RES
MBX.AI Vision Response:|$$RES
END.
Remarks
- This command returns the AI's text response as a UTF-8 string. On failure, it returns an empty string. Check AIU.GetLastError for error details.
- The alias AIU.AskV can be used instead of AIU.AskVision.
- Ensure the model selected with AIU.SetModel supports vision capabilities (e.g., "gpt-4o").
See also:
• AIU.Chat