Skip to content

Use ZhiFlo in Codex

This is the manual path for people who want a separate long-term ZhiFlo setup without overwriting the default Codex configuration.

If you are connecting for the first time, the CC Switch quickstart is faster.

  • Install Codex 0.134.0 or later from the official Codex project. Run codex --version to check; update Codex before continuing if the version is older.
  • Create a Token dedicated to this device.
  • Copy a complete model ID from your account.

On Windows, open PowerShell from Start. On macOS or Linux, open Terminal. The ~ below means your user home directory; on Windows, that directory is %USERPROFILE%.

  1. Open the .codex folder in your home directory; create it if it does not exist.
  2. Create zhiflo.config.toml, giving the full path ~/.codex/zhiflo.config.toml.
  3. Add the following content and replace <MODEL_FROM_ZHIFLO> with the complete model ID from your account.
model_provider = "zhiflo"
model = "<MODEL_FROM_ZHIFLO>"
[model_providers.zhiflo]
name = "ZhiFlo"
base_url = "https://api.zhiflo.com/v1"
env_key = "ZHIFLO_API_TOKEN"
wire_api = "responses"

Save the file. Do not put the Token in TOML, and do not copy this user-level provider configuration into a project repository.

These commands keep the Token in the current terminal environment. Closing the window removes it.

Run the commands, paste the Token, and press Enter. The input stays hidden.

Terminal window
read -s ZHIFLO_API_TOKEN
export ZHIFLO_API_TOKEN

Run the commands and paste the Token when prompted:

Terminal window
$secureToken = Read-Host "Paste your ZhiFlo Token" -AsSecureString
$env:ZHIFLO_API_TOKEN = [System.Net.NetworkCredential]::new("", $secureToken).Password

Keep the Token out of shared terminal logs, command history, and screenshots.

In the same terminal where you set the environment variable, run:

Terminal window
codex --profile zhiflo

Then send:

Do not modify any files. Reply with OK only.

An OK reply means the manual path is complete: Codex read the profile file, loaded the Token, recognized the model ID, and sent a real request through ZhiFlo.

  • Profile or configuration not found: check the exact filename and the active CODEX_HOME. Without CODEX_HOME, the default is ~/.codex. If the file is still not recognized, update Codex; do not switch to the legacy [profiles.zhiflo] syntax.
  • Missing ZHIFLO_API_TOKEN: load the Token again and launch Codex from that same terminal window.
  • 404 response: set base_url to https://api.zhiflo.com/v1 and wire_api to responses.
  • Model unavailable: copy the complete current ID again, update model, and reopen Codex.

Next: Understand usage and Token quotas.