为什么每个智能体一把 key
一把 AnyRouter key 就能驱动所有编程智能体。这样配置最省事,但所有东西都混在一起:所有智能体共用一个花费上限、一条用量记录,吊销这把 key 会让所有智能体一起掉线。
每个智能体一把 key 后,各自有自己的额度、用量和吊销。某个智能体失控时,它只会停在自己的额度上。轮换其中一把 key,其他智能体照常工作。
给每个智能体配自己的 key 或账号
anyr keys create --agent claude --limit 20 # mint a key for Claude Code and save it for it
pbpaste | anyr keys set --agent codex - # store a key you copied from the dashboard
anyr account use work --agent opencode # OpenCode launches with the work account
anyr auth status # the key each agent launches withkeys create --agent 在该智能体使用的账号里创建 key,只显示一次,并为该智能体保存。常用的范围参数照样可用,--limit、--reset、--endpoints 和 --expires 设置该智能体的上限和有效期。
keys set --agent <agent> - 从 stdin 读取 key。直接写在参数里的 key 会被拒绝,这样它不会留在 shell 历史里。account use <name> --agent 则是绑定整个账号,而不是一把 key。
--agent 接受 CLI 能启动的任何智能体,包括 claude、codex、opencode、grok 和 pi。
查看每个智能体用哪把 key
anyr auth status(或 anyr whoami)会为每个有自己 key 或账号的智能体多显示一行,列出打码后的 key 和它的来源:
claude sk-ar-v1-k7m2p…9xq4 · agent key
codex sk-ar-v1-r3c8w…2hd7 · agent key
opencode sk-ar-v1-a9t5n…6vbe · agent account work这个视图和启动时用的是同一套查找逻辑。设置了 ANYROUTER_API_KEY 时,每一行都会标明,因为这个变量会覆盖所有智能体的 key。--json 在 agents 中返回同样的行。完整 key 从不打印。
撤销
anyr keys unset --agent codex # codex goes back to its account
anyr account use --agent opencode --clear # opencode uses the active account移除的 key 在吊销前仍然有效,所以 keys unset 会打印对应的 anyr keys revoke 命令。重命名账号时,绑定的智能体会跟着走;删除账号时,绑定会被解除。
试一试
这些命令随下一个 anyr 版本发布。运行 anyr upgrade 即可获取。
文档:账号与 key。
相关文章
CLI 更新:多账号、终端管 key、agent 互相委派
AnyRouter CLI 现在可以并排管理多个账号,不进 dashboard 也能管 API key,用两个模型跑「先计划再实现」流水线,并让 coding agent 互相交活——一跳、一把 key。
Run coding agents through one gateway
Point Claude Code, Codex, OpenCode, Cursor, or any OpenAI-compatible tool at AnyRouter and get one key for every model, unified billing, per-request audit logs, and app attribution. Two environment variables — or one npx command with the anyr CLI launcher.
Run Claude Code on AnyRouter — wrapper script or CLI
Route Claude Code through AnyRouter in two ways: a wrapper that installs itself and maps Opus, Sonnet, and Haiku to one catalog model (override with --model), or the anyr CLI launcher. One key, unified billing, audit logs.