Docs / CLI deep dive

CLI — Claude Code use cases

Practical recipes: first route, switch models, unblock Agent Registry, open Flux IA, ask for spend/quotas, and use slash commands. Prefer the CLI when the current model cannot call tools.

1. First-time setup

pip install -U tokensaver-cli
tokensaver login
tokensaver route claude --launch
# Optional checks:
tokensaver whoami
tokensaver doctor --claude

Writes Claude settings (ANTHROPIC_BASE_URL → https://api.tokensaver.fr/anthropic), MCP entries in .mcp.json, statusline + SessionStart hook, and installs plugin skills under ~/.claude/skills/tokensaver-router.

2. Switch model (sticky)

tokensaver models
# Profile (plan-aware Free allowlist vs paid):
tokensaver use cheap
# Or explicit catalogue id:
tokensaver use openrouter/z-ai/glm-4.7-flash
# Restart Claude if already open — next launch keeps the sticky model

use rewrites settings, auto-approves the model in the Agent Registry, and stores a sticky choice so bare route claude --launch does not reset to the plan default.

3. Unblock zero-trust 403

If Claude returns not registered / quarantined, approve the model:

tokensaver approve --current
# or
tokensaver approve openrouter/z-ai/glm-4.7-flash
tokensaver catalog pending
tokensaver catalog approve provider/model

route claude and the SessionStart hook also call approve for the active model.

4. Flux IA — see governed runs

# After sending a message in Claude:
tokensaver flows
tokensaver flows --open

Prints the console URL /{locale}/{workspaceId}/dashboard?tab=flows and recent pipeline runs (via GET /sdk/runs).

5. Spend & quotas (inside Claude)

There is no tokensaver spend subcommand yet — use the MCP tools server (routed by the CLI) or slash commands:

# In Claude Code chat:
/tokensaver-router:quota

# Or natural language (MCP must be connected):
Combien j'ai dépensé aujourd'hui via TokenSaver ?
Montre ma consommation du mois (tokens + USD).
Combien a coûté mon dernier prompt ? Détail tokens.
Intent MCP tool
Full key dashboard tokensaver_get_api_key_overview
Quotas + usage tokensaver_get_quota_usage
Cost / tokens (today, month, …) tokensaver_get_consumption (period, include_runs)
Cost of a specific run tokensaver_get_last_run_detail / tokensaver_list_runs

Tip: tell Claude explicitly to call those tools and not invent numbers. If the model is broken, use the terminal CLI + console Cost / Flux IA tabs instead.

6. Slash commands (plugin)

Installed by route claude. List with /tokensaver-router:help.

Slash Equivalent
/tokensaver-router:models tokensaver models
/tokensaver-router:use tokensaver use …
/tokensaver-router:flows tokensaver flows
/tokensaver-router:quota MCP key / quota overview
/tokensaver-router:approve tokensaver approve …
/tokensaver-router:doctor tokensaver doctor --claude

7. Project scope + filesystem gateway

cd /path/to/repo
tokensaver route claude --scope project --with-fs --profile cheap --launch

--with-fs adds a Trust Gateway wrap around @modelcontextprotocol/server-filesystem for the cwd (needs npx and local gateway binary when self-hosting).

8. Self-host / local stack

tokensaver login --local
tokensaver route claude --local --launch
tokensaver doctor --claude --local
tokensaver flows --local --open

9. Undo routing

tokensaver unroute claude
# Keeps login credentials; restores settings backups

Next: full command map, Anthropic HTTP API, MCP tools catalogue.