下一步动作接口 (POST /v1/act)
POSThttps://llm.manina.ai/v1/act
为正在 iPhone 或 Android 真机上运行的任务预测下一步单步操作。发送当前屏幕截图、自然语言目标、编号步骤计划以及可选的近期动作历史后,Manina-4B-Lite-1.0 会返回动作类型(op)、当前画面对应的计划步骤(step),并在需要点击或定向滑动时返回原图像素坐标 point 与边界框 box。注意 TYPE、KEY 与 OPEN 仅指示“何时、在何处”输入文字、按键或启动应用,具体输入的文本或应用名称由调用方或规划器提供。每次 HTTP 200 成功返回按 $0.0003/次($0.30 / 1,000 次)计费,出错永不计费。
AI 助手与 CLI 快捷接入: 把 manina.ai/llms-full.txt 直接发给你的 AI 编程助手即可自动生成闭环执行代码;或直接安装 npm i -g manina 运行 manina run “打开设置,进入无线局域网”。
import base64import jsonimport osimport urllib.request
with open("screenshot.png", "rb") as f: image_b64 = base64.b64encode(f.read()).decode("ascii")
payload = { "image": image_b64, "goal": "打开无线局域网设置", "plan": "1. 打开设置\n2. 点击无线局域网", "history": '{"action": "open", "app": "设置"} -> screen changed',}
req = urllib.request.Request( "https://llm.manina.ai/v1/act", data=json.dumps(payload).encode("utf-8"), headers={ "Authorization": f"Bearer {os.environ['MANINA_API_KEY']}", "Content-Type": "application/json", }, method="POST",)
with urllib.request.urlopen(req) as resp: step = json.loads(resp.read().decode("utf-8"))
print(step["op"], step["step"], step.get("point"))import { readFileSync } from 'node:fs';
const response = await fetch('https://llm.manina.ai/v1/act', { method: 'POST', headers: { Authorization: `Bearer ${process.env.MANINA_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ image: readFileSync('screenshot.png').toString('base64'), goal: '打开无线局域网设置', plan: '1. 打开设置\n2. 点击无线局域网', history: '{"action": "open", "app": "设置"} -> screen changed', }),});
const step = await response.json();console.log(step.op, step.step, step.point);( printf '{"goal":"打开无线局域网设置",' printf '"plan":"1. 打开设置\\n2. 点击无线局域网",' printf '"image":"' base64 < screenshot.png | tr -d '\n' printf '"}') | curl -sS https://llm.manina.ai/v1/act \ -H "Authorization: Bearer $MANINA_API_KEY" \ -H "Content-Type: application/json" \ --data-binary @-请求头 (Headers)
Section titled “请求头 (Headers)”| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
Authorization |
string | 是 | 正式环境传 Bearer hsk_live_…,Sandbox 环境传 Bearer hsk_test_…。可在账户中创建密钥(API 密钥 →)。 |
Content-Type |
string | 是 | 必须为 application/json。请求体最大 12 MB。 |
请求体 (JSON Body)
Section titled “请求体 (JSON Body)”传入未定义字段会返回 400 invalid_request。
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image |
string | 是 | 截图的 base64 字符串,支持 PNG、JPEG、WebP(支持 data:image/…;base64, 前缀与换行符)。服务端自动缩放为 540 像素宽 JPEG。 |
goal |
string | 是 | 自然语言任务目标,去首尾空白后 1 至 1,000 个字符。 |
plan |
string | null | 否 | 编号步骤列表(格式如 1. …、2) … 或 3、…,每行一步),最多 4,000 个字符。省略或传 null 时默认为 1. <goal>(传入清晰的编号计划能显著提升多步跟踪准确度)。 |
history |
string | null | 否 | 最近已执行的若干步(建议保留最近 5 步,按时间从早到晚排列,每行一步),最多 8,000 个字符。第一步执行前可省略或传 null。 |
history 行格式
Section titled “history 行格式”每一行由“已执行的 JSON 动作(其中点击坐标归一化为图片宽高的 0 到 1000)”与“执行后画面是否变化”组成:
{"action": "open", "app": "Settings"} -> screen changed{"action": "tap", "x": 478, "y": 250} -> screen did NOT change支持的 action 结构:
{"action": "tap", "x": 0..1000, "y": 0..1000}{"action": "swipe", "direction": "up" | "down" | "left" | "right"}{"action": "type", "text": "..."}{"action": "open", "app": "..."}{"action": "set_time", "time": "07:00"}{"action": "back"}·{"action": "home"}·{"action": "wait"}·{"action": "key"}
支持的结果后缀:-> screen changed、-> screen did NOT change 或 -> unknown。
op 动作类型枚举(共 12 个取值)
Section titled “op 动作类型枚举(共 12 个取值)”| 枚举值 | 含义 | 坐标返回 (point / box) |
|---|---|---|
TAP |
点击目标界面控件 | 目标可见时返回像素坐标与框 |
TYPE |
在当前焦点或目标输入框输入文字(具体文本由调用方提供) | 可选返回输入框位置 |
KEY |
按下键盘功能键,如回车、搜索或退格(具体按键由调用方提供) | null 或可选目标框 |
SWIPE_UP |
向上滑动内容(手指自下而上移动,浏览下方内容) | 可选起点框;缺省全屏滑动 |
SWIPE_DOWN |
向下滑动内容(手指自上而下移动) | 可选起点框;缺省全屏滑动 |
SWIPE_LEFT |
向左滑动(轮播图、标签页切换) | 可选起点框;缺省水平滑动 |
SWIPE_RIGHT |
向右滑动(轮播图或侧滑返回) | 可选起点框;缺省水平滑动 |
HOME |
回到手机主屏幕 | null |
BACK |
返回上一级页面(Android 返回键或 iOS 返回操作) | null |
WAIT |
短暂等待加载动画或转场完成 | null |
DONE |
当前屏幕已达成任务目标 | null |
OPEN |
按名称直接打开应用(通过 Spotlight 或 adb 启动,应用名由调用方提供) |
null |
step 步骤对齐取值
Section titled “step 步骤对齐取值”| 取值 | 含义 |
|---|---|
"step 1" .. "step 999" |
模型判定当前正在执行的 plan 行号(从 1 开始计数) |
"done" |
计划中的所有步骤均已完成 |
"other" |
当前出现了计划外的阻塞界面(例如权限弹窗、广告遮罩、Cookie 提示框) |
model 模型标识枚举
Section titled “model 模型标识枚举”"manina-act-1"
{ "id": "act_2f7c9a1e0b6d4f3a", "op": "TAP", "op_prob": 0.93, "step": "step 2", "step_prob": 0.88, "step_text": "Tap Wi-Fi", "box": [239, 478, 717, 956], "point": {"x": 478, "y": 717}, "present_prob": 0.97, "confidence": 0.91, "plan": "1. Open Settings\n2. Tap Wi-Fi", "image": {"width": 1290, "height": 2796}, "latency_ms": 284, "model": "manina-act-1"}| 字段 | 类型 | 说明 |
|---|---|---|
id |
string | 本次调用唯一 ID(act_ 加 16 位十六进制字符)。 |
op |
string | 预测的下一步动作,取值为上方 12 个 op 枚举之一。 |
op_prob |
number | 0 到 1:模型对 op 动作类型的概率分数。 |
step |
string | "step N"、"done" 或 "other"。 |
step_prob |
number | null | 0 到 1:模型对当前 step 判定的概率分数。 |
step_text |
string | 匹配到的计划行文本(done 或 other 时为空字符串)。 |
box |
integer[4] | null | [x1, y1, x2, y2] 原图整数像素边界框;step 为 "done" 或无空间目标时为 null。 |
point |
object | null | {"x": integer, "y": integer} 原图像素点击中心点,或 null。 |
present_prob |
number | null | 0 到 1:存在边界框时的目标在屏分数,否则为 null。 |
confidence |
number | null | 0 到 1:边界框空间确定性分数,否则为 null。 |
plan |
string | 服务端解析使用的标准化编号计划文本。 |
image |
object | {"width": integer, "height": integer} 上传截图解码后的像素宽高。 |
latency_ms |
integer | 服务端处理耗时(毫秒)。 |
model |
string | "manina-act-1"。 |
客户端闭环接入建议
Section titled “客户端闭环接入建议”- 置信度门控: 建议仅在
op_prob >= 0.7,且执行TAP时满足present_prob >= 0.5和confidence >= 0.5的前提下自动点击或滑动;把握不足时交回上层规划器或提示人工介入。 - 弹窗恢复(
step: "other"): 高置信度下可允许模型自动关闭意外弹窗,但建议限制连续"other"步数上限(如最多连续 5 步),超出后触发重规划避免死循环。 - 高风险操作保护: 涉及支付、转账、发送消息或删除数据的步骤,切勿无确认自动点击。
- 错误码与限流: 详见错误码与限流。
