How to Set Up Claude Code, OpenCode, and Codex CLI in 30 Seconds

One command connects all your AI coding tools to SwitchRouter Connect, backs up your existing settings safely, and lets you check your Naira balance right from the terminal.

Short answer: Pick a SwitchRouter Connect plan, copy your API key, and run npx switchrouter connect. The installer detects Claude Code, OpenCode, and Codex CLI on your machine, saves backups of your existing settings, and gets everything working in under 30 seconds.

Step 1: Run One Command

npx switchrouter connect

Here is what happens automatically:

  1. Checks your key safely: Verifies your Connect key and stores it privately on your machine (locked so only your user account can read it).
  2. Catches wrong keys early: If you accidentally paste a pay-as-you-go API key instead of a Connect key, the installer tells you immediately and lets you swap it on the spot.
  3. Simple checkbox picker: Select OpenCode, Claude Code, Codex CLI, or your Shell environment with the arrow keys and Space. Tools you already wired up are clearly marked.
  4. Safe, non-destructive edits: Your existing settings, comments, and other AI providers stay untouched, and a .bak backup file is created before anything changes.

Step 2: Check Your Balance & Health Anytime

Install globally with npm install -g switchrouter so you can use the short sr command anywhere:

# See your Naira balance, rollover bank, and usage gauges
sr status

# Test your connection and check live response speed sr doctor

# Open your dashboard or add top-up credits in the browser sr dashboard sr topup ```

Step 3: Keep It Scoped to One Project (Optional)

Want to wire up a single repo without changing your global laptop settings? Pass --project — SwitchRouter creates local project files and adds them to .gitignore automatically so secrets never get pushed:

npx switchrouter connect --project

Or launch any tool for a single session without editing any config files at all:

sr run claude
sr run opencode
sr run codex

Building a web or Python app instead? Run sr init in your project folder to generate .env.local and a ready-to-use SwitchRouter client in seconds.

Frequently asked questions

Will npx switchrouter connect overwrite my existing Claude Code or OpenCode settings?

No. It adds SwitchRouter alongside your existing setup, keeps your comments and other providers intact, and saves a timestamped .bak backup before editing any file.

Can I run the setup inside CI or an automated script?

Yes. Pass --key sk_sr_... --yes (for example: npx --yes switchrouter@latest connect --key "$SWITCHROUTER_API_KEY" --yes) for completely hands-free setup.

Where is my API key saved?

Locally in ~/.config/switchrouter/config.json with owner-only file permissions, and it is always masked in terminal output.

Continue reading

All articles

Start building with SwitchRouter.

Connect your app or coding agent in seconds. Route across frontier models through one endpoint — then launch your app and start building what's next.

Start building