Configure Codex CLI with BytePass

Codex CLI is OpenAI's open-source terminal coding tool. This guide shows you how to connect it to BytePass.

Estimated time: 5 minutes (or under 2 minutes with CC-Switch)


Prerequisites

  • Node.js 22+ — Check with node --version
  • A BytePass API key — Create one at bytepass.ai/keys

Install Codex CLI

npm install -g @openai/codex

Configuration

If you have CC-Switch installed, go to bytepass.ai/keys and click the "Import to CCS" button next to your key. CC-Switch has a dedicated Codex tab.

See the full CC-Switch guide for details.

Method 2: Config files

Codex uses two config files. Edit ~/.codex/config.toml:

model_provider = "bytepass"
model = "gpt-5.4"

[model_providers.bytepass]
name = "bytepass"
base_url = "https://api.bytepass.ai"
wire_api = "responses"
requires_openai_auth = true

And ~/.codex/auth.json:

{
  "OPENAI_API_KEY": "sk-your-bytepass-key"
}

Method 3: Environment variables

export OPENAI_BASE_URL="https://api.bytepass.ai/v1"
export OPENAI_API_KEY="sk-your-bytepass-key"

Add these to your shell profile (~/.zshrc or ~/.bashrc) and reload.

Note: Unlike Claude Code, Codex CLI env vars need the /v1 suffix in the URL.


Verify

Open a new terminal and run:

codex

Type a message. If you get a response, the setup is working.


Troubleshooting

401 error

Check your API key and account balance at bytepass.ai/dashboard.

"model not found" or empty response

Make sure you're using a model that BytePass supports. Check the models page for the full list.

Config not taking effect

Open a new terminal after editing config files or environment variables.


What's next?