@topbilling/cli
v0.4.3
Published
Point Claude Code, Codex, OpenCode, Continue, Zed, Aider and other AI coding tools at Top Billing in one command.
Maintainers
Readme
@topbilling/cli
Point your AI coding tools at Top Billing — prepaid INR credits, one key, Anthropic- and OpenAI-compatible APIs — in one command.
npx @topbilling/cliIt signs you in through your browser (or takes an API key from app.topbilling.in/keys), checks the key, shows the models your key can use, lets you pick the tools to configure, and writes their config files. Every file it changes is backed up first, and npx @topbilling/cli remove undoes everything.
Prefer a short command? Install it once and use topbilling from then on:
npm install -g @topbilling/cli
topbilling claudeClaude Code only
npx @topbilling/cli claudeWrites the env block of ~/.claude/settings.json — base URL, your key as ANTHROPIC_AUTH_TOKEN, the default model and the opus / sonnet / haiku / fable aliases, the context window Top Billing publishes for those models, and the flags the gateway needs. If the Claude Code extension is installed in VS Code, Cursor or Windsurf, its claudeCode.environmentVariables setting is written too. Start a new claude session and check /status. If you are also logged in with a claude.ai account, Claude Code warns once; run /logout.
--project writes .claude/settings.local.json in the current folder instead, and adds it to .gitignore.
Supported tools
| Tool | What happens |
|---|---|
| Claude Code (terminal) | ~/.claude/settings.json → env |
| Claude Code in VS Code / Cursor / Windsurf | editor user settings → claudeCode.environmentVariables |
| Codex CLI | ~/.codex/config.toml → provider topbilling on the Responses API |
| OpenCode | ~/.config/opencode/opencode.json → providers topbilling and topbilling-anthropic |
| Continue | ~/.continue/config.yaml models; key in ~/.continue/.env |
| Zed | settings.json → language_models.openai_compatible.topbilling (paste the key in Zed's Agent settings — Zed keeps keys in the OS keychain) |
| Aider | ~/.aider.conf.yml |
| Cursor, Cline, Roo Code, Kilo Code | keep settings in their own UI, so the CLI prints exactly what to paste where |
Not supported: Windsurf's own agent has no custom base URL (Cline, Roo or Kilo inside Windsurf work).
Commands
npx @topbilling/cli # interactive setup
npx @topbilling/cli login # sign in with your browser — no key to copy
npx @topbilling/cli claude # Claude Code only
npx @topbilling/cli usage # balance, how long it lasts, spend per agent and per coding session
npx @topbilling/cli mcp install # Claude Code can then tell you your balance and what a session cost
npx @topbilling/cli models # models your key can use (--json for scripts)
npx @topbilling/cli env # print env vars for your shell (--shell sh|powershell|fish|cmd)
npx @topbilling/cli status # check the key and what each tool points at
npx @topbilling/cli remove # undo (--forget also deletes the saved key)Non-interactive (CI, dotfiles):
TOPBILLING_API_KEY=tb_live_… npx @topbilling/cli --tools claude-code,opencode --model <model-id> --yes--dry-run shows the files it would write, with the key masked, and writes nothing.
Where your key goes
In the config file of each tool you choose (that is how those tools read keys), and in ~/.topbilling/config.json so later commands do not ask again. Files the CLI creates are readable only by you on macOS and Linux. It never prints the full key, and it only ever talks to Top Billing: api.topbilling.in for models and usage, app.topbilling.in for browser sign-in.
Requires Node.js 20.12 or newer.
