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

# Codex CLI

> Run Codex CLI on RedPill through Private AI Proxy, or configure it by hand.

Codex speaks the Responses protocol. Private AI Proxy configures it automatically.

## With Private AI Proxy

1. Install [Private AI Proxy](/get-started/private-ai-proxy), sign in, and turn on **Protected**.
2. On the **Agents** screen, connect **Codex** and pick a model from the verified catalog.
3. Start `codex`.

The app adds a custom model provider to `~/.codex/config.toml` that points at its local API with an
agent-scoped token, and restores the file when you disconnect or stop Protected.

From the CLI, the same connection is:

```bash theme={null}
pap agents connect codex
```

## Without the Proxy

Add RedPill as a custom provider in the user-level configuration; Codex ignores `model_provider`
and `model_providers` in a project-local `.codex/config.toml`.

```bash theme={null}
export REDPILL_AI_API_KEY="YOUR_API_KEY"
```

```toml ~/.codex/config.toml theme={null}
model = "openai/gpt-5.6-sol"
model_provider = "redpill"

[model_providers.redpill]
name = "RedPill AI"
base_url = "https://api.redpill.ai/v1"
env_key = "REDPILL_AI_API_KEY"
wire_api = "responses"
```

Pick the model from [`GET /v1/models`](/api-reference/models); choose one that declares `tools`.

This path does not verify ACI locally. For confidential-only routing, use an `is_tee: true` model
with `base_url = "https://tee.redpill.ai/v1"`. See [Verified ACI clients](/guides/verified-aci-client).

## Check the connection

Start `codex` and run one bounded tool task. With the Proxy, the provider in `config.toml` points
at `http://127.0.0.1:4180/v1`; without it, at `https://api.redpill.ai/v1`.

## Troubleshooting

| Symptom                               | Check                                                                            |
| ------------------------------------- | -------------------------------------------------------------------------------- |
| Codex ignores the Proxy               | Confirm **Connected** in the app and that Protected is on, then restart `codex`. |
| Codex still uses the default provider | Confirm `model_provider = "redpill"` is at the top level of the user-level file. |
| Chat works but tools fail             | Choose a model that declares `tools` in the live catalog.                        |

## References

* [Codex custom model providers](https://learn.chatgpt.com/docs/config-file/config-advanced#custom-model-providers)
* [RedPill Responses API](/api-reference/responses)
* [RedPill model catalog](/api-reference/models)
