[PR #10671] fix(codex): add OpenAI-Beta header required for Codex API #13521

Closed
opened 2026-02-16 18:18:22 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10671

State: closed
Merged: No


Summary

Fixes #10500

The Codex API endpoint at chatgpt.com/backend-api/codex/responses requires the OpenAI-Beta: responses=experimental header. Without this header, requests can intermittently fail with 404 "Not Found" errors.

Root Cause Analysis

After researching the official OpenAI Codex CLI implementation, I found that the required headers for the Codex API include:

Authorization: Bearer <access_token>
ChatGPT-Account-Id: <account_id>  # Required for org accounts
OpenAI-Beta: responses=experimental  # ← MISSING IN OPENCODE
originator: opencode

The OpenAI-Beta: responses=experimental header was missing from OpenCode's Codex plugin, causing the backend to return 404 errors.

Changes

  • Added OpenAI-Beta: responses=experimental header to the custom fetch function in the Codex OAuth flow

Evidence

From openai/codex test files:

expect(headers?.get("Authorization")).toBe(`Bearer ${token}`);
expect(headers?.get("chatgpt-account-id")).toBe("acc_test");
expect(headers?.get("OpenAI-Beta")).toBe("responses=experimental");
expect(headers?.get("originator")).toBe("pi");

Testing

This header is standard for all Codex API requests and should resolve the intermittent 404 errors for GPT 5.2 Codex users.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10671 **State:** closed **Merged:** No --- ## Summary Fixes #10500 The Codex API endpoint at `chatgpt.com/backend-api/codex/responses` requires the `OpenAI-Beta: responses=experimental` header. Without this header, requests can intermittently fail with 404 "Not Found" errors. ## Root Cause Analysis After researching the [official OpenAI Codex CLI implementation](https://github.com/openai/codex), I found that the required headers for the Codex API include: ```http Authorization: Bearer <access_token> ChatGPT-Account-Id: <account_id> # Required for org accounts OpenAI-Beta: responses=experimental # ← MISSING IN OPENCODE originator: opencode ``` The `OpenAI-Beta: responses=experimental` header was missing from OpenCode's Codex plugin, causing the backend to return 404 errors. ## Changes - Added `OpenAI-Beta: responses=experimental` header to the custom fetch function in the Codex OAuth flow ## Evidence From [openai/codex test files](https://github.com/badlogic/pi-mono/blob/ea93e2f3da0d3bb7d78da437d32f8a9d6becf3e1/packages/ai/test/openai-codex-stream.test.ts#L76-L80): ```typescript expect(headers?.get("Authorization")).toBe(`Bearer ${token}`); expect(headers?.get("chatgpt-account-id")).toBe("acc_test"); expect(headers?.get("OpenAI-Beta")).toBe("responses=experimental"); expect(headers?.get("originator")).toBe("pi"); ``` ## Testing This header is standard for all Codex API requests and should resolve the intermittent 404 errors for GPT 5.2 Codex users.
yindo added the pull-request label 2026-02-16 18:18:22 -05:00
yindo closed this issue 2026-02-16 18:18:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13521