Skip to content

AnyRouter CLI Agent (deprecated)

Deprecated — use anyr with Claude Code, Codex, or another launcher instead.

Deprecated

@anyr/agent is deprecated. Use anyr (install via curl -fsSL https://anyrouter.dev/setup.sh | bash) with Claude Code, Codex, or another launcher instead. The features described below (TUI, --web, --print) remain in source but are no longer published or actively maintained. Sign in with anyr auth login and launch coding agents through the recommended launchers.

Run a fully capable AI coding agent — backed by AnyRouter — with a single command. Your AnyRouter key fronts every provider, so you get automatic failover, unified billing, and access to the whole model catalog. Install the native CLI with curl -fsSL https://anyrouter.dev/setup.sh | bash.

npx @anyr/agent

Quick start

Authenticate

The agent reads your key from ANYROUTER_API_KEY. Get one at anyrouter.dev/dashboard/keys. The free model (anyrouter/free, the default) works without spending credits — the Free plan gets 10 requests/day, and Go or above (a $2/mo subscription, or donate a provider key for free) raises that to 1,000/day.

export ANYROUTER_API_KEY=sk-ar-v1-...

Start a session

Launch an interactive coding session with the default model:

npx @anyr/agent

Or run one-shot

Send a single prompt, print the reply, and exit — handy for scripting:

npx @anyr/agent --print "Explain closures in three sentences"

Options

FlagDefaultDescription
--model <id>anyrouter/freeModel to use for the session
--print <prompt>—One-shot mode: send a prompt, print the reply, and exit
--web—Open the AnyRouter dashboard in your browser
--lang <locale>—Override the display language (e.g. en, ja)
--version—Print the version
--help—Show usage

Choosing a model

Any model available on AnyRouter works. Pass its id to --model:

npx @anyr/agent --model anyrouter/free           # free, no credits
npx @anyr/agent --model z-ai/glm-4.7-flash        # fast + affordable
npx @anyr/agent --model anthropic/claude-opus-4   # most capable
npx @anyr/agent --model anyrouter/coding          # routes to your BYOK coding model

Run npx @anyr/agent --model anyrouter/free to explore without spending credits (10 requests/day on Free, 1,000/day on Go and up — see Free Tier), then browse all available models for the full catalog.

--print sends one prompt, prints the reply, and exits — useful for scripting or quick one-liners.

# Capture the reply in a shell script
ANSWER=$(npx @anyr/agent --print "What is the capital of Japan?")
echo "$ANSWER"

# Pipe a file in as context
npx @anyr/agent --print "$(cat myfile.ts) — add JSDoc comments"

BYOK models

If you have provider keys configured in your BYOK settings, reach them through the dynamic preset ids — each resolves to whichever provider key you set for that slot:

npx @anyr/agent --model anyrouter/byok     # uses your default BYOK key
npx @anyr/agent --model anyrouter/coding   # uses your BYOK coding model
npx @anyr/agent --model anyrouter/agent    # uses your BYOK agent model

These are dynamic presets — they resolve at request time to the provider key you have configured, so the same command follows your BYOK setup across machines.

Delegating to other agents

Existing sessions include a delegate_task tool that bridges to the CLI's anyr delegate (one hop, 10-minute cap). The documented path for delegation is the CLI — see Delegating between coding agents.

  • CLI — anyr launches Claude Code, Codex, and other coding tools through the gateway
  • SDK — @anyr/sdk for building with AnyRouter in TypeScript
  • Models — full model catalog with pricing