> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dreamto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex CLI

> Add DreamTo as a custom model provider in ~/.codex/config.toml and drive Codex over the Responses protocol.

[Codex CLI](https://github.com/openai/codex) is OpenAI's open-source command-line coding assistant. It calls models over the OpenAI Responses protocol, which DreamTo supports natively, so you only need to add a custom provider to its config file.

## Prerequisites

* Codex CLI is installed (`codex --version` prints a version), for example via `npm i -g @openai/codex`.
* You have created an API Key on the **API Keys** page of the [DreamTo console](https://www.dreamto.ai/console).
* You have a GPT model ID that supports the Responses protocol, such as `gpt-6.2-sol`. See [OpenAI Responses](https://docs.dreamto.ai/en/llm/openai-responses.md) and the [Model Marketplace](https://www.dreamto.ai/models) for available models.

## Setup

**1. Set the API Key environment variable**

Codex reads the key from the environment variable named by `env_key`, so the config file doesn't need a plaintext key.

```bash macOS / Linux theme={null}
# Add to ~/.zshrc or ~/.bashrc, then reopen your terminal
export DREAMTO_API_KEY="sk-xxxx"
```

```powershell Windows PowerShell theme={null}
# Saves a user environment variable; takes effect in a new terminal
setx DREAMTO_API_KEY "sk-xxxx"
```

> [!WARNING]
>
> For the Codex desktop app or IDE extensions, the environment variable must be persistent (in your shell config or system environment variables). The desktop app can't see a variable you only `export` in the current terminal.

**2. Edit config.toml**

Open `~/.codex/config.toml` (`%USERPROFILE%\.codex\config.toml` on Windows; create it if missing) and add:

```toml ~/.codex/config.toml theme={null}
model = "gpt-6.2-sol"
model_provider = "dreamto"
model_reasoning_effort = "medium"

[model_providers.dreamto]
name = "DreamTo"
base_url = "https://api.dreamto.ai/v1"
env_key = "DREAMTO_API_KEY"
wire_api = "responses"
request_max_retries = 3
stream_max_retries = 3
```

Top-level keys such as `model` and `model_provider` must come before any `[...]` table; otherwise TOML assigns them to the preceding table.

| Key | Description |
| - | - |
| `model_provider` | The id of the `[model_providers.<id>]` table below; built-in ids such as `openai` and `ollama` are reserved and can't be used |
| `base_url` | Must include `/v1`; Codex appends `/responses` |
| `env_key` | Name of the environment variable holding the API Key |
| `wire_api` | Set to `"responses"` |

**3. Launch and verify**

Reopen your terminal and run in your project directory:

```bash theme={null}
codex "List the files in the current directory and explain what this project does"
```

Type `/status` in the interactive UI to see the current provider and model.

## Multiple configurations (profiles)

Use profiles to switch between models. The syntax depends on your version:

> [tab] Codex 0.134.0 and later
>
> Each profile is a separate file `~/.codex/<name>.config.toml` containing only top-level keys. Pass `--profile` at launch to layer it on top of the main config:
>
> ```toml ~/.codex/dreamto-fast.config.toml theme={null}
> model = "gpt-6-luna"
> model_provider = "dreamto"
> model_reasoning_effort = "low"
> ```
>
> ```bash theme={null}
> codex --profile dreamto-fast
> ```
>
> Starting with this version, `[profiles.xxx]` tables and the top-level `profile = "..."` in `config.toml` are no longer read. Move them to separate files.

> [tab] Earlier versions
>
> Define profiles as `[profiles.<name>]` tables in `config.toml`:
>
> ```toml ~/.codex/config.toml theme={null}
> [profiles.dreamto-fast]
> model = "gpt-6-luna"
> model_provider = "dreamto"
> model_reasoning_effort = "low"
> ```
>
> ```bash theme={null}
> codex --profile dreamto-fast
> ```

## FAQ

> [accordion] 401 / Missing environment variable
>
> * Make sure the variable name in `env_key` matches the one you `export`, and that you started Codex in a new terminal.
> * Check that the key has no extra leading or trailing spaces or quotes.

> [accordion] 404 / model not found
>
> * `base_url` must be `https://api.dreamto.ai/v1`. Without `/v1`, requests go to `/responses`; writing `/v1/responses` gives `/v1/responses/responses`.
> * Set `model` to a model ID from the Model Marketplace and make sure it supports the Responses protocol (GPT family).

> [accordion] Config in the project directory has no effect
>
> A project's `.codex/config.toml` ignores `model_provider`, `model_providers` and `openai_base_url`. These can only be set in `~/.codex/config.toml` in your home directory.

> [accordion] Streaming breaks or hangs
>
> Raise `stream_max_retries`, or set `stream_idle_timeout_ms` (milliseconds) on the provider. If you're behind a corporate proxy, make sure it doesn't buffer SSE.

> [!TIP]
>
> To just change the address without adding a provider, you can set `openai_base_url = "https://api.dreamto.ai/v1"` in `config.toml` to override the built-in `openai` provider's address. A custom provider is clearer, though, and doesn't get mixed up with your OpenAI account sign-in.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.