Setup Guideline

Full beginner guide · Windows and macOS

ChatGPT / Codex + Space Router

Windows setup supports local, domain and Microsoft Entra ID (Azure AD) accounts. If an earlier setup failed with a SID configuration error, rerun the one-command installer below. No Windows or editor upgrade is needed for this fix.

One command installs the ChatGPT / Codex app, asks for your Space Router GPT, Grok, Gemini and DeepSeek keys, writes the Codex configuration, and proves each with a real request. Codex then uses those Space Router models directly.

Gateway: https://space.stationine.com · Last checked:

Keep your API key private. Never share a real API key in screenshots, chat messages, repositories, project files, or public documents. If a key has been exposed, revoke or rotate it in Space Router and create a new one. Every example uses the literal placeholder YOUR_SPACE_API_KEY; replace it only on your own computer.

Quick install — one command

This installs the ChatGPT / Codex desktop app (and the Codex command-line tool used to verify the connection), then writes the same configuration as the Space Router console’s Use Key instructions — automatically and checked with a real request. No ChatGPT sign-in and no gateway software are involved. Claude Code has its own command on the Claude Code guide; run one at a time. The manual steps below are the fallback if you prefer to set it up yourself or if the installer fails.

Where to paste the command. The one-line installer below runs in a text window — PowerShell on Windows, Terminal on macOS. You do not need to know anything else about it. The installer asks for your Space Router keys in turn: GPT, then the optional Grok, Gemini and DeepSeek. Paste each sk- key on your own computer and press Enter; skip a group you did not buy with Enter. Every key is checked with a real request before it is saved, and the finished configuration is verified with a real Codex request.

Windows

irm https://stationine.com/setup-codex.ps1 | iex

macOS

curl -fsSL https://stationine.com/setup-codex.sh | bash

The installer:

Codex shows one model family at a time: the first one you bought in the order GPT, Grok, Gemini, DeepSeek. The other families you pasted are saved too, and the installer ends by printing one line per family to switch, for example node "…\SpaceRouter\direct-config.cjs" use gemini; paste it, then fully quit and reopen the app. Claude models are for Claude Code, which uses its own Claude-group key.

Start a new chat after setup. A conversation you opened before running the installer keeps the connection it was created with, so it keeps failing with a 401 against api.openai.com even though the setup is correct. Fully quit and reopen the app, then click New chat. Your existing conversations are not deleted, and you can copy a link from an old chat into a new one to carry the context over.

Already signed into ChatGPT? After setup, Codex uses your Space Router key instead of the ChatGPT account, so the account area shows Space Router rather than your email. To go back to ChatGPT, restore the backup the installer printed and sign in again.

Inside VS Code (Claude Code and Codex together)

If you work in VS Code, use this instead. It installs VS Code with the Claude Code and ChatGPT / Codex extensions, asks for Claude, GPT, Grok, Gemini and DeepSeek keys (each can be skipped), and connects both extensions to Space Router.

irm https://stationine.com/setup-vscode.ps1 | iex
curl -fsSL https://stationine.com/setup-vscode.sh | bash

Afterwards open VS Code (close and reopen it if it was already running) and click the Claude or Codex icon in the left bar. A Claude key cannot be used for GPT and a GPT key cannot be used for Claude; the relay refuses the request.

The remaining manual steps are for the Codex CLI in direct-provider mode. They cannot keep an official ChatGPT subscription and several Space Router providers active together. If you already use the signed-in desktop app, use the one-click gateway above; do not replace your auth.json with the manual example below.

What is Space Router?

Space Router is an AI API relay operated by Station Nine. Its base URL is https://space.stationine.com.

It accepts Anthropic Messages requests at POST /v1/messages, OpenAI Chat Completions requests at POST /v1/chat/completions, and OpenAI Responses requests at POST /v1/responses. It provides Anthropic Claude, OpenAI GPT, xAI Grok, Google Gemini and DeepSeek model families; the Space Router dashboard is the authoritative source for the current model list.

