Codex Guide
Codex is an AI Agent tool designed for code generation, modification, and review.
Installation
Choose an installation method based on your workflow.
Codex App is suitable for users who prefer a graphical interface.
Choose the installer for your system:
After downloading, follow the system prompts to install and launch it.
Codex CLI is recommended for terminal usage.
Installation:
npm install -g @openai/codexVerify installation:
codex --helpIf the command prints help information, installation succeeded.
Without global installation, you can run Codex on demand with npx.
npx @openai/codexOn first run, npx downloads and executes Codex automatically. This is useful when:
- You do not want to modify the global environment.
- You only need to run it once on a machine.
- You want to test whether the CLI meets your needs.
If you use it frequently later, global installation is recommended for faster startup.
Connect to Modelink
After installation, choose one of the following methods to connect Codex to Modelink.
Using CC-Switch is recommended for centralized configuration.
Steps:
- Follow Create API Key to generate an API key.
- Follow CC-Switch to configure a unified provider.
- Restart
CodexorCodex Appafter configuration is complete.
Step 1: Locate the config directory
The local config directory for Codex is usually:
- Windows:
%userprofile%\.codex - macOS / Linux:
~/.codex
If you use Codex inside VSCode or Zed, it usually follows the global Codex configuration. After writing the configuration in this section, restart the editor for the changes to take effect.
Start Codex or Codex App once first so it can initialize the config directory automatically.
Step 2: Write config.toml
Create or edit config.toml in the config directory, and make sure the following content is near the top of the file:
model_provider = "modelink"
model = "gpt-5.4"
review_model = "gpt-5.4"
model_reasoning_effort = "xhigh"
disable_response_storage = true
network_access = "enabled"
windows_wsl_setup_acknowledged = true
model_context_window = 1000000
model_auto_compact_token_limit = 900000
[model_providers.modelink]
name = "OpenAI"
base_url = "https://api.aigoo.xyz/v1"
wire_api = "responses"
requires_openai_auth = true2
3
4
5
6
7
8
9
10
11
12
13
14
15
Step 3: Write auth.json
Create or edit auth.json in the same directory:
{
"OPENAI_API_KEY": "YOUR_MODELINK_API_KEY"
}2
3
Replace YOUR_MODELINK_API_KEY with your real API key.
WebSocket version (optional)
If you need the WebSocket version, add the following to config.toml:
supports_websockets = true
[features]
responses_websockets_v2 = true2
3
4
About Remote Compaction
The configuration above already sets name in [model_providers.modelink] to OpenAI, which is what enables Codex remote compaction.
Codex triggers compaction when a long conversation approaches the context limit. Codex only prefers the remote compaction endpoint (/v1/responses/compact) when the upstream provider name is exactly OpenAI. Remote compaction has higher quality and keeps very long conversations stable, with less quality degradation.
If you change name to any other value (such as modelink), Codex falls back to local compaction, which works much worse.
Notes:
nameis the display name used to trigger remote compaction; keep it asOpenAI.- The provider id
modelink(used bymodel_providerand[model_providers.modelink]) is not affected and stays unchanged. - This setting does not lose your existing chat history.
