# Use Codex

> Run Claude Code sessions on a ChatGPT Codex subscription with sc -u codex, keep Claude on the main loop while Codex serves subagents, and read Codex rate limits.
>
> Run a session on GPT models through your ChatGPT subscription with sc -u codex. You need to be signed in first with sc auth codex.

1. Launch on Codex

   ```sh
   sc -u codex <project> <agent>
   ```

   Claude Code opens with every role answered by a GPT model on your ChatGPT Plus or Pro subscription. `sc` checks the profile before Claude Code opens, so a missing sign-in fails there with a message that names the fix ([Codex setup](/docs/codex-setup) covers the sign-in). On this profile your Claude login is not used ([what changes](/docs/models#how-roles-map-to-models)).

2. Check your Codex usage

   ```sh
   sc usage --endpoint codex
   ```

   `sc` prints your plan and each limit window, with percent used and when it resets.

To keep Claude on the main loop and send only subagents to Codex, build a hybrid profile (first fold below).

**Claude main loop, Codex subagents**

This profile needs the `anthropic` passthrough endpoint from [Anthropic and Claude](/docs/provider-anthropic#keep-claude-on-some-roles) next to `codex`:

```toml
[profiles.claude-codex]
opus   = { slug = "anthropic/opus" }
sonnet = { slug = "codex/gpt-5.4", reasoning = { effort = "high" } }
haiku  = { slug = "codex/gpt-5.4", reasoning = { effort = "low" } }
```

```sh
sc profiles claude-codex
sc -u claude-codex <project> <agent>
```

The main loop runs on Claude Opus with your login. A subagent that asks for Sonnet or Haiku, and Claude Code's background requests, go to Codex. A Fable request stays on Claude, because a hybrid leaves an unmapped role on Anthropic. `-m sonnet` moves the main loop onto Codex too. The [recommended walkthrough](/docs/custom-profiles#recommended-profile-walkthrough) builds the same shape with DeepSeek and shows how to check the routing.

**Pick the model and reasoning effort for the main loop**

`-m` is an alias for Claude Code's `--model`. On a gateway profile it picks which row serves the main loop:

```sh
sc -u codex <project> <agent> -m sonnet
```

The gateway sends Codex the effort as `reasoning.effort` and asks for a reasoning summary, which Claude Code shows as a thinking block ([how levels map](/docs/provider-openai-compatible#the-openai-responses-api)). A request's own level wins over the row's. The Codex backend rejects sampling fields, so the gateway strips `temperature` and `top_p` from every Codex request, and a `temperature` on a Codex row has no effect.

Role inheritance, the `fable` rule and the row fields are on [Profiles](/docs/custom-profiles#write-your-own-profile).

**Read Codex usage and handle a 429**

`sc usage` polls every configured OAuth account through the daemon. For each Codex identity it shows the plan and each limit window, with percent used and when it resets. `--json` prints the same as JSON; `pct_used` is the stable field. If the daemon is unreachable, Codex rows show `Error` rather than disappearing.

The gateway reads each `429` from Codex:

- **A throttle with a wait.** A `Retry-After` header means a short wait. The gateway waits and retries inside its retry budget, 60 seconds by default, and hands a longer wait back to Claude Code.
- **A spent plan window.** Codex sends `usage_limit_reached` with a reset time and no `Retry-After`. With two or more identities, the gateway takes that identity out of rotation until the window resets, or for 15 minutes if no reset time came. With one identity it retries with backoff inside the budget, then returns the `429` with `Retry-After` set to the reset time.
- **Every identity cooling down.** Requests get `429 all keys for this endpoint are rate-limited (cooling down)`.

Codex rate-limits per ChatGPT account, so a second `--label` adds headroom only if it signs in a different account. The general key-pool rules are on [How the gateway routes](/docs/gateways#key-pools-and-retries).

**A Codex launch or request fails**

| You see | Do this |
|---|---|
| Launch fails: `has auth=oauth but no signed-in identities` | `sc auth codex` |
| Requests fail: `oauth identity <label> for endpoint codex needs sign-in` | `sc auth codex --label <label>` |
| `429 all keys for this endpoint are rate-limited` | Every identity's window is spent. `sc usage --endpoint codex` shows the reset time; launch with `sc -u direct <project> <agent>` meanwhile, which runs that session without the gateway. |
| `profile <name> defines no fable role` | A full-gateway Codex profile got a Fable request. Add a `fable` row, or pick another model with `-m`. |
| `targets endpoint codex, which has no [endpoints.codex]` | The endpoint block is still commented out. See [Codex setup](/docs/codex-setup). |
| `-i/--incognito is not supported with the hybrid per-role routing profile` | Drop `-i`, or use the full `codex` profile. |
| `temperature` on a Codex row changes nothing | Codex forbids sampling fields; tune with `reasoning` instead. |
