Configuring a Third-Party API in Codex
Configuring a Third-Party API in Codex
If you want to use a third-party API in Codex, you need to complete two configurations:
-
Configure config.toml
-
Configure auth.json
After all configurations are complete, restart Codex for them to take effect.
How to find these two files:
MacOS / Linux:
Command+Shift+H (press all three keys together) (this step takes you to the user directory)
Then press Command+Shift+. (press all three keys together) (this step reveals all folders that start with a dot)
The .codex folder is here.
Windows:
Press Win+R, then enter %USERPROFILE% and find the .codex folder.
Alternatively, use the search next to Start to search for Run, open it, enter %USERPROFILE%, and find the .codex folder.
Step 1: Configure config.toml
First, find the Codex configuration file:
-
MacOS / Linux: ~/.codex/config.toml
-
Windows: %userprofile%/.codex/config.toml
If this file does not exist, create it first; if it already exists, edit its contents to:
model_provider = "OpenAI"
model = "gpt-5.4-mini"
review_model = "gpt-5.4-mini"
model_reasoning_effort = "medium"
disable_response_storage = true
network_access = "enabled"
windows_wsl_setup_acknowledged = true
[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://rehdasu.cn"
wire_api = "responses"
requires_openai_auth = true
Configuration notes:
-
Copy it exactly as-is.
Step 2: Configure auth.json
Next, find the authentication file:
-
MacOS / Linux: ~/.codex/auth.json
-
Windows: ~/.codex/auth.json
If the file does not exist, create one; if it already exists, edit its contents to:
{
"OPENAI_API_KEY": "sk-xxxxxxxxx"
}
Replace the value of OPENAI_API_KEY (sk-xxxxxxxxx) with the real key you obtained from the platform. (You can find this under API Keys in the left sidebar at https://rehdasu.cn.)
Important: auth.json has only 3 lines!!
Step 3: Restart Codex
After both files above have been configured, restart Codex.
If it still does not take effect after restarting, check these items first:
-
Whether the provider is OpenAI
-
Whether OPENAI_API_KEY is filled in correctly. Custom API keys are not currently supported; a randomly generated one is fine.