Connect the Codex app to Token Share
Use the Codex desktop app on macOS or Windows with Token Share instead of a ChatGPT subscription: install it, paste one block, restart.
Install the Codex app
- 1Sign in to Token Share and open the API Keys page.
- 2Click Create key, choose the Inference type, and copy the key that starts with
sk-token-. It is shown in full only once. - 3Top up with USDT on the Billing page. Claude models are paid from topped-up balance only.
- 1Download Codex for macOS or Windows from openai.com/codex and install it. On Linux, use Codex CLI.
- 2Open a terminal for the next step: on macOS press ⌘ + Space and search for “Terminal”; on Windows press Win + S and search for Terminal.
Connect to Token Share
This writes Token Share into ~/.codex/config.toml and saves your key as TOKEN_SHARE_KEY. An existing config is kept as config.toml.bak.
Change one thing only: replace <your-pool-api-key> with your key, keeping the quotes around it. Then paste the whole block into the terminal and press Enter.
mkdir -p ~/.codex
[ -f ~/.codex/config.toml ] && cp ~/.codex/config.toml ~/.codex/config.toml.bak
cat > ~/.codex/config.toml <<'EOF'
model_provider = "token_share"
model = "gpt-5.6-sol"
[model_providers.token_share]
name = "OpenAI"
base_url = "https://token-share.app/v1"
wire_api = "responses"
env_key = "TOKEN_SHARE_KEY"
requires_openai_auth = false
EOF
[ -f ~/.codex/auth.json ] || printf '%s\n' '{"OPENAI_API_KEY":"sk-placeholder"}' > ~/.codex/auth.json
SHELL_RC="$HOME/.zshrc"; case "$SHELL" in *bash*) SHELL_RC="$HOME/.bashrc";; esac
echo 'export TOKEN_SHARE_KEY="<your-pool-api-key>"' >> "$SHELL_RC"
source "$SHELL_RC"$key = "<your-pool-api-key>"
$dir = "$HOME\.codex"
New-Item -ItemType Directory -Force -Path $dir | Out-Null
if (Test-Path "$dir\config.toml") { Copy-Item "$dir\config.toml" "$dir\config.toml.bak" -Force }
[IO.File]::WriteAllText("$dir\config.toml", @'
model_provider = "token_share"
model = "gpt-5.6-sol"
[model_providers.token_share]
name = "OpenAI"
base_url = "https://token-share.app/v1"
wire_api = "responses"
env_key = "TOKEN_SHARE_KEY"
requires_openai_auth = false
'@)
if (-not (Test-Path "$dir\auth.json")) { [IO.File]::WriteAllText("$dir\auth.json", '{"OPENAI_API_KEY":"sk-placeholder"}') }
[Environment]::SetEnvironmentVariable("TOKEN_SHARE_KEY", $key, "User")
$env:TOKEN_SHARE_KEY = $keyQuit the Codex app completely (⌘ + Q on macOS; on Windows, quit it from the tray) and open it again. It now runs on Token Share.
To use another model, change model = "gpt-5.6-sol" in ~/.codex/config.toml to any GPT id from the model list.
Check it works
Send any message. The request and its cost appear on the Billing page within seconds.
Switching back to a ChatGPT account
Rename ~/.codex/config.toml.bak back to config.toml. If there was no backup, delete config.toml. Then restart Codex.
Troubleshooting
| What you see | Fix |
|---|---|
Missing environment variable: TOKEN_SHARE_KEY | Codex was started before the key was saved. Quit it completely and start it again; on Windows, also open a new terminal. |
401 invalid api key | The key was pasted wrong. Copy it again and rerun the setup block. |
| It still asks you to sign in to ChatGPT | The config was not picked up. Check that ~/.codex/config.toml starts with model_provider = "token_share", then restart Codex. |
Prefer clicking to editing files? CC Switch can write the same setup for you.
Ready? Three steps to start
- 1Sign in to the console
- 2Top up your balance
- 3Create an API key