# Codex

> Use goodapi in the OpenAI Codex CLI — add a model provider in config.toml that uses the Responses API, and fix common problems.

Codex uses the OpenAI Responses API and needs a key from the **ChatGPT** group, with GPT models.

## Configuration

Edit `~/.codex/config.toml` (create it if it doesn't exist) and add a model provider:

```toml
model = "gpt-5.6-luna"
model_provider = "goodapi"

[model_providers.goodapi]
name = "goodapi"
base_url = "https://api.goodapi.tech/v1"
env_key = "GOODAPI_API_KEY"
wire_api = "responses"
```

Then put your key in the `GOODAPI_API_KEY` environment variable and start Codex:

```bash
export GOODAPI_API_KEY="sk-..."   # key from the ChatGPT group
codex
```

- `base_url` includes `/v1`.
- `env_key` is the name of the environment variable that holds the key. You can rename it, as long as it matches your `export`.
- `wire_api` must be `responses`.

## Choosing models

Set `model` to a ChatGPT group model from [Models and pricing](/en/docs/models). To switch temporarily, run `codex -m <model>`, or use `/model` inside Codex.

## Checking it works

```bash
codex exec "Reply with exactly: ok"
```

Outside a Git repository, add `--skip-git-repo-check`. If it replies `ok` and the request shows up on the [Usage Logs](https://api.goodapi.tech/usage-logs) page of the console, Codex is going through goodapi.

## Troubleshooting

**401**: make sure the terminal you started Codex from has `export`ed the variable named in `env_key`, and that the key is valid; see [Error codes](/en/docs/errors#401).

**403 `This token has no access to model`**: the key isn't from the ChatGPT group, or `model` isn't a model in that group.

**Can I use Claude models?** No. Codex only uses the Responses API, which Claude models don't support. To use Claude and other models in one tool, try [opencode](/en/docs/opencode).
