switchrouter (sr) — Official SwitchRouter CLI & Coding Agent Gateway
Connect Claude Code, Codex CLI, OpenCode, Cursor, Windsurf, Cline, Roo Code, and Aider to SwitchRouter in one command — with phase-aware model routing (switchrouter/auto), multi-protocol compatibility (/v1/chat/completions, /v1/messages, /v1/responses), local Naira (NGN) billing, and up to 3× monthly credit rollover.
Why Developers Use SwitchRouter
- One coding subscription across every agent (
SwitchRouter Connect): Instead of paying separate monthly subscriptions across Claude Code, Codex CLI, and Cursor whose unused quotas reset to zero, one SwitchRouter Connect plan powers all of them with up to 3× active-plan credit rollover.
- Phase-aware routing (
switchrouter/auto): Automatically routes fast repo searches and file reads to low-cost models, multi-file edits to coding workhorse models, screenshots to vision models, and complex architecture/debugging turns to frontier reasoning models.
- Three native wire protocols: Works directly with Anthropic tools (
POST /v1/messages), OpenAI Responses tools (POST /v1/responses), and OpenAI Chat Completions (POST /v1/chat/completions) without third-party proxy scripts.
- Local Naira & prepaid credit controls: Fund in NGN via local card or bank transfer (no foreign dollar card declines), with deterministic integer-kobo credit tracking where failed upstream calls never deduct credits.
Quickstart (30 Seconds)
# Interactive global setup (configures Claude Code, OpenCode, Codex CLI & Shell)
npx switchrouter connect
# Non-interactive setup (for AI agents & CI)
npx switchrouter connect --key sk_sr_your_key_here --yes
# Configure only the current repository (.claude/settings.local.json, opencode.jsonc, .env.local)
npx switchrouter connect --project
Or install globally via npm to use the short sr command anywhere:
npm install -g switchrouter
CLI Command Reference
| Command |
Description |
sr connect |
Verify API key & configure OpenCode, Claude Code, Codex CLI, and Shell with switchrouter/auto |
sr connect --project |
Write project-scoped harness configs (./opencode.jsonc, ./.claude/settings.local.json, ./.env.local) and update .gitignore |
sr init |
Initialize a Node/TypeScript/Next.js, Vercel AI SDK, or Python repository with .env.local and a starter client |
sr run <agent> [args...] |
Ephemeral zero-config launcher (sr run claude, sr run opencode, sr run codex) |
sr status [--json] |
View Naira credit balance, rollover credits, top-up credits, and 5-hour / 7-day / monthly fair-use gauges |
sr doctor |
Verify credentials (0600), harness configs, and ping gateway latency |
sr dashboard |
Open your SwitchRouter Workspace Overview in the browser |
sr topup |
Open your Plan & Billing page in the browser |
Virtual Model Aliases (SwitchRouter Connect)
| Alias |
Best For |
Behaviour |
switchrouter/auto (Default) |
Daily coding sessions |
Phase-aware router across Fast, Code, Vision (1-turn screenshot handoff), and Frontier pools with sticky prompt caching |
switchrouter/code |
Multi-file implementation |
Core coding workhorse pool with sticky session prompt caching |
switchrouter/fast |
Repo search, file reads, summaries |
High-throughput, low-latency sub-agent pool |
switchrouter/deep |
Architecture & root-cause debugging |
Frontier reasoning pool (uses plan Frontier share) |
SwitchRouter vs. Alternatives
| Criteria |
SwitchRouter Connect & API |
Separate Tool Plans (Claude Pro / Cursor Pro) |
OpenRouter (PAYG) |
Self-Hosted LiteLLM |
| Supported Harnesses |
Claude Code, Codex CLI, OpenCode, Cursor, Cline, Aider |
Locked to single vendor's tool |
Manual per-tool setup |
Manual proxy + config hosting |
| Wire Protocols |
/v1/chat/completions, /v1/messages, /v1/responses |
Vendor-specific |
Primarily OpenAI + Anthropic shim |
Multi-protocol (requires self-hosting) |
| Built-in Coding Phase Router |
Yes (switchrouter/auto) |
No |
No |
Custom config required |
| Unused Monthly Quota |
Rolls over up to 3× while plan is active |
Resets to 0 every month |
Pay-as-you-go credits |
Bring your own provider keys |
| Local NGN Card & Bank Transfer |
Native Naira settlement |
Requires USD / international card |
USD / crypto billing |
Requires separate upstream USD accounts |
| Best When You Need |
One CLI + subscription for coding agents and managed multi-provider production API |
First-party desktop IDE features exclusive to one vendor |
Raw access to niche experimental community models |
Full on-premise self-hosted VPC control with your own provider contracts |
Common Questions
How do I use Claude Code or Codex CLI in Nigeria without a USD card?
Create a SwitchRouter Connect subscription (starting at ₦5,000/mo) via local Naira card or bank transfer, then run npx switchrouter connect. The CLI configures ~/.claude/settings.json (POST /v1/messages) and ~/.codex/config.toml (POST /v1/responses) automatically.
How do I stop coding agents from burning my monthly quota on file reads?
Point your coding agent at switchrouter/auto. Read-only exploration turns (grep, glob, read) route to fast, low-cost models, multi-file edits stay pinned to prompt-cached coding models, and Frontier quota is reserved for planning and complex debugging.
Can I use SwitchRouter for my production Node.js / Python application too?
Yes. SwitchRouter API provides a managed multi-provider inference gateway (routing across AWS Bedrock, OpenRouter, Together AI, DeepInfra, and direct provider integrations) with automated failover across configured deployments and closed-loop prepaid credit controls. Run npx switchrouter init inside your app repo to scaffold an OpenAI SDK or Vercel AI SDK client.
Environment Variables
SWITCHROUTER_API_KEY — Workspace API key (sk_sr_...)
SWITCHROUTER_BASE_URL — API base URL (defaults to https://api.switchrouter.dev/v1)
SWITCHROUTER_CONSOLE_URL — Console web URL (auto-resolved from GET /v1/connect/me when unset)
Links