DEV Community

Folkbench
Folkbench

Posted on

One config, many providers: safely switching Claude Code, Codex and Gemini CLI between API endpoints

If you use AI coding CLIs every day, you probably have more than one API provider. The reasons vary: the official API rate-limits you during a long refactor, a model shows "at capacity", a cheaper provider is good enough for bulk tasks, or your team routes everything through a shared proxy.

The tools themselves are great. Switching between providers is still mostly manual. This post covers where each tool keeps its connection settings, what goes wrong when you edit them by hand, and the small open-source desktop app I built to make switching boring and reversible.

Disclosure up front: I wrote the app. It lives in the same repo as folkbench.com, which publishes provider uptime/latency/price measurements. Everything below works with any compatible endpoint, official ones included.

Where each tool keeps its connection settings

Tool File(s) What has to change
Claude Code ~/.claude/settings.json Base URL, and the right credential type (auth token vs. API key)
Codex ~/.codex/config.toml A custom model provider block. Your ChatGPT OAuth login lives alongside it.
Gemini CLI ~/.gemini/.env + ~/.gemini/settings.json Env vars and the auth method, kept in sync
Aider ~/.aider.conf.yml Model name and API endpoint
OpenCode ~/.config/opencode/ Provider mapping + key (and the right SDK per protocol)
Kimi CLI ~/.kimi-code or ~/.kimi Depends on CLI version

Every tool uses a different format: JSON, TOML, YAML, dotenv. Each has its own idea of which fields matter.

What goes wrong when you do it by hand

  1. You clobber unrelated settings. Copy-pasting a "known good" settings.json over yours wipes permissions, hooks and model preferences.
  2. Two fields drift apart. Gemini CLI needs both the .env and the auth type in settings.json to agree. Change one and you get confusing auth errors.
  3. Codex forgets who you are. In my experience, pointing Codex at a third-party provider and then back often meant redoing the ChatGPT OAuth browser flow.
  4. Mid-task context switch. A provider throws 502s, you leave the terminal, edit a file, restart the CLI, and lose your train of thought.
  5. Helping friends doesn't scale. I set Claude Code up for several non-programmer friends over chat, sending screenshots of where to paste the Base URL. Never again.

The approach: profiles + diff + scoped writes

Folkbench Switch is a Tauri + Rust desktop app (Apache-2.0, macOS and Windows) built around a few rules:

  • Profiles, not file copies. You save providers as Base URL + key (several keys per provider, with notes). Applying a profile writes only the connection fields for the target tool.
  • Show the diff first. Before it writes, you see exactly what will change in the target file.
  • Stash what you'd lose. When Codex is switched to a third-party provider, the official OAuth credentials are stashed and restored when you switch back.
  • Fail safe. If a write fails, only that write is rolled back. If the file was changed externally since it was read, the app stops instead of overwriting. A shared write lock and a single-instance guard prevent two writers racing.
  • Local by default. Keys and configs stay on your disk (keys in an owner-only 0600 file in the app's config dir). The webview's CSP blocks direct HTTP; every request goes through the Rust side. A key is only sent to the provider it belongs to, when you load that provider's model list or check its balance, and redirects are followed only within the same origin. There's no telemetry or sync. At startup the app makes an anonymous GET for public rankings from folkbench.com. Signing in to Folkbench is optional, and update checks are manual and signature-verified.

Other things that turned out useful:

  • Per-session token usage and cost estimate, read from local tool logs and priced at public reference rates.
  • Provider health before switching. The app can show public uptime/latency probes from folkbench.com, so you can see whether a route is up before you move to it.
  • Simple mode. Pick a model, pick a provider, paste a key, choose a working folder, launch. It detects missing Node/npm/Homebrew and shows the install command. This is the mode I give to friends.

How it compares

cc-switch is the established, feature-rich tool in this space, and if you want every knob it's a good choice. Folkbench Switch is narrower: a beginner-first flow, diff-before-write, and Codex OAuth preservation. If you're comfortable with dotfiles, a shell alias that swaps ANTHROPIC_BASE_URL may be all you need.

Current limitations

  • 0.1.0-beta.4. Expect rough edges.
  • The Windows installer is not Authenticode-signed yet (SmartScreen will warn). macOS builds are Developer ID signed and notarized.
  • No Linux installer yet. CI compiles and tests on Ubuntu, but releases are macOS/Windows only.
  • Local model servers (Ollama, LM Studio) work as a custom Base URL; plain http:// is accepted for localhost/loopback only. There are no presets yet.
  • Keys are not in the OS keychain yet.
  • MiniMax Code, Qwen Code, Grok Build, Hermes and Pi support is still in progress.

Try it / tell me what breaks

I'm most interested in config edge cases: unusual Claude Code credential setups, multiple Codex profiles, OpenCode providers I haven't handled. Comments and issues are both fine.

Top comments (0)