Skip to content

Commit 880093f

Browse files
vladlearnsVladyslav Tkachenko
authored and
Vladyslav Tkachenko
committed
docs: add ChatGPT sign-in authentication flow and documentation
1 parent 44022db commit 880093f

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,27 @@ Install globally:
7777
npm install -g @openai/codex
7878
```
7979

80-
Next, set your OpenAI API key as an environment variable:
80+
Next, you need an OpenAI API key. You have two options:
81+
82+
### Option 1: Sign in with ChatGPT
83+
84+
If you have a ChatGPT Plus or Pro subscription, you can sign in directly with your ChatGPT account to generate an API key:
85+
86+
```shell
87+
codex
88+
```
89+
90+
When prompted, select "Sign in with ChatGPT" and follow the browser authentication flow. This will:
91+
92+
1. Open your browser to the OpenAI login page
93+
2. After signing in, automatically generate an API key for Codex
94+
3. Store the key securely for future use
95+
96+
> **Note:** ChatGPT Plus and Pro subscribers can receive API credits through this sign-in flow.
97+
98+
### Option 2: Use an existing API key
99+
100+
If you already have an OpenAI API key, you can set it as an environment variable:
81101

82102
```shell
83103
export OPENAI_API_KEY="your-api-key-here"
@@ -152,7 +172,7 @@ ChatGPT-level reasoning **plus** the power to actually run code, manipulate
152172
files, and iterate - all under version control. In short, it's _chat-driven
153173
development_ that understands and executes your repo.
154174

155-
- **Zero setup** - bring your OpenAI API key and it just works!
175+
- **Zero setup** - sign in with your ChatGPT account or bring your OpenAI API key and it just works!
156176
- **Full auto-approval, while safe + secure** by running network-disabled and directory-sandboxed
157177
- **Multimodal** - pass in screenshots or diagrams to implement features ✨
158178

@@ -220,6 +240,7 @@ The hardening mechanism Codex uses depends on your OS:
220240
| `codex` | Interactive REPL | `codex` |
221241
| `codex "..."` | Initial prompt for interactive REPL | `codex "fix lint errors"` |
222242
| `codex -q "..."` | Non-interactive "quiet mode" | `codex -q --json "explain utils.ts"` |
243+
| `codex --login` | Force ChatGPT sign-in flow | `codex --login` |
223244
| `codex completion <bash\|zsh\|fish>` | Print shell completion script | `codex completion bash` |
224245

225246
Key flags: `--model/-m`, `--approval-mode/-a`, `--quiet/-q`, and `--notify`.
@@ -499,6 +520,12 @@ Any model available with [Responses API](https://platform.openai.com/docs/api-re
499520

500521
It's possible that your [API account needs to be verified](https://help.openai.com/en/articles/10910291-api-organization-verification) in order to start streaming responses and seeing chain of thought summaries from the API. If you're still running into issues, please let us know!
501522

523+
</details>
524+
<details>
525+
<summary>How do I sign in with my ChatGPT account?</summary>
526+
527+
Run `codex` and select "Sign in with ChatGPT" when prompted, or use `codex --login` to force the sign-in flow. This will open your browser to authenticate with OpenAI and generate an API key for Codex. ChatGPT Plus and Pro subscribers can receive API credits through this flow. The key is securely stored in `~/.codex/auth.json`.
528+
502529
</details>
503530

504531
<details>

0 commit comments

Comments
 (0)