<!-- Lazu · Codex custom provider setup: config.toml and base_url · https://lazu.ai/blog/codex-custom-provider -->

# Codex custom provider setup: config.toml and base_url

2026-09-30 · Lazu team

Short answer: add a `model_providers.lazu` table to `~/.codex/config.toml` with `base_url = "https://api.lazu.ai/v1"` and `wire_api = "responses"`, put your key in the `LAZU_API_KEY` environment variable, and Codex sends its requests to Lazu. The CLI and the desktop app read the same file. If you'd rather not edit it by hand, the one-line script below does it for you.

## The fast way: one line

In [Console › API Keys](https://lazu.ai/console/token), pick a key, click **Connect**, choose Codex and copy the one-line script:

```bash
curl -fsSL https://api.lazu.ai/setup/codex | sh -s -- --model gpt-6-sol
```

The script asks for the key in the terminal, so it never lands on the command line or in your shell history. It writes `config.toml` and adds `LAZU_API_KEY` to your shell's startup file. On Windows, use the PowerShell version in the same dialog.

## Manual setup

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

```toml
model_provider = "lazu"
model = "gpt-6-sol"

[model_providers.lazu]
name = "Lazu"
base_url = "https://api.lazu.ai/v1"
env_key = "LAZU_API_KEY"
wire_api = "responses"
```

Then set the key. For zsh, add this line to `~/.zshrc` with an editor and open a new terminal:

```bash
export LAZU_API_KEY="sk-lazu-..."
```

| Field | What it does |
| --- | --- |
| `model_provider` | Makes the `lazu` provider below the default |
| `model` | The default model, any ID from the [model catalog](/models) |
| `base_url` | Where requests go. Keep the trailing `/v1` |
| `env_key` | The environment variable Codex reads the key from. Never put the key in the TOML |
| `wire_api` | Talk over the Responses API, which Codex needs |

## Why /model only shows one model

Codex never asks a custom provider for its model list; `/model` only shows models from a local catalog. To switch between several models inside Codex, you need a catalog file and a `model_catalog_json` line in `config.toml` pointing at it.

The catalog format changes with Codex versions, so a hand-written one tends to break after an upgrade. The one-line script reads your installed version's format with `codex debug models --bundled` and writes `~/.codex/lazu-models.json` for you. Add models with `--also`:

```bash
curl -fsSL https://api.lazu.ai/setup/codex | sh -s -- --model gpt-6-sol --also gpt-5.6-sol --also gpt-5.6-terra
```

After upgrading Codex, run the line again.

## Using the discount lane in Codex

GPT models on Lazu have two lanes:

- **Stable lane**: runs on the official OpenAI API at the list price, and suits every use.
- **Discount lane**: a reverse-engineered route. A third-party supplier serves the model through the official client; it is not the official API. It costs far less, and we recommend it only inside Codex, which is also the only client it accepts.

You don't touch `config.toml` to switch. Edit the key in the console and set the GPT model's lane to **Discount**. Keep your own code, scripts and anything that needs exact control of the output on the stable lane.

Current prices for `gpt-6-sol`, read live from the catalog:


### [gpt-6-sol](https://lazu.ai/models/openai/gpt-6-sol)

USD per million tokens

| Lane | Input | Output | Cache read | Cache write 5m |
| --- | --- | --- | --- | --- |
| OpenAI official price | $2.00 | $10.00 | $0.20 | $2.50 |
| Input over 272k | $4.00 | $15.00 | $0.40 | $5.00 |
| Lazu Stable · Same as official | $2.00 | $10.00 | $0.20 | $2.50 |
| Lazu Discount · −82% | $0.36 | $1.80 | $0.036 | $0.45 |

A request whose input (cached tokens included) passes the threshold is billed entirely at the long-context prices.

A dash means no price is recorded, not free usage. The request receipt is the final billing record.

## Check that it works

```bash
codex exec "Introduce yourself in one sentence"
```

If it answers, you're connected. The console's usage log shows the request with its model, lane and charge.

## Troubleshooting

**401**: Codex can't see `LAZU_API_KEY`. Run `echo $LAZU_API_KEY` in a new terminal to check it is set; the desktop app needs a restart to pick up a new variable.

**Model not found**: the model ID is wrong, or the key is limited to other models. Copy the ID from the [model catalog](/models), or check the key's model scope in the console.

**Can I use Claude or Gemini in Codex?** Not today. Codex only speaks the Responses API, and on Lazu only GPT models support it for now; Claude and Gemini models return an error. Use Claude Code for Claude models and Antigravity for Gemini models.

## Next

- [Claude Code with a custom API](/blog/claude-code-custom-api)
- [Pricing and lanes](https://lazu.ai/docs/models/pricing): both lanes in full
- [Model catalog](/models): every model with live prices

