> For the complete documentation index, see [llms.txt](https://docs.cortecs.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cortecs.ai/integration-examples/coding/codex-cli.md).

# Codex CLI

Use Cortecs models with Codex CLI

[Codex CLI](https://developers.openai.com/codex/cli) is OpenAI's terminal-based coding agent. Connect it to Cortecs through the OpenAI-compatible Responses API.

{% hint style="info" %}
Before you begin, create a Cortecs API key by following the [Member quickstart](/member-quickstart.md) and choose a tool-calling model from the [model catalog](https://cortecs.ai/serverlessModels).
{% endhint %}

## 1. Install Codex CLI

On macOS, Linux, or WSL:

```bash
curl -fsSL https://chatgpt.com/codex/install.sh | sh
```

Alternatively, install Codex CLI with npm:

```bash
npm install -g @openai/codex
```

See the [Codex CLI documentation](https://developers.openai.com/codex/cli) for othe platforms.

## 2. Add Cortecs

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

```toml
model = "<MODEL_ID>"
model_provider = "cortecs"

[model_providers.cortecs]
name = "Cortecs"
base_url = "https://api.cortecs.ai/v1"
experimental_bearer_token = "<CORTECS_API_KEY>"
wire_api = "responses"
```

Replace `<MODEL_ID>` with the exact ID from the model catalog and `<CORTECS_API_KEY>` with your generated key. For more options, see the [Codex configuration reference](https://developers.openai.com/codex/config-reference).

## 3. Start Codex CLI

Launch Codex within your desired project directory:

```bash
codex # To launch with the model set in the config
codex -m <MODEL_ID> # To launch with a different model
```

Run `/status` inside Codex to confirm that the active model and provider are set to Cortecs.

## Troubleshooting

### Web search rejection

Some of the provided models may reject Codex's web search tool. Disable web search for a single run when using an affected model:

```bash
codex --model "<MODEL_ID>" --config 'web_search="disabled"'
```

To disable it for every Codex session, add this top-level setting to `~/.codex/config.toml`:

```toml
web_search = "disabled"
```

Place the setting outside `[model_providers.cortecs]`, then restart Codex.

### Unsupported reasoning effort

Reasoning levels vary by model and provider. For some models is necessary to provide the reasoning level upon launch.

Use a supported value for a single run:

```bash
codex --model "<MODEL_ID>" --config 'model_reasoning_effort="high"'
```

To set the value for every Codex session, add it as a top-level setting in `~/.codex/config.toml`.
