屏幕定位接口 (POST /v1/locate)
POSThttps://llm.manina.ai/v1/locate
在一张 iPhone 或 Android 手机截图中查找单条自然语言指令所描述的界面控件。接口按你上传原图的整数像素返回点击中心点 point、元素边界框 box、目标当前是否在屏 on_screen 以及存在度与框置信度分数。当 on_screen 为 false 时,point 和 box 仅为模型的最佳猜测,请勿直接点击,应改为滑动页面、返回上一页或更换描述。每次 HTTP 200 成功返回按统一单价($0.0003/次)计费,所有报错均不计费。
AI 助手与 CLI 快捷接入: 把 manina.ai/llms-full.txt 直接喂给 Claude Code、Codex 或 Cursor 即可自动生成接入代码;或直接安装 npm i -g manina 在终端运行 manina find “设置图标” –tap。
import base64import jsonimport osimport urllib.request
with open("screenshot.png", "rb") as f: image_b64 = base64.b64encode(f.read()).decode("ascii")
req = urllib.request.Request( "https://llm.manina.ai/v1/locate", data=json.dumps({ "image": image_b64, "text": "设置图标", "min_present": 0.5, }).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: result = json.loads(resp.read().decode("utf-8"))
if result["on_screen"]: print("点击像素:", result["point"], "边界框:", result["box"])import { readFileSync } from 'node:fs';
const response = await fetch('https://llm.manina.ai/v1/locate', { method: 'POST', headers: { Authorization: `Bearer ${process.env.MANINA_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ image: readFileSync('screenshot.png').toString('base64'), text: '设置图标', min_present: 0.5, }),});
const result = await response.json();if (result.on_screen) { console.log('点击像素:', result.point, '边界框:', result.box);}( printf '{"text":"设置图标","image":"' base64 < screenshot.png | tr -d '\n' printf '"}') | curl -sS https://llm.manina.ai/v1/locate \ -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/png;base64,(或 jpeg / webp)前缀及换行符,服务端会自动清理。支持最高约 8,900 万像素的原图。 |
text |
string | 是 | 要查找的单个控件自然语言描述,去除首尾空白后 1 至 1,000 个字符,支持中英文及任意语言(如 "设置图标"、"右上角搜索按钮")。 |
min_present |
number | 否 | on_screen 判定阈值,取值范围 0 到 1,默认 0.5。仅当 present_prob >= min_present 且 confidence >= min_present 时,on_screen 才为 true。误触代价较高时可调高此值。 |
{ "id": "loc_2f7c9a1e0b6d4f3a", "point": {"x": 1203, "y": 330}, "box": [1112, 266, 1294, 394], "on_screen": true, "present_prob": 0.998, "confidence": 0.93, "image": {"width": 1320, "height": 2868}, "latency_ms": 268, "model": "manina-locate-1"}| 字段 | 类型 | 说明 |
|---|---|---|
id |
string | 本次调用唯一 ID(loc_ 加 16 位十六进制字符),排查问题时可提供给技术支持。 |
point |
object | {"x": integer, "y": integer}:边界框中心点,单位为你上传原图的整数像素。on_screen 为 true 时点击该点。 |
box |
integer[4] | [x1, y1, x2, y2]:元素边界框,原图整数像素,已裁剪限制在 [0, width] 与 [0, height] 范围内。 |
on_screen |
boolean | 当 present_prob >= min_present 且 confidence >= min_present 时为 true;目标不存在、被弹窗遮挡或定位含糊时为 false。 |
present_prob |
number | 0 到 1:目标元素出现在当前屏幕上的可能性分数。 |
confidence |
number | 0 到 1:模型对边界框位置确定性的排序信号(并非严格校准概率,数值越高越可靠)。 |
image |
object | {"width": integer, "height": integer}:上传图片解码后的实际像素宽高。 |
latency_ms |
integer | 服务端从收到请求到生成响应的处理耗时(毫秒,不含客户端网络往返)。 |
model |
string | 实际响应的模型标识。枚举值:"manina-locate-1"。 |
分数解读与坐标使用建议
Section titled “分数解读与坐标使用建议”- 务必用
on_screen控制点击:on_screen为false时切勿盲目点击point,应先上下滑动列表、等待页面加载完成或让上层规划器调整策略。 - 高风险界面调高
min_present: 将min_present从0.5提高到0.7或0.8,可要求模型在“目标存在”与“框位清晰”两项指标上同时具备更高把握。 - 错误码与重试处理: 完整的
400、401、402与503 busy(含Retry-After: 1)说明见错误码与限流。
