API ключ для Codex: подключение за 5 минутAPI key for Codex: set up in 5 minutes
Для Codex CLI в терминале и Codex в VS Code настройка одна: файл конфига и ключ в переменной окружения. Вставь ключ в поле ниже — команды соберутся под тебя.Codex CLI in the terminal and Codex in VS Code share one setup: a config file and your key in an environment variable. Paste your key below and the commands will be built for you.
Ключ не отправляется с этой страницы: команды собираются локально в браузере. Без галочки выше ключ исчезнет после закрытия страницы. Ключ — как пароль: не показывай его на скриншотах, не отправляй в чаты и не добавляй в Git. Нет ключа — зарегистрируйся: личный ключ выпустится сам. Кнопки скачивания готовых файлов (settings.json, codex-setup.bat) — на странице «Подключение» — генератор конфигураций.Your key never leaves this page: commands are assembled locally in your browser. Without the checkbox above, the key disappears when you close the page. Treat the key like a password: never show it in screenshots, chats, or Git. No key yet? Register — a personal key is issued automatically. Download buttons for ready-made files are on the full connection page.
Как подключить
API ключ для CodexAPI key for Codex
Ключ из поля выше автоматически подставляется в команды и конфиги.Your key from the field above is inserted into the commands and configs automatically.
Установи Codex
Уже стоит — переходи к шагу 2.
- Поставь Node.js (бесплатно, скачивается с nodejs.org).
- В терминале выполни: npm install -g @openai/codex
Создай файл конфига
Один файл — работает и терминал, и VS Code.
Windows. Нажми Win+R, вставь notepad %USERPROFILE%\.codex\config.toml и нажми Enter — Блокнот предложит создать файл, соглашайся.
macOS / Linux. Создай файл ~/.codex/config.toml в любом текстовом редакторе (папки .codex нет — создай её).
Вставь блок (адрес API уже подставлен) и сохрани:
Строка preferred_auth_method = "apikey" приказывает Codex работать с ключом, а не с аккаунтом ChatGPT. Без неё Codex может молча игнорировать твой конфиг — это самая частая проблема подключения.
Ключ — в переменную окружения
Выбери систему и вставь команду целиком.
Windows. Открой PowerShell (Пуск → набери powershell), вставь команду и нажми Enter:
macOS / Linux. Открой Terminal, вставь блок целиком и нажми Enter:
Выйди из аккаунта ChatGPT и перезапусти
Обязательный шаг, если ты когда-либо входил в Codex под аккаунтом.
- В терминале выполни: codex logout (если напишет, что ты не входил — просто иди дальше).
- Полностью закрой все окна терминала и VS Code, открой заново.
- Запусти codex и задай вопрос — пришёл ответ, всё работает.
Codex в VS Code отдельной настройки не требует: расширение читает тот же config.toml и ту же переменную. После шагов выше просто полностью перезапусти VS Code.
Windows, не любишь команды: на странице «Подключение» есть установщик одним кликом — скачанный .bat сам создаст конфиг и пропишет ключ.
Install Codex
Already installed? Skip to step 2.
- Install Node.js (it's free, downloaded from nodejs.org).
- In the terminal, run: npm install -g @openai/codex
Create the config file
One file — works for both the terminal and VS Code.
Windows. Press Win+R, paste notepad %USERPROFILE%\.codex\config.toml and hit Enter — Notepad will offer to create the file, accept.
macOS / Linux. Create the file ~/.codex/config.toml in any text editor (there is no .codex folder yet — create it).
Paste the block (the API address is already filled in) and save:
The line preferred_auth_method = "apikey" tells Codex to work with the key, not with a ChatGPT account. Without it Codex may silently ignore your config — this is the most common setup problem.
Put the key into an environment variable
Pick your system and paste the whole command.
Windows. Open PowerShell (Start → type powershell), paste the command and hit Enter:
macOS / Linux. Open Terminal, paste the whole block and hit Enter:
Sign out of the ChatGPT account and restart
A required step if you have ever signed in to Codex with an account.
- In the terminal, run: codex logout (if it says you were not signed in — just move on).
- Close all terminal windows and VS Code completely, then open them again.
- Run codex and ask something — an answer came back, everything works.
Codex in VS Code needs no extra setup: the extension reads the same config.toml and the same variable. After the steps above, simply restart VS Code completely.
Windows, don't like commands? The full connection page has a one-click installer — the downloaded .bat creates the config and writes the key itself.
Частые ошибки
Ошибка 401, и в тексте упоминается api.openai.com
401 Unauthorized: Missing bearer or basic authentication
«Лимит использования исчерпан» после долгой работы
Ключ не принимается, проверка падает
Error 401, and the message mentions api.openai.com
401 Unauthorized: Missing bearer or basic authentication
A “usage limit” error after working for a while
The key is not accepted, verification fails
Ограничения и совместимость
Сервер поддерживает оба транспорта Codex: обычные запросы (Responses API) и потоковый WebSocket.
Установщик .bat одним кликом есть только для Windows; на macOS и Linux настройка — два шага руками, они описаны выше.
Codex активно обновляется: в новых версиях могут отличаться названия пунктов и настройки входа (например, preferred_auth_method в свежем справочнике фигурирует как forced_login_method = "api"). Если одна строка не сработала — попробуй вторую и сверься с официальной документацией Codex.
Не храни ключ в скриншотах, чатах и репозиториях — это доступ к твоему балансу.
The server supports both Codex transports: regular requests (Responses API) and the streaming WebSocket.
The one-click .bat installer is Windows-only; on macOS and Linux the setup is the two manual steps described above.
Codex updates often: newer versions may rename menu items and sign-in settings (for example, preferred_auth_method appears as forced_login_method = "api" in recent documentation). If one line doesn't work, try the other and check the official Codex documentation.
Never keep the key in screenshots, chats, or repositories — it gives access to your balance.
Вопросы и ответы
Где находится config.toml?
Нужно ли отдельно настраивать Codex в VS Code?
Почему Codex обращается на api.openai.com вместо моего Base URL?
Какую модель выбрать для Codex?
Where is config.toml located?
Does Codex in VS Code need separate setup?
Why does Codex hit api.openai.com instead of my Base URL?
Which model should I pick for Codex?
Дальше:Next: Полный гайд и генератор конфигурацийFull guide and config generator Таблица моделейModel table Документация APIAPI documentation Баланс и логиBalance and logs
Инструкции для других программ:Guides for other tools:
Claude Code Cursor Cline ZCode Терминал / cURLTerminal / cURL Python JavaScript JetBrains Antigravity Claude Code в РоссииClaude Code in Russia