Codex (ChatGPT subscription)
Sign in with sc auth codex and run Claude Code's roles on GPT models through your ChatGPT Plus or Pro subscription, with no API key.
Do this for me on this machine: sign in to Codex with my ChatGPT subscription and make it available as a profile. This is superclaude's own guide. Read all of it as raw Markdown first, without summarizing it: curl -fsSL "https://superclaude.io/docs/codex-setup.md" Then: 1. Tell me in a few lines what you are going to change. 2. Do every step yourself: run the commands, edit the files, check each result. 3. Stop only for what needs me: a browser sign-in, a choice between options, a secret to paste. 4. Finish by showing it works, and tell me the one command I will use from now on. Other superclaude pages, if you need them: https://superclaude.io/llms.txt
-
Declare the codex endpoint
[endpoints.codex] url = "https://chatgpt.com/backend-api/codex" format = "openai-responses" auth = "oauth" [endpoints.codex.oauth] provider = "codex"The
config.tomlthatscwrites on first run carries this endpoint commented out. Uncomment it or paste the block. Do this before you sign in, because the login readsoauth.provider. -
Sign in
sc auth codexYour browser opens at the OpenAI sign-in page, and
scwaits up to five minutes. On success it prints:sc: signed in to `codex` as `default` (account <account-id>). -
Add a profile and check it
[profiles.codex] opus = { slug = "codex/gpt-5.5", reasoning = { effort = "high" } } sonnet = { slug = "codex/gpt-5.4", reasoning = { effort = "medium" } } haiku = { slug = "codex/gpt-5.4", reasoning = { effort = "low" } }sc profiles codexThe part after
codex/is any model id your subscription serves. The ids above come from the Codex profile that the starterconfig.tomlcarries commented out. -
Launch on it
sc -u codex <project> <agent>A profile row whose OAuth endpoint has no signed-in identity fails the launch before Claude Code starts, with the message in the fold below.
The tokens go into config.toml. The file stays at mode 0600, sc never prints a token, and the daemon refreshes the access token when a request finds it within two minutes of expiry. There is nothing to rotate by hand.
Sign in on a machine with no browser
sc auth codex --devicesc prints a URL and a one-time code:
To sign in on another device, open:
https://auth.openai.com/codex/device
and enter the code:
<code>Open the URL on any device and enter the code; sc finishes when you approve it.
The browser flow needs port 1455 on localhost, because the provider’s OAuth client registration fixes it. If another sc auth or another Codex client holds that port, the login fails with cannot bind the OAuth loopback callback server. Stop the other process and retry, or use --device, which needs no local port.
See what sc stored for my sign-in
After a login, the identity table looks like this. The values are written by sc auth; leave the table alone, because the daemon rewrites it on every refresh:
[endpoints.codex.oauth.identities.default]
refresh_token = "<written by sc auth>"
access_token = "<written by sc auth>"
expires_at = 0
account_id = "<written by sc auth>"expires_atis the access token’s expiry, in Unix seconds.account_idis your ChatGPT account id, read from the token. The gateway sends it as theChatGPT-Account-Idheader, so Codex bills the right account.
List every OAuth endpoint and its stored labels:
sc auth listOAuth identities — ~/.superclaude/config.toml
codex [codex]
default ••••xY valid (52m left) account <account-id>| Status | Meaning |
|---|---|
valid (<n>m left) | the access token is good for more than two minutes |
expiring soon (refreshes on next use) | under two minutes left |
expired (refreshes on next use) | past expiry; the next request refreshes it |
(no access token yet) | the identity has no expiry recorded |
Expired is not an error. The gateway refreshes the token before it sends a request, and writes the new pair back to config.toml.
With no signed-in identity, the launch fails with:
endpoint `codex` (role `opus`) has auth=oauth but no signed-in identities — run `sc auth codex [--label <name>]`Add a second ChatGPT account
sc auth codex --label work
sc auth remove codex --label workEvery stored label joins the endpoint’s pool, and the gateway spreads requests across them. Codex rate-limits per ChatGPT account, not per token, so a second label for the same account gives you two tokens that share one limit. Add labels only for different accounts; sc cannot check this, and prints a note when you add a second label. remove always needs --label, including for default.
Sign in again
sc auth codex --label defaultSigning in to an existing label replaces its tokens. You need it when the refresh token is rejected, for example after you revoke access or your subscription lapses, or when Codex answers 401 or 403 although the local token had not expired. In both cases the session gets an error naming the fix:
oauth identity `default` for endpoint `codex` needs sign-in — run `sc auth codex --label default`If the pool holds another label, the gateway also cools the failed label for 60 seconds, so the next request goes to the other label while you sign in again.
Sign in to a different OAuth endpoint
| Command | What it does |
|---|---|
sc auth <endpoint> | browser login into the default label |
sc auth <endpoint> --label <name> | log in another, named identity |
sc auth <endpoint> --device | login with a one-time code, for a machine with no browser |
sc auth list | every OAuth endpoint’s labels, masked tokens and expiry |
sc auth remove <endpoint> --label <name> | delete one stored identity |
sc auth supports two providers, codex and grok. Any other oauth.provider value fails with unknown oauth provider.
Next: Use Codex