Pointing Codex CLI at Space Router sends its supported OpenAI Responses-format model requests through that relay. See the full Space Router overview for service and account details.

0. Get a Space Router API key

  1. Create an account at Space Router with an email address and verification, or sign in with GitHub or Google.
  2. Add credit, then create an API key in the dashboard.
  3. Use that private key wherever this guide says YOUR_SPACE_API_KEY; never publish or commit it.

1. What you need

Software requirements for running Codex CLI through Space Router
SoftwareWindowsmacOSRequired?
Codex CLIYesYesYes
GitRecommendedRecommendedStrongly recommended
PowerShellBuilt inNoWindows only
Node.js / npmOptionalOptionalOnly for the npm install method
HomebrewNoOptionalOnly for the Homebrew method
VS Code / CursorOptionalOptionalNot required for Codex CLI

Use the native Codex installer. You do not need Node.js or npm with it. Git is still strongly recommended because Codex works best inside Git repositories and can inspect diffs, branches, and commits.

2. Install Git

Windows

Install Git for Windows. Close and reopen PowerShell, then check:

git --version

You should see a Git version number.

macOS

git --version

If macOS asks to install Command Line Tools, accept it. Or run:

xcode-select --install
git --version

3. Install Codex CLI

Open PowerShell and run:

powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

Close PowerShell, open a new window, then check:

codex --version
curl -fsSL https://chatgpt.com/codex/install.sh | sh

Close Terminal, open it again, then check:

codex --version

4. Alternative Codex installation methods

Skip this section if the native installer worked.

npm — Windows or macOS

Node.js and npm are required only for this method.

node --version
npm --version
npm install -g @openai/codex
codex --version

Homebrew — macOS

brew install --cask codex
codex --version

5. If codex says “command not found” or “not recognized”

First close the terminal completely and reopen it.

Windows

Get-Command codex -ErrorAction SilentlyContinue
where.exe codex
Test-Path "$HOME\.local\bin\codex.exe"

If the last command returns True, add C:\Users\<YOUR_WINDOWS_USERNAME>\.local\bin to your User PATH:

  1. Press Windows Start and search for Environment Variables.
  2. Open Edit environment variables for your account.
  3. Select Path, choose Edit, then New.
  4. Add %USERPROFILE%\.local\bin.
  5. Press OK on all windows, close all PowerShell windows, and open PowerShell again.
codex --version

macOS

command -v codex
ls -l ~/.local/bin/codex 2>/dev/null

If Codex exists at ~/.local/bin/codex but the command is not found:

File: ~/.zshrc (macOS)

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
codex --version

6. Create the Codex configuration folder

Windows

Codex user configuration is stored in %USERPROFILE%\.codex\.

New-Item -ItemType Directory -Force "$HOME\.codex" | Out-Null

macOS

Codex user configuration is stored in ~/.codex/.

mkdir -p ~/.codex

7. Configure Space Router in config.toml

Windows

File: %USERPROFILE%\.codex\config.toml

notepad "$HOME\.codex\config.toml"

macOS

File: ~/.codex/config.toml

nano ~/.codex/config.toml

8. Important — do not overwrite the whole existing config.toml

If config.toml already contains your settings, MCP servers, plugins, profiles, notifications, or other configuration, do not delete the whole file. Replace only the top model/provider configuration block. Keep everything below the existing provider block unless you intentionally want to remove it.

Also remove this old test setting

Do not add:

File: %USERPROFILE%\.codex\config.toml (Windows) / ~/.codex/config.toml (macOS)

[features]
goals = true

If it exists only for this old test, remove those two lines. goals = true is intentionally excluded from the configuration below.

9. Windows config.toml top block

Put this at the beginning of config.toml:

File: %USERPROFILE%\.codex\config.toml (Windows)

model_provider = "OpenAI"
model = "gpt-5.5"
review_model = "gpt-5.5"
model_reasoning_effort = "xhigh"
disable_response_storage = true
network_access = "enabled"
windows_wsl_setup_acknowledged = true

