gitmyhub

sub2cli

Python ★ 13 updated 2d ago

Sub2API gateway subscription → Codex CLI / Codex App injector. macOS-native, zero-deps Python single-file. Supports codex2api.com and any self-hosted Sub2API instance.

A macOS tool that simplifies switching between API relay accounts for OpenAI's Codex CLI by automatically updating config files, testing model endpoints, and managing credentials through a menu-driven desktop app or terminal interface.

Pythonrequestswebsocket-clientmacOSsetup: moderatecomplexity 2/5

Sub2cli is a macOS tool for people using Codex CLI or Codex App (OpenAI's command-line coding assistant) who access it through an API relay service rather than directly through an official OpenAI account. An API relay is a third-party service that provides access to AI models, often with different pricing or subscription arrangements. The primary supported relay is codex2api.com, but the tool works with any self-hosted instance of the Sub2API relay software.

The problem it solves is switching between API channels. Without this tool, changing your Codex setup to use a different relay account, key, or endpoint means manually editing configuration files at ~/.codex/config.toml and ~/.codex/auth.json, restarting Codex App, and hoping nothing breaks. Sub2cli wraps all of that into a menu-driven interface: you pick a relay account, test which model endpoints are available, select one, and the tool writes the config files for you with automatic backups in case you need to roll back.

It comes in two forms. The desktop app is a macOS native window with a dark industrial interface that shows account balances, subscription status, and endpoint latency side by side. The CLI is a terminal REPL (an interactive command-line menu) backed by the same Python logic. Both are distributed from the same single Python file with minimal dependencies: just the requests and websocket-client packages.

Under the hood, the tool reads your relay auth token from a browser's local storage via a debugging connection to Chrome or Edge, then calls the relay's REST API to get your keys, groups, and subscription details. When writing config changes, it uses an atomic copy approach and a lock file to prevent Codex App's own token refresh mechanism from corrupting the files at the same time.

The desktop app is unsigned, so macOS will block it by default. The README provides the command to remove Apple's quarantine flag before opening it. Installation for the CLI version is via a shell script from the repository or from a local clone, targeting macOS 12 or later with Python 3.10 or later.

Where it fits