# Codex with ChatGPT sign-in + API

Pure API mode (see [Codex CLI](https://docs.2api.dev/en/clients/codex/)) 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.

1. Fully quit Codex.

2. Back up `~/.codex/auth.json`, then delete it. **Do not delete** `~/.codex/sessions`. It holds your session history.

3. Start Codex again and sign in with your ChatGPT account.

4. Open `~/.codex/config.toml` and add an `experimental_bearer_token` line under `[model_providers.sub2api]`. Its value is your 2api key:

   ```toml title="~/.codex/config.toml" ins={8}
   model_provider = "sub2api"

   [model_providers.sub2api]
   name = "sub2api"
   base_url = "https://2api.dev/v1"
   wire_api = "responses"
   requires_openai_auth = true
   experimental_bearer_token = "sk-your-key"
   ```

5. Save, quit Codex and open it again, then start a new session.

:::caution
Keep the provider name `sub2api`. You are only resetting the sign-in state and changing the config. Your session history is not lost.
:::