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

# Use OpenAI Codex with abliteration.ai

> Use OpenAI's Codex CLI with abliteration.ai by registering a custom provider in ~/.codex/config.toml.

**To use Codex with abliteration.ai**, register a custom model provider in `~/.codex/config.toml` pointing at `https://api.abliteration.ai/v1` with `wire_api = "responses"`. The [Codex CLI](https://developers.openai.com/codex) then runs unchanged — same workflow, routed through abliteration.

## Install

```sh theme={"system"}
npm install -g @openai/codex
```

## Configure

Codex reads its configuration from `~/.codex/config.toml` (user-level). Create it if it doesn't exist:

```sh theme={"system"}
mkdir -p ~/.codex
```

Add the following to `~/.codex/config.toml`:

```toml theme={"system"}
[model_providers.abliteration]
name = "abliteration.ai"
base_url = "https://api.abliteration.ai/v1"
wire_api = "responses"
env_key = "ABLITERATION_API_KEY"

[profiles.abliteration]
model = "abliterated-model"
model_provider = "abliteration"
web_search = "live"
```

`env_key` tells Codex **which environment variable** holds your API key — it does not contain the key itself. Export it separately:

```sh theme={"system"}
export ABLITERATION_API_KEY="ak_YOUR_API_KEY"
```

<Note>
  Codex only reads keys from environment variables. Setting the key inside `config.toml` will not work. Use a tool like `direnv` or your shell rc file if you want it persisted across terminals.
</Note>

## Run

```sh theme={"system"}
codex --profile abliteration
```

To make `abliteration` the default so plain `codex` picks it up, add this line at the top of `~/.codex/config.toml`:

```toml theme={"system"}
profile = "abliteration"
```

Then:

```sh theme={"system"}
codex
```

## Per-project config

Codex also looks for `.codex/config.toml` inside trusted projects. Use this to override the model or profile for a single repo without touching the user-level config.

## Config precedence

When the same setting is defined in multiple places, the order is:

1. CLI flags (highest)
2. Profile (`--profile <name>`)
3. Project config (`.codex/config.toml`)
4. User config (`~/.codex/config.toml`)

If Codex isn't using your abliteration provider, check whether something higher in this chain is overriding it.

## Web search

Web search is enabled with `web_search = "live"` in the profile (already shown above). You'll need to turn on web search in the [console](https://abliteration.ai/console) too. See the [web search overview](/capabilities/web-search) for full details.

## Troubleshooting

```sh theme={"system"}
echo $ABLITERATION_API_KEY        # confirm the key is exported in this shell
cat ~/.codex/config.toml          # confirm the config is present and correct
codex --profile abliteration      # run with the profile explicitly
```

## Notes

* Policy rules attached to your API key apply to every Codex turn.
* For headless / CI runs, use `codex exec` with `--approval-mode auto`.
