Codex CLI

Use Foza models with OpenAI Codex CLI

Before you start#

Codex CLI runs as a local coding agent in your terminal. It can read files, propose edits, and run commands in the current project, so start in a clean git working tree when possible.

You need:

  • A Foza API key from Console -> API Keys
  • A model subscription on that API key
  • Codex CLI installed
  • A terminal opened inside the project you want Codex to work on

Recommended first model: openai/gpt-4o. If your Foza account exposes Codex-specific model slugs, use the exact slug shown in Console -> Marketplace.

Use the setup generator from your API key page. This avoids mismatched base URLs, missing API keys, and wrong model names.

1

Open your API key

Go to Console -> API Keys, open the key you want Codex CLI to use, and confirm it is Active.

2

Open the Codex CLI tab

In the key detail page, select Codex CLI.

3

Choose operating system

Select macOS / Linux or Windows. The generated command will match your shell and config location.

4

Assign models by workload

Choose Foza model slugs for the Codex workloads:

  • Fast for light tasks
  • Default for daily use
  • Powerful for hard tasks
5

Create setup command

Click Create setup command, copy the command, and run it in your terminal. The command configures Codex CLI to use the Foza gateway, the selected key, and the selected model mapping.

The generated remove command removes only the Foza configuration for Codex CLI. It does not uninstall Codex CLI.

Manual setup#

1

Get your API key

Create an API key at Console → API Keys and subscribe it to an OpenAI model (e.g., openai/gpt-4o or openai/codex-mini).

2

Set environment variables

export OPENAI_BASE_URL=https://api.foza.ai/v1
export OPENAI_API_KEY=sk-foza-xxxxx

Add these to your ~/.bashrc or ~/.zshrc to persist them.

3

Confirm the variables are active

echo $OPENAI_BASE_URL
echo ${OPENAI_API_KEY:0:12}

The base URL should print https://api.foza.ai/v1. The key check should print the first few characters only.

4

Run Codex

cd /path/to/your/project
codex

Codex CLI will now route all requests through the Foza gateway.

First prompt#

Use a read-only prompt first:

Inspect this repository and explain how the app starts. Do not modify files yet.

Then try a small controlled edit:

Find one low-risk typo in docs or comments and propose a patch before applying it.

Troubleshooting#

SymptomWhat to check
Codex still uses the default OpenAI endpointOPENAI_BASE_URL is set in the same terminal session
401 or authentication errorThe Foza key is copied fully and has an active subscription
Model not availableUse the exact model slug from Foza Marketplace
Tool calls failTry a model intended for coding-agent workflows

You can also set these variables per-session by prefixing the command: OPENAI_BASE_URL=https://api.foza.ai/v1 OPENAI_API_KEY=sk-foza-xxxxx codex