[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://space.stationine.com"
wire_api = "responses"
requires_openai_auth = true

Leave the rest of your existing config.toml underneath it. Example:

File: %USERPROFILE%\.codex\config.toml (Windows)

model_provider = "OpenAI"
model = "gpt-5.5"
review_model = "gpt-5.5"
model_reasoning_effort = "xhigh"
disable_response_storage = true
network_access = "enabled"
windows_wsl_setup_acknowledged = true

[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://space.stationine.com"
wire_api = "responses"
requires_openai_auth = true

# KEEP YOUR EXISTING CONFIGURATION BELOW THIS LINE.
# Example only:
#
# [mcp_servers.example]
# ...

10. macOS config.toml top block

File: ~/.codex/config.toml (macOS)

model_provider = "OpenAI"
model = "gpt-5.5"
review_model = "gpt-5.5"
model_reasoning_effort = "xhigh"
disable_response_storage = true
network_access = "enabled"

[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://space.stationine.com"
wire_api = "responses"
requires_openai_auth = true

windows_wsl_setup_acknowledged is not needed on macOS. Again, keep your existing configuration below this block.

11. Create auth.json

The API key is stored separately.

Windows

File: %USERPROFILE%\.codex\auth.json

notepad "$HOME\.codex\auth.json"

macOS

File: ~/.codex/auth.json

nano ~/.codex/auth.json

Put:

File: %USERPROFILE%\.codex\auth.json (Windows) / ~/.codex/auth.json (macOS)

{
  "OPENAI_API_KEY": "YOUR_SPACE_API_KEY"
}

Replace YOUR_SPACE_API_KEY with your new Space Router API key only on your own computer. Do not add extra commas.

macOS security permission

File: ~/.codex/auth.json (macOS)

chmod 600 ~/.codex/auth.json

12. Start Codex

Open the folder you want Codex to work on.

Windows example

cd "C:\path\to\your\project"
codex

macOS example

cd ~/path/to/your/project
codex

13. First test

Inside Codex, try:

Tell me what folder you are currently working in and list the top-level files. Do not change anything.

Then run /status and confirm the model/provider information looks correct. You can also run /model to inspect or change the model.

14. Git beginner workflow

If the folder is a new project:

git init
git status

A safe beginner habit is to create a Git checkpoint before asking Codex to make a large change:

git add .
git commit -m "checkpoint before Codex changes"
codex

15. Common problems

Codex CLI and Space Router troubleshooting fixes
ProblemFirst checkFix
codex not recognizedInstallation folder in PATHAdd %USERPROFILE%\.local\bin to User PATH on Windows or add ~/.local/bin through ~/.zshrc on macOS, then reopen the terminal.
Codex asks you to sign inconfig.toml, auth.json, and requires_openai_authCreate both user files, set requires_openai_auth = true, then completely restart Codex.
401 / UnauthorizedKey validity and auth.json syntaxPut a valid, complete key with no extra spaces in "OPENAI_API_KEY", save valid JSON, and rotate any exposed key.
Model not foundSpace Router's current supported model IDsReplace model and review_model with a current model ID from the Space Router dashboard; keep wire_api = "responses".
Existing settings disappearedRestore configuration below the provider blockRestore MCP, plugin, and profile sections below the new provider block and remove the obsolete goals = true test setting.

Problem A — codex is not recognized

The symptom is that the terminal does not recognize codex. The installation folder is missing from PATH; add %USERPROFILE%\.local\bin to User PATH on Windows or add ~/.local/bin through ~/.zshrc on macOS, then reopen the terminal and run codex --version.

Problem B — Codex asks you to sign in

The symptom is an unexpected Codex sign-in prompt. One of the user configuration files is missing, or the provider block does not enable OpenAI authentication.

Windows files: %USERPROFILE%\.codex\config.toml and %USERPROFILE%\.codex\auth.json

Test-Path "$HOME\.codex\config.toml"
Test-Path "$HOME\.codex\auth.json"

macOS files: ~/.codex/config.toml and ~/.codex/auth.json

ls -l ~/.codex/config.toml
ls -l ~/.codex/auth.json

On Windows, both commands should return True. Close Codex completely and start it again. Also ensure this line appears under [model_providers.OpenAI]:

File: %USERPROFILE%\.codex\config.toml (Windows) / ~/.codex/config.toml (macOS)

requires_openai_auth = true

Problem C — 401 / Unauthorized

The symptom is a 401 or Unauthorized response, which means Space Router did not receive an accepted valid credential. Fix auth.json as follows:

  1. Check that the Space Router API key is still valid.
  2. Confirm you copied the complete key with no extra spaces.
  3. Confirm auth.json is valid JSON.
  4. Confirm the key is assigned to "OPENAI_API_KEY".

If the key was visible in a screenshot or shared publicly, rotate it.

Problem D — model not found

The symptom is that Codex reports a model is not found. The configured model ID is not available through the gateway; this guide currently uses:

File: %USERPROFILE%\.codex\config.toml (Windows) / ~/.codex/config.toml (macOS)

model = "gpt-5.5"
review_model = "gpt-5.5"

Those values match our current Space Router setup configuration. If a name is rejected, replace both with a model ID from the authoritative current list in the Space Router dashboard. Do not randomly change wire_api; for this setup it must remain:

File: %USERPROFILE%\.codex\config.toml (Windows) / ~/.codex/config.toml (macOS)

wire_api = "responses"

Problem E — existing Codex settings disappeared

The symptom is that MCP, plugin, profile, or other Codex settings have disappeared. This happens when the entire config.toml is replaced; restore those sections below the new provider block and remove the obsolete goals = true test setting.

File: %USERPROFILE%\.codex\config.toml (Windows) / ~/.codex/config.toml (macOS)

Replace only the top model/provider block
↓
Keep the rest of config.toml
↓
Do not add [features] goals = true

Restore your MCP, plugin, and profile sections underneath the new provider block.

FAQ

Do I need Node.js to use Codex CLI with Space Router?

You do not need to install Node.js yourself. The one-click desktop gateway installs its required runtime automatically; the manual native Codex CLI installer does not need Node.js. The npm alternative below does.

Do I need WSL on Windows?

No. This guide installs Codex CLI natively from PowerShell on Windows, and the Windows config.toml block includes windows_wsl_setup_acknowledged = true.

Why does the terminal say codex is not recognized?

The Codex installation folder is missing from PATH. Add %USERPROFILE%\.local\bin to User PATH on Windows or add ~/.local/bin through ~/.zshrc on macOS, then reopen the terminal.

What does a 401 Unauthorized response mean, and how do I fix it?

A 401 means Space Router did not receive an accepted valid credential. Put a valid, complete key with no extra spaces in "OPENAI_API_KEY" inside valid auth.json, and rotate the key if it was exposed.

What if the model name is rejected?

Replace model and review_model in config.toml with a current model ID from the authoritative list in the Space Router dashboard. Keep wire_api = "responses" for this setup.

Can I use this with an editor or IDE extension?

VS Code and Cursor are optional and are not required for Codex CLI. This guide configures the CLI, so start codex from the project directory instead of assuming an editor extension inherits these user files.

How do I switch back to the official OpenAI endpoint?

Restore config.toml and auth.json from the direct-backup-* folder the installer printed (inside %LOCALAPPDATA%\SpaceRouter), fully restart Codex, and sign in to ChatGPT again if you want the ChatGPT account back.

Where do I get Space Router support?

Contact Space Router at apisupport@stationine.com or through the Space Router Telegram group. Space Router is operated by Station Nine.

16. References

Space Router is operated by Station Nine (stationine.com). With respect to OpenAI it is a third-party gateway: OpenAI does not maintain, audit, or support third-party gateways, so vendor-specific issues should be reported to Space Router, not to OpenAI.