Install GPT-codex: To install GPT-codex, please follow these two processes: 1. Local installation (recommended) macOS, Linux, WSL, Windows PowerShell, Windows CMD:
Create a configuration file config.toml You can use any editor available on your computer, such as nano, vim, code (VS Code), etc., or you can create the config.toml file directly under the .codex directory. Run the following code in the installation directory:
Method 1: Using the command line (for those accustomed to the command line)#
Both Windows Command Prompt (CMD) and PowerShell can do this. The setx command is recommended. setx is used to permanently set environment variables. Important note: setx will write the variable to the registry. It will affect all command prompt windows opened in the future, but it will not affect the current window. Therefore, you need to reopen a new terminal window (win+R, enter cmd and press Enter) after the operation:
Use setx for permanent setting (equivalent to editing .bashrc) Operation steps (Open and execute in CMD):
Set the first variable setx 4SAPI_API_KEY "sk "
Important: After the setting is completed, you need to close all opened CMD or PowerShell windows, and then reopen a new window so that the new environment variable will take effect.
Method 2: Using Graphic User Interface (GUI) (Recommended for all Windows users)#
This is the most intuitive and least error-prone method.
Open "System Properties" Press the Windows key + R key on the keyboard to open the "Run" dialog box. Enter sysdm.cpl and then press Enter.
Enter "Environment Variables" settings In the opened "System Properties" window, switch to the "Advanced" tab. Click the "Environment Variables..." button in the lower right corner.
Add a new user variable In the pop-up "Environment Variables" window, the upper half is "User variables for (your username)". Click the "New (N)..." button. Variable name (N): 4SAPI_API_KEY Variable value (V): sk-... (your key) Click "OK".
Save and close Click "OK" in the "Environment Variables" window. Click "OK" in the "System Properties" window. Important: After completing the setting through the GUI, you need to close all opened CMD or PowerShell windows, and then reopen a new window so that the new environment variable will take effect.
How to open GPT-codex: Open a new terminal, enter codex "Hello" and press enter. When something similar to the following appears, the configuration is successful and can be used normally.
Start using GPT-codex: Open a new terminal, enter codex and press enter.