参考
CLI
qi 命令与面板使用同一个 API。可供个人、cron 任务或 CI 流水线使用。
安装
@sumeria.ai/qi 包会安装 qi 和 qi-mcp 命令。需要 Node 20 或更高版本。
npm install -g @sumeria.ai/qi # the qi and qi-mcp commands, Node 20+
qi --help凭证
qi auth login 会先询问你在哪里工作——你的组织、通过邮箱查找,或个人账户(Free 或 Pro)——然后打开浏览器让你批准这台电脑:密钥会被创建并保存在你的用户目录中,仅你可读。若要改用 API Keys 中的密钥,运行 qi auth login --key;输入时不会显示。密钥形如 sk_live_tenant.…,自带租户,因此无需输入租户或 URL。
qi auth login
# Where do you work? your organization / find it by email / personal account (Free, Pro)
# The browser opens: approve this computer and the key is created and saved for you
qi auth status # account, branch and key in use (the key is masked)
qi auth login --tenant acme # skip the question: your organization's name
qi auth login --key # paste a key from API Keys instead (not echoed)
qi auth switch # sign in to another account; keeps the current one if it fails
qi auth switch --branch # another branch of your organization
qi auth logout # forget the key on this machine在 CI 中,环境变量优先于文件:不会向磁盘写入任何内容。
# CI: the key comes from the pipeline's secrets, never from a file or a flag.
# GitHub Actions, for example:
env:
QI_API_KEY: ${{ secrets.QI_API_KEY }}
# QI_TENANT only for older keys (sk_live_<hex>) that do not carry their tenant
# QI_BASE_URL advanced: point at another environment特意不提供 API 密钥参数:命令行参数会留在你的 shell 历史中,并且在进程运行期间出现在机器上所有用户都能读取的进程列表中。
环境变量
| 变量 | 用途 |
|---|---|
QI_API_KEY | 密钥。 |
QI_TENANT | 仅用于不含租户的旧密钥(sk_live_ 后接十六进制)。 |
QI_BASE_URL | 高级:指向其他环境。通常不需要。 |
QI_CONFIG_PATH | 可选:移动配置文件(及其旁边的 state.json)。 |
QI_STATE_PATH | 可选:移动 qi watch 的状态文件。 |
QI_LANG | 可选:CLI 语言(en、es…)。 |
命令
qi auth login # sign in from the browser and save the key
qi auth status # which account and key are in use (masked)
qi auth switch [--branch] # another account, or another branch
qi auth logout # forget the key on this machine
qi doctor # config, API, plan, modules, name rules, ffmpeg
qi usage # plan, QI tokens used, period end
qi lang [code] # CLI language: en es zh pt fr de ja
qi upload audio <file|folder...> # recordings (Speech Analytics)
qi upload text <file|folder...> # conversations (Text Analytics)
qi upload bot <file|folder...> --bot <p> # bot conversations (Bot Analytics)
qi validate <file|folder...> # check names against the tenant's rules
qi rename <file|folder...> [--apply] # rename local files with --prefix/--suffix/--key
qi convert <file|folder...> --to <fmt> # convert audio with the system's ffmpeg
qi forms list [--type audio|text|bot] # forms and the key uploads use
qi bots list # bot profiles (plans with Bot Analytics)
qi interactions list [--all] # analysed conversations
qi interactions get <id> # status, dialogue, answers
qi interactions wait <id> # until processing finishes
qi interactions export --format csv|json # [--with-answers]
qi watch <folder...> # upload new files as they appear
qi schedule print --every <cron> -- ... # print a cron line or a schtasks command较长的文件列表会自动拆分为每批 10 个,一个被拒绝的文件不会拖垮其余文件:它会被单独剔除,批次重新发送。
上传成功表示文件已被接受并排入队列。转写和分析需要几分钟:qi interactions wait 会阻塞,直到所有阶段都完成。
选项
列出与导出
| 选项 | 用途 |
|---|---|
--limit <n> --page <n> | 每页数量(最大 200)和页码,从 0 开始。 |
--from <date> --to <date> | ISO 日期,必须同时提供。 |
--type <audio|text> | audio 或 text。默认为 audio。 |
--agent-type <human|bot> | human 或 bot:由谁应答。 |
--form <id> | 仅限用该表单(id)评估的互动。 |
--all | 所有页,而非仅一页。 |
--format <csv|json> --out <file> | 导出:csv 或 json,输出到文件或标准输出。 |
--with-answers | 导出:附上每个互动的答复。 |
--timeout <s> --interval <s> | wait 和 watch 的时间,单位为秒。 |
--json | JSON 输出,供脚本使用。 |
文件与名称
| 选项 | 用途 |
|---|---|
-r, --recursive | 进入子文件夹。 |
--include <glob> --exclude <glob> | 可重复使用,按文件名匹配。 |
--prefix <p> --suffix <s> | 以不同的名称上传(或重命名);磁盘上的文件保持不变。 |
--key <KEY> --key-from-folder | 以 _KEY 形式追加的表单键(共享租户),或文件夹名称。 |
--company <c> | 独立租户:同时检查公司段。 |
上传
| 选项 | 用途 |
|---|---|
--form <key|id> | 按键或 id 指定表单。 |
--analysis <full|transcript> | 共享租户:full 或 transcript。 |
--bot <bot_id|name> | 按 bot_id 或名称指定机器人配置档案(upload bot)。 |
--concurrency <n> | 同时进行的 10 个文件的请求数。默认为 2。 |
--retries <n> | 对 429 和 5xx 的重试次数,采用指数退避。默认为 3。 |
--dry-run | 打印最终名称以及会被拒绝的内容;不发送任何内容。 |
--convert <mp3|wav|…> | 上传前用 ffmpeg 转换。 |
-i, --interactive | 从菜单中选择表单、机器人和分析方式。 |
转换
| 选项 | 用途 |
|---|---|
--to <mp3|wav|flac|ogg|m4a> | 输出格式:mp3、wav、flac、ogg 或 m4a。 |
--bitrate <64k> --mono --sample-rate <hz> --trim-silence --normalize | 转换后音频的设置。 |
--out-dir <dir> | 输出文件夹。 |
-y, --yes | 不询问直接安装 ffmpeg。没有终端时,CLI 只会打印命令:绝不会静默安装。 |
监视与计划
| 选项 | 用途 |
|---|---|
--type <audio|text|bot> | watch 渠道:audio、text 或 bot。 |
--interval <s> | 检查文件夹的频率,单位为秒。默认为 60。 |
--settle <s> | 文件大小需保持不变多少秒后才会被处理。默认为 2。 |
--done-dir <dir> | 将已发送的内容移到那里。 |
--once | 只运行一轮,供调度器使用。 |
--every "<cron>" | schedule print 使用的 cron 表达式。 |
--platform <linux|darwin|win32> | 为哪个系统打印命令。 |
--name <task> | 计划任务的名称。 |
常用示例
上传文件夹
遍历子文件夹,按模式筛选,并为整个批次选定表单。
# A folder, recursively, only .mp3, evaluated against the form VENTAS
qi upload audio ./grabaciones -r --include "*.mp3" --form VENTAS
# Shared tenants: transcript only, no evaluation
qi upload audio ./grabaciones --analysis transcript
# Choose form, bot and analysis from a menu
qi upload audio ./grabaciones -i前缀、后缀和键
它们改变的是每个文件发送时所用的名称,而不是文件本身。请先尝试 --dry-run;只有 qi rename --apply 会在磁盘上重命名。
# Preview the names files would be sent under; nothing is uploaded
qi upload audio ./grabaciones --prefix dev_ --suffix _lote2 --key VENTAS --dry-run
# Every reason a name is refused, per file (exit 1 if any is bad)
qi validate ./grabaciones
# Rename on disk: preview first, then --apply
qi rename ./grabaciones --prefix acme_
qi rename ./grabaciones --prefix acme_ --apply上传前转换
使用已安装的 ffmpeg。如果没有,在终端中会先询问再安装(根据系统使用 winget、brew、apt 或 dnf)。
# Convert, then upload the result (system ffmpeg, into a temporary folder)
qi upload audio ./wav --convert mp3
# Only convert
qi convert ./wav --to mp3 --bitrate 64k --mono --sample-rate 16000 --trim-silence --normalize
qi convert ./wav --to mp3 --out-dir ./mp3监视文件夹
它会在 ~/.qi/state.json 中记住已发送的内容(路径、大小和修改时间):文件只发送一次,仅在发生变化时再次发送。失败的文件会在下一轮重试。
# Upload what lands in ./inbox, every 60 s, and move it to ./sent
qi watch ./inbox --interval 60 --done-dir ./sent --form VENTAS
# One round only, for a scheduler
qi watch ./inbox --once使用 cron 或任务计划程序进行调度
qi schedule print 会打印 crontab 行或 schtasks /Create 命令,其中包含 node 和 CLI 的绝对路径。它不会安装任何内容:需要你自己添加这一行。
# Linux / macOS: prints the crontab line
qi schedule print --every "0 2 * * *" -- upload audio /var/recordings --form VENTAS
# Windows: prints the schtasks /Create command (daily, weekly, hourly or every N minutes)
qi schedule print --every "0 2 * * *" --platform win32 --name qi-nightly -- upload audio D:\grabaciones读取并导出结果
CSV 遵循 RFC 4180,以 =、+、- 或 @ 开头的文本前会加上撇号,使电子表格只显示它而不执行它。
qi interactions list --limit 25 --from 2026-09-01 --to 2026-09-08
qi interactions list --all --agent-type bot --json
qi interactions export --format csv --out week.csv --from 2026-09-01 --to 2026-09-08 --with-answers
qi interactions export --format json --with-answers > all.json退出码
| 代码 | 含义 |
|---|---|
0 | 正常。 |
1 | 请求失败:原因输出在 stderr 上。 |
2 | 命令有误。 |
为 cron 和 CI 而设计。部分上传会以 1 退出,并逐个文件说明原因:
FAILED 1 accepted · 1 rejected · 0 failed
├─ SUCCEEDED call-001.mp3
└─ REJECTED notas.mp3 missingFields: 1 fields, 7 required: tenant_company_YYYYMMDD_HHMMSS_callId_clientId_agentId# Nightly upload, alerting only when it actually breaks
qi upload audio /var/recordings/$(date +%F) || notify-team "QI upload failed"智能体提示词
将此内容粘贴到编程智能体(Claude Code、Cursor…)中,让它把 CLI 接入你的项目。
You are integrating the Sumeria Quality Intelligence CLI (@sumeria.ai/qi) into this project.
1. Install: npm install -g @sumeria.ai/qi (or add it as a dev dependency for CI). Node 20+.
2. Authenticate once with "qi auth login": it asks where the user works and approves the
computer in the browser; the key is stored outside the repo. In CI, provide QI_API_KEY
from the pipeline's secrets instead — never as a command-line flag or in a file that
could get committed. QI_TENANT is only needed for older keys (sk_live_<hex>).
3. Use "qi upload audio <path>" and "qi upload text <path>" to send files or folders; they
go in requests of 10 and are retried on 429/5xx.
4. A successful upload only means the files were accepted and queued — use
"qi interactions wait <id>" or poll "qi interactions list" to see when they were analysed.
5. Exit codes: 0 fine, 1 the request failed (reason on stderr), 2 the command was wrong.
6. Wire this into our build/release process: <tell the agent where the files to upload
live in this repo, and when the command should run>.
Ask before writing any credential to a file that could be committed.