codex-fast-proxy
Codex App Fast proxy and auth-split for third-party OpenAI-compatible APIs. Supports Sign in with ChatGPT, priority service_tier, Responses API benchmark, enable/check/update/uninstall.
What it does
Use this skill when the user wants Codex to manage the local auth-split and Fast proxy for Codex App.
Trigger patterns
- Enable requests such as "enable Codex Fast proxy".
- App Fast requests such as "make Codex App use Fast".
- Provider-specific requests such as "enable Fast for PackyAPI".
- ChatGPT login compatibility requests such as "plugins work but model requests return 401".
- Benchmark requests such as "run the Fast proxy benchmark" or "check whether my provider supports Fast".
- Upstream URL changes such as "set the Codex Fast proxy upstream to https://api.example.com/v1".
- Maintenance requests such as "show status", "check updates", "stop", or "uninstall".
How to execute
Run the manager as the source of truth:
python -m codex_fast_proxy doctor
python -m codex_fast_proxy install --start
python -m codex_fast_proxy install --start --use-provider-auth-file
python -m codex_fast_proxy prepare-chatgpt-login
python -m codex_fast_proxy prepare-chatgpt-login --apply
python -m codex_fast_proxy verify-upstream --upstream-base https://api.example.com/v1
python -m codex_fast_proxy set-upstream --upstream-base https://api.example.com/v1
python -m codex_fast_proxy set-upstream --use-provider-auth-file
python -m codex_fast_proxy set-upstream --clear-upstream-auth
python -m codex_fast_proxy set-upstream --service-tier-policy auto
python -m codex_fast_proxy set-upstream --service-tier-policy inject_missing
python -m codex_fast_proxy status
python -m codex_fast_proxy check-update
python -m codex_fast_proxy benchmark
python -m codex_fast_proxy autostart --quiet
python -m codex_fast_proxy stop --force
python -m codex_fast_proxy uninstall --defer-stop
python -m codex_fast_proxy uninstall
Safety model
- Installing the repo or skill must not change Codex provider config.
- Enable with
install --start; it starts the local proxy before switching Codex config. - Enable also installs one user-level Codex
SessionStarthook in~/.codex/hooks.jsonand enables the Codex hooks feature flag. Newer Codex builds usefeatures.hooks = true; older docs/builds may refer tofeatures.codex_hooks. During the CLI/App transition, write both keys and treat either key as enabled. The hook starts a missing proxy on future Codex sessions only when the recorded provider still points to the local proxy. It must not restart an already healthy proxy just because runtime code is stale. Current Codex builds may also require a trusted hook state entry, so treatstartup_hook: trueas installed, enabled, and trusted; ifstartup_hook_trustreportsmodifiedoruntrusted, rerun enable/update instead of relying on~/.codex/hooks.jsonalone. - After an enabled update,
install --startcompares the running proxy runtime with the installed code and restarts stale proxy runtime before returning when config still points to the local proxy. Codex may fireSessionStartfor each new or resumed session;autostart --quietdoes not log normal no-op checks and does not refresh stale runtime implicitly. - Do not run plain
installto enable the proxy; the manager rejects config switching without--start. - Default service tier policy is
auto: ChatGPT-login or unclear states preserve Codex App/CLI Fast choices, while API-key mode can inject priority when Codex omitsservice_tierbecause the App Fast UI may not be available. Use--service-tier-policy inject_missingonly when the user explicitly asks for global Fast injection and accepts that Codex App's Fast UI toggle will no longer control missing tiers. Use--service-tier-policy preserveonly when the user explicitly wants no proxy-side Fast injection. - Before first enable or model-path setting changes,
install --startverifies the candidate upstream and auth source with one side-path Codex-stylePOST /v1/responsesrequest usingstream=true. If verification fails, do not pass--no-verifyunless the user explicitly accepts that future Codex model requests may fail. - Existing enabled installs that do not yet have
service_tier_policyin settings are legacy global-Fast installs when they do not also have split upstream auth; preserve that behavior asinject_missingunless the user explicitly asks for App-controlled Fast. Missing policy plus split upstream auth belongs to the ChatGPT-login auth split path and should be treated as App-controlledpreserve. - For ChatGPT account login compatibility, prefer the proxy-managed provider auth file over editing
auth.json, passing literal keys, or writing global user environment variables. This makes the proxy replace the upstream model-providerAuthorizationheader for requests already routed through the local proxy while leaving ChatGPT plugin/GitHub/App connector requests alone. In this override mode, the proxy also drops unexpectedCookieheaders before forwarding provider API requests. Existing--upstream-api-key-env <ENV_NAME>installs remain supported as an advanced compatibility path. - When the user wants ChatGPT login compatibility, run
prepare-chatgpt-loginas a dry run first. It may find the current working provider key inauth.jsonor the environment, but it must not print the key. Report the non-secret JSON fields, ask for approval, then runprepare-chatgpt-login --apply. After apply, runset-upstream --use-provider-auth-fileso a streaming/v1/responsesside-path verification succeeds before settings are saved. - If
set-upstream --use-provider-auth-filereturnsrestart_required=trueor a followingstatusreportsneeds_restart=true, do not tell the user they can sign in with ChatGPT yet. Explain that provider auth was verified and saved, but the running proxy has not loaded the new override yet. The user must restart Codex App or explicitly allowpython -m codex_fast_proxy startbefore signing in with ChatGPT. - After provider auth split is active and
status.needs_restart=false, tell the user they can sign in with ChatGPT, and report thechatgpt_login_windows_troubleshootingJSON field when present. - If proxy startup or config switching fails, the manager restores the backed-up config before returning.
- Use
set-upstreamwhen the user wants to change the provider URL, upstream auth source, or service tier policy while the proxy is already enabled. It must keep Codex config pointed at the local proxy, update the saved settings and uninstall baseline, and refuse to run if config no longer points to the recorded proxy. Do not pass--restartunless the user explicitly accepts that restarting the proxy can interrupt current proxy-backed Codex sessions. Without--restart, tell the user to restart Codex App, open a new CLI process, or runstartlater to apply the new upstream. - Use
verify-upstreamwhen the user asks to test a candidate upstream or auth source without changing local state. It must run the same streaming/v1/responsesside-path check asset-upstream, then stop without writing settings, editing Codex config, installing hooks, or restarting the proxy. - Do not edit the active provider
base_urldirectly while the proxy is enabled. For ChatGPT login compatibility, configure upstream provider auth withprepare-chatgpt-login --applyandset-upstream --use-provider-auth-filerather than editingauth.json. Model, reasoning, and other Codex config fields can still be edited directly by the user or agent. - Running Codex processes do not hot-switch provider config. After enable, restart Codex App and resume the same conversation if desired, or open a new CLI process.
- If the current process is already using the proxy, stopping the proxy can interrupt the conversation. Disable with
uninstall --defer-stop, tell the user to restart Codex App or open a new CLI process, then run uninstall again to finish cleanup. - If uninstall output has
status="confirmation_required", no uninstall changes were applied. Reportdirect_upstream_auth_warningfirst. Ask whether the user wants to keep the proxy enabled, switch Codex App back to API-key/third-party provider auth before uninstalling, or explicitly continue despite the ChatGPT-login direct-upstream 401 risk. Only after explicit confirmation, rerun with--confirm-chatgpt-direct-uninstall. - If confirmed uninstall output includes
direct_upstream_auth_warning, report it before any restart instruction. Restored direct upstream mode no longer has the proxy auth override; if Codex App remains signed in with ChatGPT, a third-party provider may receive ChatGPT auth and return 401. Tell the user to switch back to API-key/third-party provider auth before restarting, or keep the proxy enabled if they want ChatGPT-login UI with a third-party provider. - Uninstall removes only the
codex-fast-proxyhook and must preserve unrelated hooks. - Do not run
stopwhile Codex config still points to the proxy unless the user explicitly accepts that current and future sessions may fail. - Run
benchmarkonly when the user explicitly asks for an A/B check or confirms the cost. The default benchmark usescodex-climode: it starts a local forwarding capture proxy, launches realcodex execrequests, and runs three interleaved default-vs-priority pairs against the saved upstream. It can consume noticeable token quota. It uses existing Codex/provider authentication when available, records upstream latency without storing response content, and should compare full-response latency even when the provider response does not exposeservice_tier. - When the user asks whether their provider supports Fast/Priority, run or request enough input to run
benchmarkwith the defaultfullprofile. Do not use normal proxy logs,service_tier_injected=true, or HTTP 200 responses as proof of provider Fast support; those only prove the proxy sent a successful request. If automatic auth discovery cannot find a key in env/provider config/~/.codex/auth.json, ask the user for the API key environment variable name and rerun with--api-key-env. - The default benchmark timeout is 600 seconds per sample. If
fullbenchmark reportsTimeoutExpired, rerun with a larger explicit timeout such as--timeout 900before drawing a stability conclusion. statusanddoctorinclude a local health check and runtime check; treathealthy=falseas a reason to stop and diagnose before continuing. Ifstatus.needs_restart=trueafter update, tell the user to restart Codex App, open a new CLI process after the old proxy is gone, or runpython -m codex_fast_proxy startwhen it is safe to refresh runtime code. The startup hook should not restart an already healthy proxy just because runtime code is stale.- If the user asks only to check for updates, run
check-updateand stop. It is read-only and must not pull, install, restart the proxy, edit Codex config, or write proxy state. - After a successful enable, report the JSON result, the top-level
next_user_action, and thechatgpt_login_hintmessage. Ifchatgpt_login_hint.status=optional_setup_available, tell the user they can keep API-key mode for third-party API plus global Fast, and should runprepare-chatgpt-loginbefore switching Codex App to ChatGPT login for plugin marketplace, GitHub/Apps/connectors, manual Fast controls, status hints, and voice input. Avoid chaining unrelated work in the same turn.
Sandbox and approval discipline
- Operations that clone from GitHub, install with
pip, create~/.agentsskill links, write~/.codex/config.toml, write~/.codex/hooks.json, start a background proxy, or remove installed files may need user approval or elevated sandbox permissions. - If the harness supports escalation, request approval for the intended command instead of trying alternate paths.
- If a command fails because of network, permissions, sandbox write limits, skill link creation, or background-process restrictions, stop and rerun the same intended action with approval. Do not invent workarounds that bypass the user's sandbox policy.
- Do not print API keys, request bodies, prompts, or Codex history. Do not edit
auth.jsonunless the user explicitly asks for a recovery action; prefer copying the current working provider key to the proxy-managed provider auth file withprepare-chatgpt-login --apply.
User handoff messages
- After
.codex/INSTALL.mdor.codex/UPDATE.mdchanges skill files, explicitly tell the user to restart Codex App and return to the conversation, or open a new CLI process, so Codex can rescan~/.agents/skills; then ask Codex to enable Codex Fast proxy. - After
.codex/UNINSTALL.md, explicitly tell the user to restart Codex App, or open a new CLI process, so Codex removescodex-fast-proxyfrom the skill list. - After a successful
install --start, explicitly tell the user that Fast proxy is enabled, but the current Codex process will not hot-switch; they should restart Codex App and return to the conversation, or open a new CLI process. - After a successful
install --start, always append this optional ChatGPT-login UI note even if the status summary is already long: the user may keep API-key mode for third-party API plus global Fast. If they want richer Codex App UI such as plugin marketplace, GitHub/Apps/connectors, manual Fast controls, status hints, and voice input, they should runprepare-chatgpt-loginbefore switching Codex App to ChatGPT login; switching directly may cause 401. - After
uninstall --defer-stopreturnsstatus="confirmation_required", explicitly tell the user no uninstall changes were applied because ChatGPT login appears active and direct upstream may return 401. Do not tell the user to restart yet. - After
uninstall --defer-stopreturnsstatus="uninstalled", explicitly tell the user that Codex config has been restored to direct upstream, and the proxy was left running temporarily to avoid interrupting the current process. They should restart Codex App and return to the conversation, or open a new CLI process, then run uninstall again to finish cleanup. - If
direct_upstream_auth_warningis present after a confirmed uninstall, first warn that ChatGPT login appears active. After direct upstream restore, requests no longer pass through the proxy upstream auth override. Keeping ChatGPT login may send ChatGPT auth to the third-party provider and return 401. The user should switch back to API-key/third-party provider auth before restarting, or keep the proxy enabled for ChatGPT-login UI with a third-party provider.
Use --provider <name> only when the user names a provider or when doctor reports that no active provider can be selected.
Use --upstream-base <url> only when Codex config does not contain a usable provider base_url or the user explicitly wants a different upstream.
Use --upstream-api-key-env <ENV_NAME> only as an advanced compatibility path with an environment variable name, never a literal key value.
Use --clear-upstream-auth when the user wants to stop overriding upstream Authorization and
return to Codex's original provider auth behavior.
For upstream URL changes after enable, prefer set-upstream --upstream-base <url> over rerunning
install --start --upstream-base <url>.
Result handling
- Treat the JSON output as the source of truth.
- Report
provider,base_url,upstream_base,service_tier_policy,upstream_auth,running,diagnosis,provider_auth_preparation,chatgpt_login_hint,next_user_action,chatgpt_login_windows_troubleshootingwhen present,runtime_matches,needs_restart, and backup or restore status. - Use
status.runtimewhen diagnosing stale runtime, wrong Python executable, or a startup hook that points at a different checkout. Do not infer hook readiness from~/.codex/hooks.jsonalone. - For App-specific traffic checks, use recent
/v1/responsesevents as model-generation evidence. TreatGET /v1/modelsas provider metadata checks; do not report isolated/v1/modelsfailures as model-generation failure unless/v1/responsesalso fails. - Do not print API keys,
auth.json, request bodies, prompts, or Codex history. - For benchmark results, report profile, medians, observed speedup,
priority_accepted,observed_priority_effective, provider-confirmed priority metadata when present, sample counts,service_tier_control.valid, and errors. Prioritize full-response total latency and first-output latency over first-event/TTFB. Treatpriority_accepted=trueas proof that the wire parameter is accepted, andobserved_priority_effective=trueas proof that this measured workload benefited. Reportbenchmark_modeand do not present Codex CLI/app-server benchmark results as an App-specific guarantee. For App-specific verification, use recent dashboard/proxy traffic after the user sends an App message.priority_accepted=truemeans at least one priority sample succeeded; always report the displayedok/countsample counts with it. Do not claim a guaranteed speedup from a single run. - If install or update changed the skill files, tell the user to restart Codex.
Expected behavior
install --startbacks up~/.codex/config.toml.- The selected provider's original
base_urlbecomesupstream_base. - The selected provider's
base_urlbecomeshttp://127.0.0.1:8787/v1. - Before switching config on first enable,
install --startverifies a streaming/v1/responsesrequest against the candidate upstream/auth route unless the user explicitly accepted--no-verify. verify-upstreamreports the same candidate route validation without changing persistent state.set-upstreamupdates the savedupstream_base, service tier policy, upstream auth source, and uninstall recovery baseline without changing model, reasoning, tools, input, or literal API key values. Before writing settings, it sends one side-path Codex-stylePOST /v1/responsesrequest withstream=trueto the candidate upstream/auth source. This is real provider traffic; if it fails, do not add--no-verifyunless the user explicitly accepts that future Codex requests may break. It applies immediately only when the proxy is not running or the user explicitly accepted--restart; otherwise it defers restarting a running proxy to avoid cutting off the current response.- A
SessionStarthook calls the current Python executable with-m codex_fast_proxy autostart --quieton future Codex sessions. - By default
autopreserves Codex App/CLIservice_tierchoices in ChatGPT-login or unclear states, and can injectservice_tier="priority"in API-key mode when that field is absent. Only explicitinject_missingforces global Fast regardless of login mode. - Optional upstream auth split applies to proxied provider API requests, not to ChatGPT plugin,
GitHub, Apps, connector, cookie, or token traffic; override mode replaces
Authorizationand drops unexpectedCookieheaders before forwarding upstream. benchmarkcompares synthetic Codex-style requests with noservice_tieragainstservice_tier="priority". The defaultcodex-climode is intended to measure real Codex acceleration;--profile smokeis only for low-cost connectivity checks, and--mode directis a less representative fallback when Codex CLI is unavailable. It stores only redacted metrics in~/.codex/codex-fast-proxy-state/state/fast_proxy.benchmark.json. The local dashboard shows the latest saved benchmark summary and never starts benchmark runs.uninstallrestores the full backup when the current config still matches the installed state.- If the config changed but the selected provider still points to the local proxy,
uninstallrestores only that provider'sbase_urltoupstream_baseand preserves other config changes. - If ChatGPT login is active and uninstall would newly restore direct upstream,
uninstallreturnsstatus="confirmation_required"before changing config, hooks, proxy process, or files unless--confirm-chatgpt-direct-uninstallis explicit. - If
uninstallreportsconfig_restore="skipped_config_changed", do not delete the package or repo; the selected provider no longer points to the recorded proxy, so ask the user before using--force.
Capabilities
Install
Quality
deterministic score 0.47 from registry signals: · indexed on github topic:agent-skills · 30 github stars · SKILL.md body (20,453 chars)