# Codex Desktop

Run Codex in the ChatGPT desktop app on your OpenDunes balance.

The desktop app, Codex CLI and the IDE extension read the same `~/.codex/config.toml`. The app sends every request to `POST /v1/responses`, as the CLI does. What the app lacks is your shell: it reads no `export` from your shell profile, so the key goes where it can read it.

1. [Install the app](#1-install-the-app).
2. [Add OpenDunes as a provider](#2-add-opendunes-as-a-provider).
3. [Make the key visible to the app](#3-make-the-key-visible-to-the-app).
4. [Restart and start a local chat](#4-restart-and-start-a-local-chat).

## 1. Install the app

Download the ChatGPT desktop app for macOS or Windows from chatgpt.com, open it and sign in. To reach Codex, open the *ChatGPT* dropdown and choose *Codex*.

## 2. Add OpenDunes as a provider

If Codex CLI already runs on OpenDunes, skip this step: the app reads the same file ([Codex CLI](/docs/cookbook/codex-cli)). If not, write the provider into `~/.codex/config.toml`, or `%USERPROFILE%\.codex\config.toml` on Windows:

```toml
model = "anthropic/claude-sonnet-4.5"
model_provider = "opendunes"

[model_providers.opendunes]
name = "OpenDunes"
base_url = "https://opendunes.com/v1"
env_key = "OPENDUNES_API_KEY"
wire_api = "responses"
supports_websockets = false
```

The provider holds in this file only, in your home folder: a project's `.codex/config.toml` cannot set it. Any model on sale goes in `model`, charged at its own rate shown on its page in [Models](/docs/models).

## 3. Make the key visible to the app

Create an API key named *Codex Desktop*, and cap it on *API Keys* ([API keys](/docs/api-keys) shows how). Then set `OPENDUNES_API_KEY` where the app reads it.

| On | Run once, in a terminal | Holds until |
|---|---|---|
| macOS | `launchctl setenv OPENDUNES_API_KEY "…"` | the Mac restarts |
| Windows | `setx OPENDUNES_API_KEY "…"` | you remove it |

<div class="watch-out">
<p>On macOS, <code>launchctl setenv</code> is lost when the Mac restarts, and the app then sends no key and gets a 401. Run the line again after each restart, before you open the app.</p>
</div>

## 4. Restart and start a local chat

Quit the app fully, not only its window, and open it again: it reads `config.toml` and the key at start. Choose *Codex* and start a new chat as *Local* or *Worktree*: both run on your computer, with your `config.toml`.

Send one short task, then open *Activity*, in the app on opendunes.com: each request Codex sent is there, with its charge in DA.

## Errors

| Status | Means | Do |
|---|---|---|
| 401 | the app sent no key, or a wrong, paused, revoked or expired one | set the key as in step 3, then quit and reopen the app |
| 402 | the balance is at zero or below, cannot pay the request's hold, or the key's cap is spent | make a deposit, or raise the cap |
| 404 | the model ID is not on sale | copy the ID from Models |

Every other status: [Errors and retries](/docs/errors-and-retries). Codex in a terminal: [Coding agents](/docs/coding-agents).

Next: [Cursor](/docs/cookbook/cursor) · [OpenCode](/docs/cookbook/opencode)
