An Interchange inference provider for OpenAI Codex ("Login with ChatGPT"):
OAuth constants and token mapping for @corbits/oauth-core, and a
Responses-protocol adapter for Codex's ChatGPT backend built on
@corbits/openai-responses. It does not implement login flow orchestration,
token storage, or usage/quota reporting — a host composes those itself from
@corbits/oauth-core directly.
bun add github:corbitsdev/corbits-codex-providerThe package ships TypeScript source and needs no build step; Bun consumes it
directly. @intx/inference and @intx/types are peer dependencies and
resolve to the host's own copy.
import type { AdapterManifest } from "@intx/inference";
import { createDefaultScheduler } from "@intx/inference";
import { loadAdapterRegistry } from "@intx/inference/providers";
import type { InferenceSource } from "@intx/types/runtime";
import { withCodexContentTypeRepair } from "@corbits/codex-provider";
const manifest: AdapterManifest = [
{
provider: "codex",
specifier: "@corbits/codex-provider",
export: "createCodexResponsesAdapter",
},
];
const adapters = await loadAdapterRegistry(manifest);
const dependencies = {
adapters,
fetch: withCodexContentTypeRepair(fetch),
scheduler: createDefaultScheduler(),
};
// Quirks ride on the `InferenceSource` the harness resolves at call time,
// not on the manifest entry:
const source: InferenceSource = {
id: "codex/1",
provider: "codex",
baseURL: "https://chatgpt.com/backend-api",
apiKey: "",
model: "gpt-5.5",
quirks: {
productName: "My Harness",
environmentTagName: "my_harness_environment",
},
};codexOAuthConfig, exchangeCodexCode, and refreshCodexTokens plug
directly into @corbits/oauth-core's startOAuthLogin and
createTokenSession, as shown in that package's own README.
See src/index.ts for the full public surface and its TSDoc; the Codex
quirks shape is CodexQuirks in src/quirks.ts.
- Codex has no separate API-key credential path — only the ChatGPT OAuth subscription token is supported.
- A host's own operating prompt rides as the leading
developermessage viawrapCodexBridgeMessage. This package does not send aninstructionsfield. CodexQuirks(productName,environmentTagName) has no default: there is no honest generic product name, so an absent quirks bag is a validation error, not a silently-generic adapter.createCodexResponsesAdapteris a plain(source, quirks?)AdapterFactory, loadable from anAdapterManifestentry like any other provider.withCodexContentTypeRepairexists because the backend omitscontent-typeon some streamed responses despite a valid SSE body; it restores the header from the request's ownacceptcommitment rather than guessing.- Requests identify as the public Codex CLI (
originator: codex_cli_rs, the CLI's own OAuth client id) because the ChatGPT backend only serves that client; the ChatGPT subscription token from that login is the only credential this package uses, and OpenAI closing that door is an outage this package cannot route around, not a bug in it.
- No API-key credential path — Codex has none.
- No live model catalog (
GET /codex/models) — a host that needs one fetches it itself. - No usage/quota or rate-limit surfaces — out of scope for an inference provider adapter.
- No login flow orchestration or token storage — call
@corbits/oauth-coredirectly withcodexOAuthConfig.
LGPL-2.1-or-later.