Codex

Set up OpenAI’s Codex CLI to use Modelway. You don’t need a ChatGPT account.

Step 01

Get your Modelway key

Sign in, open API keys and click Create key. Copy it right away: it’s shown once. New to Modelway? Start with getting access.

Step 02

Install Codex

Open PowerShell and run OpenAI’s installer:

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

With npm, if you already have Node.js:

powershell
npm install -g @openai/codex

Open a new terminal and check it with codex --version.

Step 03

Point it at Modelway

Codex reads %USERPROFILE%\.codex\config.toml. Create the folder if it doesn’t exist yet, then open the file in an editor:

powershell
1New-Item -ItemType Directory -Force "$env:USERPROFILE\.codex"
2notepad "$env:USERPROFILE\.codex\config.toml"

Paste this in, with your key in place of the placeholder:

%USERPROFILE%\.codex\config.tomltoml
1model = "claude-sonnet-5"
2model_provider = "modelway"
3model_reasoning_effort = "medium"
4model_context_window = 1000000
5
6[model_providers.modelway]
7name = "Modelway"
8base_url = "https://modelway.vip/v1"
9experimental_bearer_token = "<your Modelway API key>"
10wire_api = "responses"

Already have a config? Keep model and model_provider above the first [section]. In TOML, anything below a section header belongs to that section.

Step 04

Start Codex

Open a terminal in a project folder and run:

powershell
codex

Switch models with /model.

FAQ

Codex asks me to sign in with ChatGPT.

It isn’t using the Modelway provider. Check that model_provider = "query" is at the top of %USERPROFILE%\.codex\config.toml, above any section.

How do I update?

Run the install command again. With Homebrew, use brew upgrade --cask codex; with npm, npm install -g @openai/codex@latest.

How do I go back to my ChatGPT account?

Remove model_provider and the [model_providers.modelway] section from %USERPROFILE%\.codex\config.toml, then run codex and sign in.