ClearCrowds CLI — npm 安装与使用
通过 npm 或 npx 安装 ClearCrowds CLI,在终端完成图片编辑、物体移除、尺寸调整和 OCR 文字识别。
从终端或 AI Agent 处理本地图片。CLI 将你选择的文件上传到 ClearCrowds API,执行指定任务,再将结果下载到你指定的本地路径。
安装
需要 Node.js 20.19 或更新版本。
npm install --global clearcrowds
clearcrowds --help
clearcrowds --version也可以直接运行,无需全局安装:
npx --yes clearcrowds --help这是命令行工具,不是 MCP 服务或 JavaScript SDK。开发者 API 需要已获准使用的项目,消耗独立的 API Credits,不使用个人订阅积分。个人订阅修图请使用连接 Agent。
授权当前设备
在 macOS 上,通过浏览器授权开发者项目:
clearcrowds login
clearcrowds doctor --json
clearcrowds whoami
clearcrowds credits浏览器登录将刷新凭据保存到 macOS 钥匙串。login --no-browser 只显示授权地址,不自动打开浏览器。Linux、Windows 和 CI 请通过环境变量或密钥管理工具配置 CLEARCROWDS_API_KEY;当前浏览器登录仅支持 macOS。不要把密钥粘贴给 Agent。
编辑本地图片
clearcrowds presets --json
clearcrowds edit ./input.jpg --preset remove-crowds --output ./fixed.jpg
clearcrowds erase ./input.jpg --mask ./mask.png --output ./cleaned.jpg
clearcrowds resize ./fixed.jpg --width 1200 --height 630 --output ./social.jpg
clearcrowds ocr detect ./input.jpg --filter all --json
clearcrowds ocr replace --detection DETECTION_ID --candidate CANDIDATE_ID --text "新的文字" --output ./edited.jpg
clearcrowds jobs get JOB_ID --json
clearcrowds jobs cancel JOB_ID --json用 presets 查询当前可用的功能 ID 和价格。edit 支持单张图片且无需额外表单字段的任务。OCR 检测返回的 detection 和 candidate ID 用于 ocr replace。支持 JPG、PNG、WebP 和 HEIF,单张最大 25 MB。
开始付费任务前会检查输出路径。已有文件必须明确使用 --force 才会覆盖,不能用输入图片作为输出路径。API 错误返回非零退出码;--json 输出机器可读错误码。API Credits 不足时不会自动购买。
提交结果不确定时,使用同一个 --idempotency-key 和相同参数重试,或查询原任务。即使下载失败,已经完成的图片处理也可能产生费用;再次创建付费任务前先检查原任务。
配置 Agent 客户端
clearcrowds setup --agent codex其他客户端可使用 claude-code 或 cursor。该命令通过固定版本的 skills 安装器安装包内 Skill,授权 CLI 或使用已有环境凭据,然后检查连接。--no-login 只安装 Skill。单纯安装 npm 包不会安装 Skill 或打开浏览器。
升级和卸载
npm install --global clearcrowds@latest
clearcrowds logout
npm uninstall --global clearcrowds卸载不会撤销 API Key,也不会删除单独安装的 Skill,请分别在开发者控制台和 Agent 客户端管理。本地联调可用 CLEARCROWDS_API_BASE_URL 指向 localhost backend;远程地址必须使用 HTTPS。
