# Use AoxToken in Codex

Create an account → create an API key → find the configuration file → paste the configuration → add your key → restart.

This guide targets Codex CLI and the Codex desktop app; Windows and macOS tests are pending. ChatGPT Desktop compatibility is tracked separately in #38. Do not apply this setup to it based on this guide.

> Pending verification: the example model `gpt-5.4` has not been confirmed with an AoxToken test account. The model, group, and configuration must be tested before publication; another provider’s tutorial is insufficient evidence.

## Create your account

1. Open [AoxToken registration](https://aoxtoken.com/register) and follow the registration steps.
2. Already have an account? [Sign in](https://aoxtoken.com/login).
3. Open your [dashboard](https://aoxtoken.com/dashboard) and check your available credits. Follow the purchase instructions if needed.

AoxToken uses its own API keys and account credits, not your ChatGPT subscription allowance.

## Create an API key

1. Open [API key management](https://aoxtoken.com/keys).
2. Create a key with a recognizable name, such as `My Codex`.
3. If you need to select a group, choose one with access to **GPT-5.4 and the Responses API**.
4. Copy the key for the next step.

> Your API key grants access to your account allowance. Do not share it.

## Windows

Install and launch Codex once before starting. The example includes the endpoint and model; replace only the API key.

### Find the configuration file

Press **Win + R**, paste this path and press Enter:

```text
%USERPROFILE%\.codex
```

Right-click `config.toml` and choose **Open with → Notepad**. If the file does not exist, create it. Enable file extensions in File Explorer and make sure it is not named `config.toml.txt`.

### Paste the configuration

If the file already contains settings, make a backup named `config.toml.backup`. This is a complete first-time setup. Replace the contents only if there are no custom settings to preserve; otherwise merge the values without duplicating keys or removing MCP settings.

```toml
model = "gpt-5.4"
model_provider = "aoxtoken"
forced_login_method = "api"

[model_providers.aoxtoken]
name = "AoxToken"
base_url = "https://api.aoxtoken.com/v1"
wire_api = "responses"
experimental_bearer_token = "PASTE_YOUR_API_KEY_HERE"
supports_websockets = false
```

### Add your key, save and restart

Replace `PASTE_YOUR_API_KEY_HERE` with your AoxToken API key. Keep the straight double quotes and do not add `Bearer `.

Press **Ctrl + S**, fully quit the client, reopen it and start a new task.

## macOS

Install and launch Codex once before starting.

### Find the configuration file

Open **Finder**, press **Command + Shift + G** and paste:

```text
~/.codex
```

Open `config.toml` with **TextEdit**. If the folder is missing, launch Codex once and try again. If only the file is missing, open Terminal and run:

```bash
touch ~/.codex/config.toml && open -a TextEdit ~/.codex/config.toml
```

### Paste the configuration

Back up existing contents as `config.toml.backup`. In TextEdit, turn off **Edit → Substitutions → Smart Quotes**. Preserve existing MCP or other custom settings when merging.

```toml
model = "gpt-5.4"
model_provider = "aoxtoken"
forced_login_method = "api"

[model_providers.aoxtoken]
name = "AoxToken"
base_url = "https://api.aoxtoken.com/v1"
wire_api = "responses"
experimental_bearer_token = "PASTE_YOUR_API_KEY_HERE"
supports_websockets = false
```

### Add your key, save and restart

Replace the key placeholder, keeping the straight double quotes and omitting `Bearer `. Press **Command + S**, then **Command + Q** in the client to fully quit. Reopen it and start a new task.

## Check the connection

Send: “Hello, please briefly introduce yourself.” Check for a matching request or usage record in the [AoxToken dashboard](https://aoxtoken.com/dashboard).

Depending on the client version, the model picker may show **GPT-5.4** or **Custom**. A label alone does not prove the request reached AoxToken.

For Codex CLI, restart with:

```bash
codex
```

ChatGPT Desktop is outside this guide’s verification scope. Wait for its separate compatibility document.

## Troubleshooting

| Problem | What to check |
| --- | --- |
| Invalid key or 401 | Copy the complete key without extra spaces or a `Bearer ` prefix. |
| Permission error or 403 | Confirm that the key's group allows GPT-5.4. |
| Model not found | Confirm `gpt-5.4` is available to the key, or obtain a supported model ID from AoxToken. |
| 404 | Use `https://api.aoxtoken.com/v1`; do not append `/responses`. |
| 429 | Check credits, request rate and concurrency limits. |
| Configuration parse error | Check straight quotes, duplicate fields and file contents. |
| Changes have no effect | Check the filename and fully restart the client. |

When merging settings, place `model`, `model_provider` and `forced_login_method` before the first `[section]`. This example uses HTTPS streaming without WebSocket. If you set `CODEX_HOME`, edit the configuration in that directory instead.

## Restore your previous configuration

Quit the client, restore `config.toml.backup` as `config.toml`, then restart. Never upload a file containing your key to a repository or share it. Revoke a leaked key and create a replacement.
