How To Call It
AI is a global table: call its functions with a dot (AI.<method>(...)), not a colon.
Sends a prompt with a Base64 image to the AI provider; returns a table with the same fields as AI.ask.
Documented for app version 1.0.51Updated:
AI is a global table: call its functions with a dot (AI.<method>(...)), not a colon.
Use this to analyze a screenshot with a cloud model. The local pixel mode of MH Visual Decision is a separate flow.
prompt and imageBase64 are required. A nil providerId uses app settings. mimeType must match the image. credentialReference accepts nil or a saved Visual Decision reference, never a raw API key. timeoutMs is bounded to 1000–60000 ms.
Check ok, text, errorCode and error in the result table. This call does not tap the screen. Visual Decision retries, thresholds and outcome branches require additional Lua logic. Bound request frequency in loops.
The snippet below is a starter pattern that can be applied directly in runtime flow.
-- Uses the configured provider and credential; do not embed API keys.
local image = Capture.regionToBase64(Region(), "jpeg", 60)
if image ~= nil and image ~= "" then
local response = AI.askVision("Describe the visible targets", image, nil, "image/jpeg", nil, 30000)
if response.ok then print(response.text) else print(response.errorCode, response.error) end
else print(System.lastScanError()) endFrom foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.
-- Uses the configured provider and credential; do not embed API keys.
local image = Capture.regionToBase64(Region(), "jpeg", 60)
if image ~= nil and image ~= "" then
local response = AI.askVision("Describe the visible targets", image, nil, "image/jpeg", nil, 30000)
if response.ok then print(response.text) else print(response.errorCode, response.error) end
else print(System.lastScanError()) endlocal stepOk = true
-- Uses the configured provider and credential; do not embed API keys.
local image = Capture.regionToBase64(Region(), "jpeg", 60)
if image ~= nil and image ~= "" then
local response = AI.askVision("Describe the visible targets", image, nil, "image/jpeg", nil, 30000)
if response.ok then print(response.text) else print(response.errorCode, response.error) end
else print(System.lastScanError()) end
if stepOk then
wait(200)
endlocal ok, err = pcall(function()
-- Uses the configured provider and credential; do not embed API keys.
local image = Capture.regionToBase64(Region(), "jpeg", 60)
if image ~= nil and image ~= "" then
local response = AI.askVision("Describe the visible targets", image, nil, "image/jpeg", nil, 30000)
if response.ok then print(response.text) else print(response.errorCode, response.error) end
else print(System.lastScanError()) end
end)
if not ok then
print("API step failed: AI.askVision: " .. tostring(err))
requestStop()
end-- Use configured credentials and handle failed responses before continuing.
local function run_askvision_step()
-- Uses the configured provider and credential; do not embed API keys.
local image = Capture.regionToBase64(Region(), "jpeg", 60)
if image ~= nil and image ~= "" then
local response = AI.askVision("Describe the visible targets", image, nil, "image/jpeg", nil, 30000)
if response.ok then print(response.text) else print(response.errorCode, response.error) end
else print(System.lastScanError()) end
end
local ok, err = pcall(run_askvision_step)
if not ok then
toast("Step failed")
print(err)
end-- Uses the configured provider and credential; do not embed API keys.
local image = Capture.regionToBase64(Region(), "jpeg", 60)
if image ~= nil and image ~= "" then
local response = AI.askVision("Describe the visible targets", image, nil, "image/jpeg", nil, 30000)
if response.ok then print(response.text) else print(response.errorCode, response.error) end
else print(System.lastScanError()) end