Skip to content

TechTronixx/Custom-modelswitch

Repository files navigation

AI Config Manager

PowerShell Platform Issues Stars Last commit

Claude Code OpenCode Codex Hermes Desktop

One-liner to switch Claude Code, OpenCode, Codex, and Hermes Desktop to a custom AI gateway.

Model lists are fetched live from the gateway when possible, with curated fallbacks. Every config file is backed up before it's touched.

Quick start

irm https://raw.githubusercontent.com/TechTronixx/Custom-modelswitch/main/bootstrap.ps1 | iex

Downloads to ~/AI-Config-Manager and launches the menu. Re-run the same line any time to update and start again.

Requirements

  • Windows PowerShell 5.1+ or PowerShell 7+
  • curl.exe (bundled with Windows 10/11)
  • The tools you want to configure (Claude Code, OpenCode, Codex, Hermes)

Install (manual)

Clone and run, if you prefer not to use the one-liner above:

git clone https://github.com/TechTronixx/Custom-modelswitch.git
cd Custom-modelswitch
powershell -ExecutionPolicy Bypass -File .\AI-Config-Manager.ps1

No dependencies. AI-Config-Presets.json must stay next to the script.

Usage

Pick an option with the arrow keys, Enter to select, Esc to go back.

Option What it does
Configure Claude Code Writes ~/.claude/settings.json (base URL, token, model)
Configure OpenCode Writes ~/.config/opencode/opencode.json (provider + model)
Configure Codex Writes ~/.codex/auth.json + ~/.codex/config.toml, sets an API-key env var
Configure Hermes Desktop Launches hermes model for you to complete manually
Configure Claude Desktop Writes the 3P gateway config (configLibrary entry) for the Claude Desktop app
Configure Both Claude Code + OpenCode in one pass
View current configuration Shows what each tool is currently pointed at

Pick a gateway from the list, or choose Custom base URL to enter one at runtime. Then enter your API key and pick a model.

Gateways

The gateway list comes from AI-Config-Presets.json. Add your own by copying a block — no code changes. Each preset defines, per tool, a base URL, provider labels, and a curated model fallback list.

{
  "presets": [
    {
      "id": "mygateway",
      "label": "My Gateway",
      "dashboard": "https://example.com/keys",
      "fetchModels": true,
      "modelsApiUrl": null,
      "claude":   { "baseUrl": "https://example.com", "curatedModels": ["claude-opus-4-8"] },
      "opencode": { "baseUrl": "https://example.com/v1", "providerKey": "mygateway", "providerName": "My Gateway", "npmPackage": "@ai-sdk/openai-compatible", "curatedModels": ["gpt-5.5"] },
      "codex":    { "baseUrl": "https://example.com" }
    }
  ]
}

Field notes:

  • dashboard — signup/key page shown at the API-key prompt (null to omit).
  • fetchModels — try a live model list before falling back to curatedModels.
  • modelsApiUrl — optional public model-list endpoint; if set, it's used instead of the standard /v1/models call.
  • Base URLs can differ per tool — set each to whatever your gateway expects.

Notes

  • Backups: each write leaves a *.backup-<timestamp> copy next to the original.
  • Codex sets an environment variable. Configuring Codex writes a persistent User environment variable (e.g. MYGATEWAY_API_KEY) holding your API key, because Codex resolves its provider key from the real process environment. Fully restart the Codex app afterward for it to take effect.
  • Claude Desktop uses a 3P gateway config. The Claude Desktop Electron app stores its gateway settings in a managed config file inside %LOCALAPPDATA%\Claude-3p\configLibrary\. The script finds the active entry (via _meta.json's appliedId) and writes the gateway base URL, API key, auth scheme, and model list. Fully restart the app afterward. If a setup screen appears, go to Menu > Developer > Configure Third-Party Inference to verify the config loaded. Each gateway uses its own model ID format, so pick the model from the live-fetched list that matches your gateway.
  • Secrets: API keys are written into these config files and, for Codex, into a user environment variable — plaintext, local only. They're excluded from git via .gitignore.

Development

Run the built-in self-test for the scroll-window math (no terminal needed):

powershell -File .\AI-Config-Manager.ps1 -SelfTest

Contributing

Contributions welcome — see CONTRIBUTING.md for the branch workflow (dev → PR → main) and guidelines.

Found a bug or want a new gateway/tool? Open an issue — issue templates are provided for bug reports and feature requests. Questions and ideas can go in Discussions.

Disclaimer

This tool edits your own config files to point Claude Code, OpenCode, Codex, and Hermes at a gateway you choose. It does not bypass authentication or pirate access — you supply your own API keys. Routing official clients to third-party endpoints may violate those tools' Terms of Service and can result in account bans or service termination. You are responsible for complying with your gateway's and each tool's terms. The software is provided "AS IS" without warranty; the author is not liable for any damage, bans, or service loss.

License

MIT — see LICENSE.

About

Terminal UI to point your AI coding tools at a custom gateway for Claude/OpenAI

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages