File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed
Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ program
8080 rawOpts . apiKey ||
8181 process . env . OPENAI_API_KEY ||
8282 process . env . CODEX_API_KEY ||
83- "" ,
83+ undefined ,
8484 verbose : rawOpts . verbose ,
8585 } ;
8686
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export async function runCodegen(opts: CodegenOptions): Promise<void> {
4141 // -----------------------------------------------------------------------
4242 // 3. Start Codex session
4343 // -----------------------------------------------------------------------
44- const codex = new Codex ( { apiKey : opts . apiKey } ) ;
44+ const codex = new Codex ( opts . apiKey ? { apiKey : opts . apiKey } : { } ) ;
4545
4646 // The agent gets its own workspace as the working directory, with
4747 // additional read access to the server source (and existing client if
@@ -132,9 +132,12 @@ export async function runCodegen(opts: CodegenOptions): Promise<void> {
132132// ---------------------------------------------------------------------------
133133
134134function validatePrerequisites ( opts : CodegenOptions ) : void {
135+ // API key is optional — if omitted the Codex CLI will use its locally
136+ // stored session (from `codex` → "Sign in with ChatGPT").
135137 if ( ! opts . apiKey ) {
136- throw new Error (
137- "API key required. Set OPENAI_API_KEY / CODEX_API_KEY or use --api-key." ,
138+ log (
139+ opts ,
140+ "No API key provided; relying on local Codex CLI authentication." ,
138141 ) ;
139142 }
140143
Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ export interface CodegenOptions {
1515 effort : "low" | "medium" | "high" | "xhigh" ;
1616 /** Maximum number of generation + verification attempts */
1717 maxAttempts : number ;
18- /** OpenAI API key */
19- apiKey : string ;
18+ /** OpenAI API key (optional — if omitted, uses local Codex CLI auth) */
19+ apiKey ? : string ;
2020 /** Print verbose output */
2121 verbose : boolean ;
2222}
You can’t perform that action at this time.
0 commit comments