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 a terminal and run OpenAI’s installer:

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

With npm, if you already have Node.js:

shell
npm install -g @openai/codex

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

Step 03

Point it at Modelway

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

shell
1mkdir -p ~/.codex
2nano ~/.codex/config.toml

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

~/.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:

shell
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 ~/.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 ~/.codex/config.toml, then run codex and sign in.