---
title: Codex CLI
description: Run Codex CLI on GPT models at half the official price: add Half Off Dev as a model provider in config.toml, set the key, and pick a model.
---

Codex CLI lets you register extra model providers in `~/.codex/config.toml`. Add Half Off Dev as one and Codex sends its OpenAI Responses API calls here, where GPT models cost half the official rate. Everything else in your Codex setup stays as it is. Create an [API key](/app/keys) first.

## Register the provider {#provider}

Add this to `~/.codex/config.toml`:

```toml title="~/.codex/config.toml"
model = "gpt-6.1-sol"
model_provider = "halfoff"

[model_providers.halfoff]
name = "Half Off Dev"
base_url = "https://halfoff.dev/v1"
env_key = "HALFOFF_API_KEY"
wire_api = "responses"
```

The key itself doesn't go in the file. Codex reads it from the environment variable that `env_key` names:

```bash title="Shell"
export HALFOFF_API_KEY="ho-..."
codex
```

> [!NOTE] Old configs
> Recent Codex releases reject `wire_api = "chat"`. If your config came from an older guide, set it to `"responses"`.

### Or import it from the dashboard {#import}

On [API keys](/app/keys), choose **Use in tools** → **Codex CLI** for this config with your key filled in. **Import with CC Switch** adds Half Off Dev as a provider in the [CC Switch](https://github.com/farion1231/cc-switch) desktop app, with models preset (CC Switch has to be installed). A new key is already in the dialog; for an existing one, paste the full key, because Half Off Dev stores only a hash.

## Models {#models}

The Responses API here serves GPT models, so use a `gpt-*` id. `model` in `config.toml` is the default; `codex -m <model>` overrides it for one session. All ids are on the [model list](/models).

## Prompt caching {#prompt-caching}

Each Codex session sends a `prompt_cache_key`. Half Off Dev uses it to keep all turns of the session on the channel that holds the cache, so repeated context is billed at the cached-input rate. See [Prompt caching](/docs/models/caching).

## Fixing errors {#troubleshooting}

| What you see | What to do |
| --- | --- |
| `401` `Missing API key` | No key is reaching Half Off Dev. Export `HALFOFF_API_KEY` in the shell that runs `codex`, and make sure `env_key` holds that exact name. |
| `401` `Invalid or revoked API key` | The key was mistyped, cut short or revoked. Paste it again or make a new one. |
| `404` `not served in responses format` | Only GPT models are served over the Responses API. Set `model` to a `gpt-*` id. |
| `404` `Unknown endpoint /responses` | `base_url` lacks `/v1`. Set it to `https://halfoff.dev/v1`. |
| Codex refuses `wire_api = "chat"` | Use `wire_api = "responses"`. |
| `402` | The balance is empty or the key has hit its spend cap. See [Billing](/docs/account/billing). |

Any other status is explained in [Errors](/docs/api/errors).
