# Codex setup

## Prerequisites

Install the official Codex CLI and check codex --version. Use an available model verified for the Responses API, streaming and tool calling. A Chat Completions model is not automatically a working Codex model. Names containing “codex” do not by themselves prove protocol compatibility. The following profile is prepared for integration; actual upstream behavior still needs validation.

## Create a separate profile

For Codex 0.134.0 and later, save the TOML block below as ~/.codex/u9ai.config.toml. On Windows the default location is %USERPROFILE%\.codex\u9ai.config.toml. Replace the model placeholder locally and set your key in the terminal environment. Do not overwrite your existing config.toml or auth.json.

```toml
model = "YOUR_RESPONSES_MODEL_ID"
model_provider = "u9ai"

[model_providers.u9ai]
name = "U9 AI"
base_url = "https://u9ai.ai/v1"
env_key = "U9AI_API_KEY"
wire_api = "responses"
requires_openai_auth = false
```

```bash
export U9AI_API_KEY="YOUR_U9AI_API_KEY"
codex --profile u9ai
```

```powershell
$env:U9AI_API_KEY = "YOUR_U9AI_API_KEY"
codex --profile u9ai
```
## Version differences

Current Codex uses a separate profile file with top-level keys. It no longer loads the old [profiles.u9ai] table from config.toml. Older releases use a different profile format; upgrade or follow the official documentation for your installed version. A project AGENTS.md supplies instructions, not provider authentication. Current Codex ignores provider-auth overrides in project .codex/config.toml; put this provider profile at user level.

## Acceptance and rollback

First run the read-only /models check from [quickstart](/en/docs/quickstart). Then, with an available Responses model, ask a short question in an empty test directory. Confirm streaming and a complete tool-call round trip before normal work. Check request history and costs; tests may incur charges. Start codex without --profile u9ai to use your original default configuration. Existing project or command-line overrides can still take precedence: inspect them if the wrong provider is active.

Download [this guide](/en/docs/codex.md) and the [AGENTS.md project instruction template](/en/docs/AGENTS.md). Merge project instructions instead of replacing existing rules.

[Official advanced configuration](https://learn.chatgpt.com/docs/config-file/config-advanced) · [Official configuration reference](https://developers.openai.com/codex/config-reference/). This guide was checked against official documentation on 2026-10-24; verify version-specific behavior after upgrading.
