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

# Codex

> Route OpenAI Codex CLI through GMI Cloud as a custom model provider.

OpenAI's Codex CLI lets you swap providers via a TOML config. Point it at GMI Cloud and you get the full GMI model catalog through Codex's native interface, chat, tool use, and the OpenAI Responses API all work as-is.

## Prerequisites

* A GMI Cloud account at [console.gmicloud.ai](https://console.gmicloud.ai)
* Codex CLI installed
* A terminal running zsh or bash
* About 5 minutes

## Step 1. Get your GMI API key

1. Sign in to [console.gmicloud.ai](https://console.gmicloud.ai).
2. Open **API Keys** and click **Create API Key**.
3. Copy the key now, it won't be shown again.

## Step 2. Export the key

Add this to your shell config (`~/.zshrc` or `~/.bashrc`):

```bash theme={null}
export GMI_API_KEY=your_gmi_api_key_here
```

Then reload:

```bash theme={null}
source ~/.zshrc
```

## Step 3. Configure Codex

Create or edit `~/.codex/config.toml`:

```toml theme={null}
# ~/.codex/config.toml

model = "openai/gpt-5.5"
model_provider = "gmi"

[model_providers.gmi]
name = "GMI Cloud"
base_url = "https://api.gmi-serving.com/v1"
env_key = "GMI_API_KEY"
wire_api = "responses"

[projects."/home/your-username"]
trust_level = "trusted"

[tui.model_availability_nux]
"gpt-5.5" = 2
```

Adjust two things for your setup:

* **`model`**: pick any model from the [GMI catalog](/model-quickstarts/text/overview). Defaults to `openai/gpt-5.5` here.
* **`[projects."/path"]`**: set this to the absolute path of the project directory you want Codex to trust without prompting.

The `wire_api = "responses"` line tells Codex to use OpenAI's Responses API, which GMI Cloud serves at `/v1/responses`.

## Step 4. Run Codex

```bash theme={null}
codex
```

Codex picks up the config, reads `GMI_API_KEY` from your environment, and talks to GMI Cloud directly.

## Tips

* Edit the `model` line in `config.toml` to switch defaults. You can also override per-session from inside the Codex UI.
* Browse model IDs in the [Text catalog](/model-quickstarts/text/overview), [Image catalog](/model-quickstarts/image/overview), and [Video catalog](/model-quickstarts/video/overview).

## Troubleshooting

* **`401 Unauthorized`**: `GMI_API_KEY` isn't exported in the shell where you launched Codex. Run `echo $GMI_API_KEY` to confirm.
* **`Unknown model`**: the `model` string must include the provider prefix (e.g. `openai/gpt-5.5`, not `gpt-5.5`).
* **Trust prompts on every run**: make sure the `[projects."..."]` path matches the directory you're running Codex from exactly.

## Next steps

* Try [Claude Code](/coding-tools/claude-code) or [Cursor](/coding-tools/cursor) with the same GMI account.
* Stuck? Email [support@gmicloud.ai](mailto:support@gmicloud.ai).
