Skip to main content
Codex CLI is OpenAI’s official command-line coding assistant, its answer to Claude Code. It talks to the model through the OpenAI Responses API, so routing it through RuAPI only takes a provider entry in ~/.codex/config.toml. You don’t need a ChatGPT account or an OpenAI sign-in. Updated: Nov 5, 2026 For a short explanation of why Codex is easier to run in Russia through RuAPI than through a ChatGPT account, and how to pay without a foreign card, see www.ruapi.ai/codex-v-rossii; the setup steps are below.
Codex works not only with GPT models (for example gpt-5.4, gpt-5.5) but also with other vendors’ models: Claude, DeepSeek, Gemini, Kimi, GLM, Qwen, MiniMax and Grok. Codex sends Responses API requests, and RuAPI converts them into the format each model understands. We tested every family with Codex-format requests (a tool call, the follow-up step with the tool result, streaming and non-streaming) — for example claude-sonnet-5-5, deepseek-flash, gemini-3.8-flash, kimi-k3.1-pro, glm-5.3, qwen3.8-max, MiniMax-M3.1-Flash, grok-4.7. The /model menu lists all of these models your key can use, GPT models first.

Quickest: one command

1

Open the connect window

Sign up at www.ruapi.ai (you don’t have to top up for a first test), open Console → API Keys, click Connect Claude Code, Cline & more and pick Codex.
2

Copy the command

Click Copy command. Your key and the RuAPI address are filled in automatically. The command works once and expires after 30 minutes; if it runs out, click New command. If the window shows ready-made settings instead, first choose Method → One command (recommended) at the top of the window.
3

Paste it into a terminal

macOS: ⌘ + Space → “Terminal”. Linux: Ctrl + Alt + T. Windows: Win + X → “Terminal” or “Windows PowerShell” (not “Command Prompt”). Paste the command and press Enter — the script does the rest by itself.
4

Wait for Codex to open

Usually 1–5 minutes. If Codex isn’t installed yet, the script installs it via npm (plus Node.js if it is missing, into a separate folder, no admin rights), backs up config.toml, adds the RuAPI settings to it without touching the rest, checks the connection and opens Codex. Next time, start it with codex (on Windows, if PowerShell scripts are blocked — the default — codex.cmd; the script shows the right command at the end).
RuAPI API Keys page: the https://www.ruapi.ai address and the “Connect Claude Code, Cline & more” button

Console → API Keys: the “Connect Claude Code, Cline & more” button

If something goes wrong, the script prints a line with [!] saying what to do. If your config.toml has an unusual layout, the script leaves it alone and shows what to add by hand (see below).

Manual setup

Prerequisites

1

RuAPI account + API key

Console → API Keys → Create API key. See API keys & security.
2

Node.js with npm

Install from nodejs.org if needed.

Install Codex CLI

Verify:
You need version 0.161 or newer: from that version Codex loads the model list from RuAPI by itself. Update Codex the same way you installed it: npm install -g @openai/codex@latest or brew upgrade codex.

The config.toml file

Open ~/.codex/config.toml (on Windows, %USERPROFILE%\.codex\config.toml; if you set the CODEX_HOME variable, the config.toml in that folder). If the file doesn’t exist, create it and paste all of this, replacing sk-your-key with your key:
If the file already has settings:
  • the first two lines (model and model_provider) must be at the very top of the file, before the first [ … ] header; if those lines are already there, replace them;
  • add the [model_providers.ruapi] block at the end of the file; if the file already has that block, replace it entirely — Codex won’t start with two blocks of the same name.
Save the file and start codex again.
The key is written into the file: don’t put config.toml in a project folder or commit it to git. base_url must end with /v1, and wire_api must be "responses": the "chat" option was removed from Codex in February 2026 and Codex won’t start with it.
The model_catalog_url line gives you a /model menu whose list refreshes by itself. Codex 0.156–0.160 already knows this line but doesn’t load the list by itself, so the menu stays empty. Update Codex or remove the line. Very old versions simply ignore it.

First call

On first start in a new folder Codex asks whether you trust it — press Enter. Then, in interactive mode:
A normal reply + an entry in RuAPI Console → Usage Logs = success.

Switch models

Inside a session, type /model to open a menu with the models your key can use: GPT first, then Claude, DeepSeek, Gemini, Kimi, GLM, Qwen, MiniMax and Grok. Codex loads the list from RuAPI at startup, and it updates by itself when we add new models. On the trial balance the models are marked ”✓ Available on the trial” or ”🔒 Unlocks after you top up”. You can also change model = "..." at the top of config.toml by hand. Any model from the /model menu or the pricing page works. Budget option. Our cheapest GPT model is gpt-6-luna: it costs many times less than gpt-5.4. At the top of config.toml (before the first section in square brackets), change the model = "..." line to model = "gpt-6-luna". For a really hard task, switch to gpt-5.4 with /model, and switch back to gpt-6-luna afterwards: the model picked in /model may stay for the next launches too.

Troubleshooting

  • experimental_bearer_token must hold the full RuAPI key, including sk-, not an official OpenAI sk-proj-... key.
  • In Console → API Keys, check that the key is active and that the model is in the key’s “Available models” (if a list is set).
  • Check the version: codex --version. You need 0.161 or newer (see above about 0.156–0.160).
  • [model_providers.ruapi] must have the model_catalog_url line, and model_provider = "ruapi" must be at the top of the file.
  • If the key has an “Available models” list, the menu only shows the models from that list.
  • If you selected a profile (a profile = ... line at the top of config.toml), its model and model_provider override the RuAPI settings.
If Codex was installed by the command from the Console, it lives in a separate folder, and the update button inside Codex installs the new version elsewhere. Update like this:
  • Typo in the ID. Pick the model in the /model menu or copy the exact name from the pricing page.
  • base_url must end with /v1.
Your config is outdated. In config.toml, replace wire_api = "chat" with wire_api = "responses".
The old setup with env_key = "RUAPI_API_KEY" and an environment variable keeps working, but its /model menu doesn’t refresh by itself. To make the list refresh by itself, replace the whole [model_providers.ruapi] block with the one above.
  • Codex’s built-in web search works only with GPT models. With other models that tool isn’t passed to the model; your regular tools (commands, file edits, MCP) work with all of them.
  • DeepSeek in Codex accepts text only — it can’t see images in the request.
  • Continuing a previous response via previous_response_id isn’t supported for any model — Codex doesn’t use it anyway (see errors).
For GPT models RuAPI forwards tool calls unchanged; for other models it converts them into the format the model understands. If Codex complains, send support the error text and the request time from Console → Usage Logs.
The easiest way to switch is CC Switch. By hand, change model_provider at the top of config.toml.

Advanced: alongside Claude Code

Many people run Codex and Claude Code side by side — both now offer the same model families, so you can pick the tool you prefer rather than the one your model requires. They don’t conflict: set each up per the Claude Code page and this one — the same RuAPI key works for both.