Support ChatGPT subscription (Codex OAuth) as a model provider — pi-ai already ships the client #83
Replies: 5 comments
|
Would this design be generalized for other subscription providers ? |
|
I forked and tried adding ChatGPT OAuth implementation, but can't call chatgpt.com/backend-api. They always returns error response: So I guess their WAF blocks Cloudflare Workers IP. |
|
I tested both the compatibility-gateway path and the new official Codex app-server path against a local Cloudflare OS checkout. The gateway works today with Cloudflare OS's existing OpenAI Responses provider, including real tool calls, Gadget creation, and reload persistence. But it depends on the private The more durable direction now looks like
This is not really another
A tiny local companion is still necessary because a Worker cannot launch the Codex process. It would only own app-server's stable stdio JSONL process and managed ChatGPT login; the runtime adapter, durable chat mapping, tool execution, and approvals would live in Cloudflare OS. For a deployed OS, that companion could remain local behind an authenticated named Cloudflare Tunnel, avoiding the Workers-egress WAF failure already reported above. Would maintainers be interested in this |
|
One useful simplification after checking the current transport docs more closely: if an experimental MVP is acceptable, no custom HTTP/SSE companion is required. App-server already exposes an experimental WebSocket JSON-RPC transport and built-in capability-token / signed-bearer authentication. That makes the lean boundary:
For local OS, the runtime can connect to a loopback app-server listener. For deployed OS, the same authenticated listener can remain on the user's machine behind a TLS Cloudflare Tunnel. A tiny launcher/service may improve onboarding, but it does not need to translate protocols or own credentials; the official Codex process owns both. The proposed OS-native runtime seam and the rest of the proof remain the same. This is experimental because app-server's WebSocket transport and |
|
I built an experimental Cloudflare OS integration on this fork branch. It uses OpenAI's official The parts I've verified are:
The fork keeps this single-tenant. The launcher uses an isolated Codex home, disables inherited apps and plugins, removes API-key environment variables, and protects the local listener with a random capability token. A multi-user deployment would need one app-server identity per user rather than sharing the deployment owner's ChatGPT account. I put the screenshots, deployment options, and open design questions in this separate discussion. |
Uh oh!
There was an error while loading. Please reload this page.
The "Add Model" flow currently requires an API key for every provider. Many users already pay for a ChatGPT subscription, and OpenAI now openly tolerates third-party use of Codex OAuth (they open-sourced a plugin calling Codex from Claude Code, and enabled OAuth for OpenClaw). Platforms like exe.dev already offer "connect your ChatGPT subscription" as a first-class model source.
Notably,
@earendil-works/pi-ai0.83.0 — already vendored here — ships everything needed:api/openai-codex-responses(speaks tochatgpt.com/backend-api, WebSocket + SSE fallback, auth via access token +chatgpt-account-id) and theopenai-codexmodel catalog. The wiring inai-models.ts(API_STREAMS / catalogModel / a direct-path handle) looks thin.The design questions would be: (1) the "Sign in with ChatGPT" OAuth flow and refresh-token custody — presumably a DO, following the same pattern as the Cloudflare gatekeeper's OAuth; (2) subscription traffic bypassing AI Gateway cost accounting.
Would love to see this in-tree someday!
All reactions