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

# Codex

> Use Auriko as your LLM provider in Codex

Auriko connects to Codex through two environment variables, routing your completions through Auriko instead of OpenAI.

## Prerequisites

* [Codex CLI](https://github.com/openai/codex) installed
* An [Auriko API key](https://auriko.ai/signup?redirectTo=%2Fdashboard%3Ftab%3Dapi-keys)

## Install Codex

Run the official install script:

```bash theme={null}
curl -fsSL https://chatgpt.com/codex/install.sh | sh
```

Or install via npm:

```bash theme={null}
npm install -g @openai/codex
```

Or via Homebrew (macOS):

```bash theme={null}
brew install --cask codex
```

Open a new terminal after installing, then confirm Codex is available:

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

The install script writes PATH to `~/.bashrc`, which non-interactive shells don't source. In CI, GitHub Actions, or agent-driven sessions, add this before invoking `codex`:

```bash theme={null}
export PATH="$HOME/.codex/bin:$PATH"
```

## Set your API key

Add these two lines to your shell profile (`~/.zshrc` on macOS, `~/.bashrc` on Linux):

```bash theme={null}
export OPENAI_API_KEY="ak_live_..."    # your Auriko API key
export OPENAI_BASE_URL="https://api.auriko.ai/v1"
```

The variable names are `OPENAI_*` because Codex reads OpenAI-standard environment variables. Your Auriko API key goes in `OPENAI_API_KEY`. Your key starts with `ak_live_` (production) or `ak_test_` (testing).

The base URL must include `/v1`. Codex appends `/responses` directly.

If you've logged in to Codex with a ChatGPT account, these environment variables override the ChatGPT login. Codex routes completions through `OPENAI_BASE_URL` instead of `chatgpt.com`.

Reload your shell after saving:

```bash theme={null}
source ~/.zshrc   # or: source ~/.bashrc
```

Or open a new terminal.

<Accordion title="Use Auriko alongside a ChatGPT Pro subscription">
  To keep your default `codex` connected to ChatGPT, create a wrapper command instead of modifying your shell profile.

  Add your Auriko API key to your shell profile (`~/.zshrc` or `~/.bashrc`):

  ```bash theme={null}
  export AURIKO_API_KEY="ak_live_..."
  ```

  Create the wrapper script:

  ```bash theme={null}
  mkdir -p ~/.local/bin
  cat > ~/.local/bin/codex-auriko << 'EOF'
  #!/usr/bin/env bash
  export OPENAI_API_KEY="${AURIKO_API_KEY}"
  export OPENAI_BASE_URL="https://api.auriko.ai/v1"
  exec codex "$@"
  EOF
  chmod +x ~/.local/bin/codex-auriko
  ```

  Add `~/.local/bin` to your `PATH` if it isn't already:

  ```bash theme={null}
  export PATH="$HOME/.local/bin:$PATH"
  ```

  Reload your shell, then verify:

  ```bash theme={null}
  codex-auriko exec -m gpt-5.4-mini "Say exactly: setup-ok"
  ```

  Use `codex-auriko` for Auriko sessions and `codex` for your ChatGPT subscription.
</Accordion>

## Verify

Run a test completion:

```bash theme={null}
codex exec -m gpt-5.4-mini "Say exactly: setup-ok"
```

Codex prints sandbox setup output on first run. The model response follows.

Expect two cosmetic warnings:

* `Model metadata for '...' not found`: metadata isn't available for models served through custom base URLs.
* `missing field 'models'`: the response uses the standard `data` field instead of a `models` field.

## Use different models

Pass any model ID with the `-m` flag:

```bash theme={null}
codex -m gpt-5.5 "Summarize this repo"
codex -m gpt-5.4 "Review my code"
```

To switch models mid-session, type `/model <id>`.

<Note>
  Codex uses the Response API with hosted tools, which only GPT models support. Non-GPT models (Claude, DeepSeek, Gemini) return a `hosted_tool_not_supported` error.
</Note>

These are the models available through Auriko that work with Codex:

| Model          | Author | Context |
| -------------- | ------ | ------- |
| `gpt-5.5`      | OpenAI | 1M      |
| `gpt-5.4`      | OpenAI | 1M      |
| `gpt-5.4-mini` | OpenAI | 400K    |
| `gpt-5.4-nano` | OpenAI | 400K    |
| `gpt-5-codex`  | OpenAI | 400K    |
| `o4-mini`      | OpenAI | 200K    |
| `o3`           | OpenAI | 200K    |
| `gpt-4o`       | OpenAI | 128K    |

`gpt-5.4-nano` works for basic tasks but doesn't support all Codex tools (e.g., `tool_search`). Complex multi-tool sessions may require a larger model.

To list all Auriko models (only GPT models with Response API support work with Codex):

```bash theme={null}
curl -s -H "Authorization: Bearer $OPENAI_API_KEY" \
  https://api.auriko.ai/v1/models | jq '.data[].id'
```

## Control routing

Configure routing in the [Auriko dashboard](https://auriko.ai/dashboard). See [routing options](/guides/routing-options) for details.

## Uninstall

Remove `OPENAI_API_KEY` and `OPENAI_BASE_URL` from your shell profile (`~/.zshrc` or `~/.bashrc`). If you created a `codex-auriko` wrapper, delete `~/.local/bin/codex-auriko`.

## Troubleshoot

| Symptom                               | Cause                                                      | Fix                                                                                                                          |
| ------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| Completions go to ChatGPT, not Auriko | `OPENAI_API_KEY` not set; ChatGPT auth takes over          | Export `OPENAI_API_KEY` with your Auriko key                                                                                 |
| `hosted_tool_not_supported`           | Non-GPT model used                                         | Use a GPT model (see model table above)                                                                                      |
| 404 on requests                       | `OPENAI_BASE_URL` missing `/v1`                            | Use exactly `https://api.auriko.ai/v1`                                                                                       |
| "Model metadata not found" warning    | Built-in metadata not available for custom-provider models | Cosmetic. No action needed                                                                                                   |
| "missing field `models`" warning      | Auriko's model list format differs slightly from OpenAI's  | Cosmetic. No action needed                                                                                                   |
| 401 or "API key is invalid"           | Wrong key value or expired key                             | Run `echo $OPENAI_API_KEY` to check. Verify at `curl -H "Authorization: Bearer $OPENAI_API_KEY" https://api.auriko.ai/v1/me` |
| `codex: command not found`            | Install script PATH not loaded                             | Run `export PATH="$HOME/.codex/bin:$PATH"` or open a new terminal                                                            |
