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

# Codex

> Run OpenAI's Codex CLI on any model in the Opper catalog

[Codex](https://openai.com/codex/) is OpenAI's open-source coding agent for the terminal (Apache-2.0, [source](https://github.com/openai/codex)). It works from natural-language instructions to edit code across your project, run commands, and complete tasks end to end.

Codex reads its model providers from a config file, so adding Opper as one provider lets you run it on Claude, Gemini, DeepSeek, or any other model in the catalog.

## Setup

> [!TIP]
>
> One command, no config files:
>
> ```bash theme={null}
> npx @opperai/cli launch codex --model anthropic/claude-opus-4-8
> ```
>
> This starts Codex with Opper passed as its provider through `-c` flags, for that run only, so `~/.codex/config.toml` is left unchanged. `--model` is optional.

To configure it by hand, add the provider to `~/.codex/config.toml`:

```toml theme={null}
model_provider = "opper"
web_search = "disabled"

[model_providers.opper]
name = "Opper"
base_url = "https://api.opper.ai/v3/compat"
env_key = "OPPER_API_KEY"
wire_api = "responses"
```

`wire_api = "responses"` sends Codex's requests to Opper's Responses endpoint. `web_search = "disabled"` turns off Codex's default cached web search, which the gateway can't serve across providers. The CLI passes both on every run.

Then export your key and start Codex:

```bash theme={null}
export OPPER_API_KEY=your-opper-api-key
codex --model anthropic/claude-opus-4-8
```

## Choosing a model

Pass any Opper model ID with `--model`, or set a default in `config.toml`:

```toml theme={null}
model = "anthropic/claude-sonnet-4-6"
```

Codex needs tool calling and streaming — pick a model the catalog marks with the `tools` capability. Browse IDs in the [model catalog](https://docs.opper.ai/capabilities/models.md).

## Troubleshooting

> [accordion] 401 Unauthorized
>
> Check that `OPPER_API_KEY` is exported in the shell running Codex, and that `env_key` in `config.toml` names that same variable. Opper keys start with `op-`.

> [accordion] 404 Model Not Found
>
> Copy the model ID exactly from the [catalog](https://docs.opper.ai/capabilities/models.md) — it includes the provider prefix, as in `anthropic/claude-sonnet-4-6`.

> [accordion] 502 on Gemini, DeepSeek, and other non-OpenAI models
>
> If the error says `web_search is not supported`, Codex is requesting its default cached web search, which the gateway can't serve for those models. Add `web_search = "disabled"` at the top level of `config.toml`.

> [accordion] Codex ignores the provider
>
> `model_provider = "opper"` and `web_search = "disabled"` have to sit at the top level of `config.toml`, not inside the `[model_providers.opper]` table. TOML tables capture every key that follows them.

## Related

> [card] [Logs](https://docs.opper.ai/control-plane/logs.md)
>
> Every Codex call, with model, latency, tokens, and cost.

> [card] [All apps](https://docs.opper.ai/integrations/overview.md)
>
> Every app that runs on Opper.


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