Codex Setup Guide
Use ToAPIs in Codex CLI through CC Switch
Note for users in mainland China: Please use https://toapis.cn as the API endpoint (Base URL). Replace https://toapis.com with https://toapis.cn in the examples in this document.
Prerequisites
Before you begin, prepare:
-
A ToAPIs API key from the ToAPIs Console.
-
Codex CLI, installed from the official Codex documentation or with:
npm install -g @openai/codex -
CC Switch, downloaded only from ccswitch.io or the official GitHub Releases.
Add ToAPIs in CC Switch
- Open CC Switch and select Codex in the application switcher.
- Click + and choose App-specific provider.
- Select the Custom preset and enter:
| Field | Value |
|---|---|
| Name | ToAPIs |
| API Key | Your ToAPIs API key |
| API endpoint / Base URL | https://toapis.com/v1 |
| Model | gpt-5.3-codex |
| API protocol | Responses |
| Local routing/model mapping | Off |
- Click Add, then click Enable on the ToAPIs provider card.
- Exit any running Codex session and reopen the terminal so the new configuration is loaded.
ToAPIs natively supports POST /v1/responses. Do not enable local routing/model mapping; that option is intended for providers that only expose Chat Completions.
Start and Verify
codexSend a simple task, for example:
Inspect this project and summarize its main directory structure.If Codex responds normally, the setup is complete.
Change the Model
Edit the ToAPIs provider to use another Responses-compatible model available to your account. CC Switch can fetch models from /v1/models; you can also review the ToAPIs model list.
Common choices:
| Model | Best for |
|---|---|
gpt-5.3-codex |
Recommended default for most coding tasks |
gpt-5.3-codex-spark |
Coding tasks that prioritize response speed |
gpt-5.3-codex-official |
Workloads that specifically require the official direct version |
Availability depends on your account permissions and available model configuration. Prefer the /v1/models list fetched by CC Switch.
Troubleshooting
Codex still uses the previous provider
Codex does not hot-reload provider configuration. Fully exit Codex, reopen the terminal, and run codex again.
401 Unauthorized
- Confirm the API key in CC Switch is complete
- Verify that the key is active in the ToAPIs Console
- Ensure the account has sufficient balance
404 or an incorrect Responses path
Confirm the Base URL is https://toapis.com/v1, the protocol is Responses, and local routing/model mapping is disabled.
Model unavailable
Use CC Switch's model-fetch button or call GET https://toapis.com/v1/models with the same API key.
Configuration and Key Safety
CC Switch manages ~/.codex/auth.json and ~/.codex/config.toml. Do not commit these files, your API key, or screenshots containing the key to Git.
See the official CC Switch user manual for additional provider-management instructions.