Codex
Codex with ChatGPT sign-in + API
Sign in to the account with ChatGPT and send model requests through 2api. For people who also use the mobile app, official plugins and similar features.
Pure API mode (see Codex CLI) can’t use these features, which need a ChatGPT sign-in:
- Continuing or viewing Codex sessions in the mobile app
- Official plugins and connectors that need a ChatGPT sign-in
- Features such as long-term goals and background tasks
If you need them, set it up as follows. You sign in with ChatGPT, and model requests still go through 2api and are charged there. Ordinary API users can skip this page.
-
Fully quit Codex.
-
Back up
~/.codex/auth.json, then delete it. Do not delete~/.codex/sessions. It holds your session history. -
Start Codex again and sign in with your ChatGPT account.
-
Open
~/.codex/config.tomland add anexperimental_bearer_tokenline under[model_providers.sub2api]. Its value is your 2api key:~/.codex/config.toml model_provider = "sub2api"[model_providers.sub2api]name = "sub2api"base_url = "https://2api.dev/v1"wire_api = "responses"requires_openai_auth = trueexperimental_bearer_token = "sk-your-key" -
Save, quit Codex and open it again, then start a new session.