Skip to content

Codex CLI

This page focuses on the terminal-based Codex CLI. If you use ChatGPT desktop app, the Codex client, or an IDE extension, read the Codex/ChatGPT guide instead.

TIP

Recommended path: create getapi.one and getapi.pro as separate OpenAI-compatible providers in CC Switch. If you prefer a CLI-only setup, add both providers to Codex config.toml and keep API Keys in environment variables.

For desktop and IDE workflows, go to Codex/ChatGPT.

Download and install

CC Switch

Install CC Switch first if you want one visual place to manage and switch GetAPI provider configurations.

ClientSystem / scenarioCDN downloadFallback
CC SwitchmacOSDownloadGitHub Releases
CC SwitchWindowsDownloadGitHub Releases
CC SwitchMore versionsGitHub Releases

Install Codex CLI

OpenAI official Codex CLI installer command:

bash
curl -fsSL https://chatgpt.com/codex/install.sh | sh

If the installer script is unavailable in your environment, use the OpenAI official Codex CLI documentation as the source of truth for alternate installation methods.

Before you start

  • Codex CLI is installed and the codex command works in your terminal.
  • CC Switch is installed, or you are ready to edit the Codex config file manually.
  • Complete GetAPI sign-up and login. If you have not done that yet, start from the sign-up and login overview.
  • Create a GetAPI API Key. If you have not created one yet, read the API Key overview.
  • Decide whether this CLI session should use getapi.one or getapi.pro.
  • Prepare the exact model name you want Codex CLI to use.

Choose a GetAPI service

Keep each API Key paired with the Base URL from the same service. For Codex CLI and CC Switch, the Base URL must include /v1. Do not mix a getapi.one key with the getapi.pro relay address, or the other way around.

ServiceCodex Base URLAPI Key sourceAPI Key guide
getapi.onehttps://www.getapi.one/v1getapi.one API KeysAPI Key guide
getapi.prohttps://relay-api.getapi.pro/v1getapi.pro API KeysAPI Key guide

Configure with CC Switch

1. Open CC Switch

Launch CC Switch first and prepare to enter the Codex provider configuration area.

2. Open the Codex provider tab

In CC Switch, select the Codex provider tab, then click the plus button to add a new provider.

CC Switch Codex provider list and add button

3. Choose custom configuration

On the add provider page, select custom configuration, then scroll down if you need to find it.

CC Switch add provider page with custom configuration selected

4. Fill in the GetAPI provider

Enter a provider name, paste the matching API Key, and fill in the API request address with /v1, such as https://relay-api.getapi.pro/v1.

CC Switch GetAPI Pro provider configuration with Base URL ending in /v1
Configuration itemgetapi.progetapi.oneNotes
Provider nameGetAPI ProGetAPI OneCustom name for recognition.
Official websitehttps://www.getapi.prohttps://www.getapi.oneProvider website. This field can be left blank if CC Switch does not require it.
API Keygetapi.pro API Keygetapi.one API KeyCopy the key from the matching service. Do not mix keys and addresses across services.
API request addresshttps://relay-api.getapi.pro/v1https://www.getapi.one/v1Must include /v1.
Default modelFor example, gpt-5.6-solFor example, gpt-5.6-solUse a model enabled in the matching GetAPI console.

5. Enable the provider

After saving, return to the provider list and enable the GetAPI provider before starting Codex CLI.

CC Switch provider list with GetAPI Pro enabled

Manual config.toml setup

For a CLI-only setup, store keys in environment variables first. Avoid writing API Keys directly into config.toml.

bash
export GETAPI_ONE_API_KEY="sk-..."
export GETAPI_PRO_API_KEY="sk-..."

Then open ~/.codex/config.toml and add both GetAPI providers. Change model_provider to the service you want to use by default.

toml
model_provider = "getapi_pro"
model = "your-model-name"

[model_providers.getapi_one]
name = "GetAPI One"
base_url = "https://www.getapi.one/v1"
env_key = "GETAPI_ONE_API_KEY"
wire_api = "responses"

[model_providers.getapi_pro]
name = "GetAPI Pro"
base_url = "https://relay-api.getapi.pro/v1"
env_key = "GETAPI_PRO_API_KEY"
wire_api = "responses"

Replace your-model-name with the model you enabled in the matching GetAPI console. For GetAPI, keep base_url ending in /v1. If your relay expects a different OpenAI-compatible wire API, adjust the provider settings according to the Codex config reference.

Run Codex CLI

1. Confirm Codex CLI is installed

Run codex --version in the terminal to confirm that the CLI command is available.

Terminal showing codex --version output

2. Send a test request

Start Codex CLI and send a short message. If Codex returns normally, the CLI provider can be used.

Terminal showing Codex CLI responding successfully

Common issues

ProblemPossible reason
codex: command not foundCodex CLI is not installed, or the install directory is not in PATH.
Missing API keyThe environment variable named in env_key is not loaded in the current terminal.
401 / UnauthorizedThe API Key is incorrect, disabled, or does not match the selected API address.
404 / Not FoundThe Base URL is wrong, missing /v1, or the relay does not support the request path used by the CLI.
Model not foundThe model name is incorrect, or the selected GetAPI group does not enable that model.
Config change not appliedThe wrong config file was edited, model_provider points to another provider, or the terminal needs to be restarted.

Security tips

Never paste a real API Key into screenshots, public repositories, frontend code, or shared documents. Use environment variables and mask keys before sharing terminal output.

References

OpenAI official documentation provides the Codex CLI installation, authentication, and configuration reference. CC Switch releases are provided as a convenience download source.