To connect Codex to AICodeWith, the current docs use https://api.aicodewith.ai/chatgpt/v1 with the Responses protocol. You can't swap this address for a generic /v1. Beyond the address, you also need to set up authentication, the provider, and the model together, then verify requests against the platform's call logs. This article was checked on October 12, 2026.
If you can't reach the service from mainland China or don't have an overseas credit card, start with "Using Codex in China: How to Solve Network and Payment Problems". If you only want to know how to configure the different kinds of Codex keys, read "How to Configure a Codex API Key".
What to Prepare Before You Start
You need a working Codex CLI, a test project, and an AICodeWith API Key. The model should be currently supported by the platform, within the scope of your Key, and available on the corresponding channel. This article uses gpt-5.6-sol, the current example in the platform docs, purely to illustrate the configuration. If the platform changes, follow the latest docs and model page, and don't treat the example model as valid forever.
View the current Codex terminal integration docs
If you only use the official ChatGPT login and it meets your needs, no extra configuration is required. Switching to a third-party provider changes where model requests go, but it does not replace Codex's file permissions, approvals, or workspace settings.
Step 1: Find and Back Up Your Existing Config
The default directory is ~/.codex on macOS/Linux and the .codex folder in your user directory on Windows. If you've set a custom CODEX_HOME, use that actual directory. Back up config.toml and any existing auth.json, using timestamped copy names so you don't overwrite older backups. Credential backups also need to be kept secret, so don't put them in a synced public folder or in Git.
On macOS/Linux, confirm the directory in a terminal:
mkdir -p "$HOME/.codex"
The Windows PowerShell equivalent:
New-Item -ItemType Directory -Path (Join-Path $env:USERPROFILE ".codex") -Force | Out-Null
Then use a file manager or editor to copy the existing files as separate backups. Don't run a one-click script that overwrites the whole directory, because your current config may also contain MCP servers, project rules, and other providers.
If files already exist in the default directory, you can use the commands below to create timestamped copies. They copy only files that exist, and credential backups should be treated like passwords. On macOS/Linux:
aicw_stamp=$(date +%Y%m%d-%H%M%S)
for aicw_file in config.toml auth.json; do
if [ -f "$HOME/.codex/$aicw_file" ]; then
cp "$HOME/.codex/$aicw_file" "$HOME/.codex/$aicw_file.before-aicw-$aicw_stamp"
fi
done
On Windows PowerShell:
$aicwStamp = Get-Date -Format 'yyyyMMdd-HHmmss'
$aicwDir = Join-Path $env:USERPROFILE '.codex'
foreach ($aicwFile in @('config.toml', 'auth.json')) {
$aicwPath = Join-Path $aicwDir $aicwFile
if (Test-Path $aicwPath) { Copy-Item $aicwPath "$aicwPath.before-aicw-$aicwStamp" }
}
If you've set CODEX_HOME, change the directories above to your actual Codex home. System credential storage isn't kept in auth.json, so file copies can't back up the login state stored there.
Step 2: Configure the Dedicated Provider
Open the user-level config.toml in a text editor. Put model and model_provider at the top level of the file, before any [table]. If keys with the same names already exist, change the existing values instead of adding duplicates. Then add or update the matching provider table. Each line below forms part of one TOML block, in order:
model_provider = "codex"
model = "gpt-5.6-sol"
[model_providers.codex]
name = "codex"
base_url = "https://api.aicodewith.ai/chatgpt/v1"
wire_api = "responses"
requires_openai_auth = true
supports_websockets = false
The value of model_provider must match codex in the table name. requires_openai_auth = true is the authentication method used in this platform's docs. According to the official documentation, env_key is ignored when it's enabled. Don't add env_key to the same config and expect a dedicated variable to override the credentials.
supports_websockets = false comes from the current platform example. Don't treat this channel-specific setting as a default requirement for every provider. The project-level .codex/config.toml can't override these machine-level provider fields, so edit the user config instead.
Step 3: Set Credentials for This Integration Route
The platform docs store the platform Key in the OPENAI_API_KEY field of .codex/auth.json. That field name is just Codex's local credential structure and doesn't mean the Key comes from the OpenAI Platform. Finish the backups above first, then edit the file locally. This applies only to the third-party route in this article, so don't use the platform Key to log in on the OpenAI website.
{"OPENAI_API_KEY":"REPLACE_WITH_YOUR_AICODEWITH_KEY"}
After replacing the placeholder, save the file as valid JSON, and choose UTF-8 in your Windows editor. Don't keep old login tokens from an unrelated route and guess at their precedence. If your machine uses system credential storage, an organization-enforced login policy, or an existing login cache, the file may not be the credential source actually in use. Confirm with the official authentication docs before switching, and don't work around the policy by repeatedly rewriting the file.
Don't put the Key in config.toml, AGENTS.md, or Git. During verification, don't run cat auth.json or Get-Content auth.json, so the full key doesn't end up in your logs.
Step 4: Send a Read-Only Task and Check the Call Logs
codex --version
codex
In your test project, enter: "Only read the README, explain the startup steps, and don't modify any files or install dependencies." Check the current model, the reply, and git status --short, then go to AICodeWith and match the call log by time, Key, and model. Only when a normal reply lines up with a platform record can you say the request reached the intended service. A config file merely existing doesn't prove success.
After configuring the desktop app, restart the client and verify its actual requests separately. The platform's desktop docs are also based on local configuration, but the entry points vary by version, so follow the current UI.
AICodeWith desktop integration guide
When checking call logs, distinguish three cases. If there's no record, first check whether the client is still using the old provider and whether the request reached the platform. If there's a failed record, keep troubleshooting based on the error the service returned. If there's a successful record but the answer doesn't match the task, it only shows the model call succeeded, and you still need to check the output and tool behavior. Logs are a troubleshooting lead, but they can't on their own prove that all local permissions and features are correct.
Create and manage the API Key for this integration
Troubleshoot Errors Layer by Layer
401: Confirm the Key hasn't been revoked, was copied in full, and belongs to the right platform, and check the credential source actually in use. 404: Check /chatgpt/v1 and the Responses configuration character by character, and don't substitute addresses for Claude Messages or generic Chat Completions. model not found: Check the model ID, Key restrictions, and channel, and don't guess model fields from display names.
Long wait with no result: Record the time, client version, and error message, and first work out whether the problem is in the network, authentication, or model response stage. Don't turn off all approvals to work around connection problems. Approvals control local actions and can't fix a remote API address.
How to Restore Your Original Official Config
Exit the current test session and restore the backed-up config.toml. The auth file also needs to be restored to match the original route, or you can re-authenticate with your original login method. If you restore only the model name and keep the third-party address, requests will keep going to the wrong service. Restart the client and confirm the original route with a read-only task. When you no longer need the test Key, revoke it on the platform and clean up any temporary backups that contain it.
Conclusion and Related Resources
The acceptance criteria for this setup is that the provider, dedicated endpoint, model, credential, and call log all agree. When something breaks, pin down the layer first. Keeping your original config makes it safe to roll back.
Official provider and authentication docs
Official config fields and precedence
Codex API key setup and troubleshooting
Don't have an account yet?Sign up for AICodeWith →, then follow the Create an API Key guide to generate a key.


