# CLI update: a separate key for each coding agent

> The anyr CLI can now give Claude Code, Codex, OpenCode and the other coding agents it launches their own API key or their own account, with plain commands. Each agent gets its own spend, limits and revocation.

- Date: November 2, 2026
- Category: product
- HTML: https://anyrouter.dev/blog/cli-a-key-per-coding-agent

## Why one key per agent

One AnyRouter key can drive every coding agent. That is the easy setup, but it pools everything. All agents share one spend limit and one line of usage, and revoking the key signs every agent out.

With a key per agent, each agent gets its own limit, its own usage, and its own revocation. If one agent runs away, it stops at its own limit. If you rotate one key, the other agents keep working.

## Give each agent its own key or account

```bash
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 with
```

`keys create --agent` mints the key in the account that agent uses, prints it once, and saves it for that agent. The usual scope flags work, so `--limit`, `--reset`, `--endpoints` and `--expires` set the agent's cap and lifetime.

`keys set --agent <agent> -` reads a key from stdin. A key typed as an argument is refused, so it stays out of your shell history. `account use <name> --agent` binds a whole account instead of one key.

`--agent` takes any agent the CLI launches, including `claude`, `codex`, `opencode`, `grok` and `pi`.

## See which key each agent uses

`anyr auth status` (or `anyr whoami`) adds one line per agent that has its own key or account. Each line shows the masked key and where it comes from:

```text
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
```

The view uses the same lookup as a launch. When `ANYROUTER_API_KEY` is set, every line says so, because that variable overrides every agent's key. `--json` returns the same rows in `agents`. Full keys are never printed.

## Undo it

```bash
anyr keys unset --agent codex                # codex goes back to its account
anyr account use --agent opencode --clear    # opencode uses the active account
```

A removed key keeps working until you revoke it, so `keys unset` prints the `anyr keys revoke` command for it. Renaming an account keeps its agents bound, and removing an account unbinds them.

## Try it

These commands ship in the next `anyr` release. Run `anyr upgrade` to get it.

Docs: [accounts and keys](https://anyrouter.dev/docs/cli/accounts-and-keys).
