Connect DSH to OpenAI Codex via device code OAuth, run Codex models using ChatGPT Plus/Pro subscription—no API Key required.
- Language
- JavaScript
- License
- MIT
- Branch
- main
Install
$ dsh plugin --profile web add dsh-codex-providerRun the command above in your terminal to install this plugin via the dsh CLI. You can switch Profile in the top-right corner. New to dsh? Read the beginner tutorial
Install via your agent
Install the DeepSeek Harness plugin Hu9956/dsh-codex-provider for me: review the repository at https://github.com/Hu9956/dsh-codex-provider first, then run the install command and verify the plugin loads successfully.
Paste this instruction to the DSH Web GUI assistant — it will install and verify for you.
One-Line Pitch
Bring OpenAI Codex to DSH: Log in to your ChatGPT account via device code OAuth, connect your ChatGPT Plus/Pro subscription quota to DSH's built-in openai-codex model routing, no API Key required.
Core Capabilities
- Device Code OAuth Login: Click login in "Settings → Providers", complete authorization on the OpenAI authorization page using the device code displayed on the page, no API Key required
- Reuse Codex CLI Login State: Directly read existing access/refresh tokens from local
~/.codex/auth.json, skipping re-authorization - Automatic Token Refresh: Background check every minute for access token expiration, automatically rotate using refresh_token when less than 10 minutes remaining (refresh_token is also refreshed together)
- Cross-Instance Refresh Lock: Ensure serialized refresh across multiple DSH processes on the same machine via
~/.dsh/.codex-provider-refresh.lockfile lock, preventing token corruption - Provider Management Panel: Display masked account, subscription (Plus/Pro), token expiration time after login, support one-click logout
- Auto-Activate Built-in Codex Routing: After successful login, write
OPENAI_CODEX_API_KEYtollm-pi-ai.providers.openai-codex.apiKeyEnv, Codex models likegpt-5.4become directly selectable in the model selector
Technical Implementation
- Language: JavaScript (ESM,
"type": "module"), source code has no TS type annotations but depends on DSH's Typert decorators at runtime - Key Dependencies:
@deepseek-ai/dsh-typert-protocol(Remote/TypertRemoteService, host-client remote calls),@deepseek-ai/dsh-credentials(credential storage),@deepseek-ai/dsh-settings(writing tollm-pi-ai.providers.openai-codex.apiKeyEnv) - Architecture Pattern: Dual-end plugin + Typert remote service. Host-side
CodexGatewayinheritsTypertRemoteServiceexposing six remote methods:status/loginStart/loginStatus/loginCancel/importExisting/logout; client-side uses__ModuleLoader__format to register UI components and$mountthe same remote description, achieving browser-side not touching original tokens - Entry Files:
lib/index.js(host),lib/client.js(web bundle), injected into DSH bundle bycordis.patch.ymlduring installation
Use Cases
Users who have a ChatGPT Plus/Pro subscription and want to add Codex series models (gpt-5.4, gpt-5.5, gpt-5.6-*) to the DSH model selector. The pain point is that DSH's built-in openai-codex routing only accepts credential references without a built-in login entry; without this plugin, users either pay for API Key billing or manually maintain tokens. This plugin completes the last mile: login UI, token refresh, and credential recycling. Also suitable for users already running Codex CLI who want to reuse local login state and avoid repeated authorization.
Prerequisites & Compatibility
| Dependency | Minimum Version | Description |
|---|---|---|
| @deepseek-ai/dsh | >=0.1.0-rc.6 | Declared via peerDependencies (typert-protocol / credentials / settings and other host packages all require same version) |
| @deepseek-ai/cordis | ^4.0.1 | Host plugin runtime, marked as optional in peerDependencies |
| Node.js | >=22 | package.json engines.node hard requirement |
| React | ^18.2.0 | Client rendering dependency, only needed when using web profile |
| Platform | Cross-platform | Host code has no platform binding; user-facing only supports DSH web profile (client.platform = "web"), CLI/TUI scenarios not covered by this plugin |
| Native Modules | None | All pure JS + Node built-in modules (node:fs / node:os / node:path) + fetch |
Installation
dsh plugin --profile web add dsh-codex-provider
During installation, cordis.patch.yml is automatically written, no manual editing needed. After completion, restart dsh web, and the Providers section will appear in the "Settings" sidebar for use.
Configuration Options
This plugin requires no additional configuration. All runtime state (access token, refresh token, login session) is written via DSH credential store and settings, not reading any Schema fields.
| Config | Type | Description | Default |
|---|---|---|---|
| — | — | This plugin requires no additional configuration | — |
Advanced info (for reference only, not declared as user config in source): Refresh lock file path is determined by environment variable
DSH_HOME, default~/.dsh/.codex-provider-refresh.lock; credential reference is written tollm-pi-ai.providers.openai-codex.apiKeyEnv, device code login entry athttps://auth.openai.com/codex/device.
FAQ
Q: Do I need an OpenAI API Key?
A: No. This plugin consumes ChatGPT Plus/Pro subscription quota, using the same OAuth channel as Codex CLI, not API billing.
Q: I already have Codex CLI installed, can I reuse the login?
A: Yes. Click "Import local Codex CLI login state" on the providers page, the plugin directly reads ~/.codex/auth.json, no need to go through device code authorization again.
Q: Login failed with "device code authorization denied" prompt?
A: You need to first enable "Enable device code authorization for Codex" switch in ChatGPT web "Settings → Account security and login". It is recommended to turn it off after successful login, and turn it on again before next login.
Q: Will tokens refresh automatically? Do I need manual operations?
A: Automatic. Host side checks every 60 seconds, uses refresh_token to renew when access token remaining lifetime is below 10 minutes (refresh_token is also rotated), multiple DSH processes use file locks to serialize and avoid races.
Q: Where are credentials stored? Can the browser see them?
A: Credentials are written to DSH credential store (keys: OPENAI_CODEX_API_KEY and OPENAI_CODEX_REFRESH_TOKEN), browser side only gets masked account ID, subscription type, expiration time and other status info, original tokens are not delivered to frontend.
Q: Will I be logged out if I run Codex CLI at the same time?
A: They share the same OAuth session. After either side refreshes the token, the other side's old refresh_token may become invalid; just re-run codex login on the Codex CLI side to restore.
Q: Which models are supported?
A: Determined by the built-in openai-codex routing in the current DSH version, README examples include gpt-5.4, gpt-5.5, gpt-5.6-*, etc.; specific visibility also depends on your OpenAI account permissions.
Q: How to uninstall?
A: Just remove this plugin via dsh. Host side will automatically clear the two credential store keys and revoke the apiKeyEnv reference in settings; after restart, the "Providers" section in settings disappears.
Difficulty Level
Beginner — Just click "Log in with OpenAI account" once in "Settings → Providers" and follow the device code authorization guide; no code changes, config files, or environment variables involved.
Known Issues & Limitations
- Device code authorization depends on OpenAI account settings: Must enable "Enable device code authorization for Codex" on ChatGPT web side before logging in, otherwise OAuth endpoint will refuse to issue device code (README.md:44-46)
- Shares OAuth session with Codex CLI: After either side refreshes the token, the other side's old refresh_token may become invalid, need to re-login on the invalidated side (README.md:57)
- Only supports DSH web profile: Client bundle declares
platform: "web", CLI/TUI scenarios not covered by this plugin (package.json:57) - Device code valid for 15 minutes: Authorization must be completed within 15 minutes of receiving device code, otherwise it expires and login flow must be restarted (lib/index.js:23)
- Refresh lock wait limit 45 seconds: When multiple DSH processes on the same machine trigger refresh simultaneously, the second process waits max 45 seconds; lock files not released for over 2 minutes are treated as stale locks and automatically recycled (lib/index.js:26-27)
- Depends on DSH RC version: Currently validated against
@deepseek-ai/dsh 0.1.0-rc.6, if DSH adjusts plugin interfaces in the future, this plugin may need synchronized upgrades (README.md:70)
DeepSeek Harness (DSH) 供应商插件:OpenAI Codex(ChatGPT Plus/Pro 订阅) 的设备码 OAuth 登录、令牌自动刷新与供应商管理。
在 DSH 设置中新增 “供应商” 分区,通过设备码授权登录 OpenAI 账号后,即可在模型选择器中使用 DSH 内置的 openai-codex 模型(gpt-5.4、gpt-5.5、gpt-5.6-* 等),消费你的 ChatGPT Plus / Pro 订阅额度。
✨ 功能
- 设备码 OAuth 登录:在界面点击“使用 OpenAI 账号登录”,按提示完成设备码授权,无需 API Key
- 导入 Codex CLI 登录态:直接复用本机
~/.codex/auth.json中已有的登录(无需重新授权) - 令牌自动刷新:后台定期检查 access token,过期前自动用 refresh token 轮换(refresh_token 也会一并轮换)
- 供应商管理界面:设置 → 供应商,展示登录状态、账号、套餐(Plus/Pro)、令牌过期时间,支持退出登录
- 激活内置 Codex 模型:登录后
openai-codex路由自动激活,模型选择器直接可选
📦 安装
dsh plugin --profile web add dsh-codex-provider
插件包自带 DSH bundle 配置,安装时会自动加入 profile,无需手动编辑 cordis.patch.yml。
重启 dsh web 服务(Ctrl+C 后重新运行启动命令),刷新页面即可在 设置 → 供应商 看到入口。
也可以从 GitHub 安装当前源码版本:
dsh plugin --profile web add github:Hu9956/dsh-codex-provider
🚀 使用
- 打开 设置 → 供应商
- 点击 “使用 OpenAI 账号登录”,按页面提示完成设备码授权
- 登录成功后,在模型选择器中选择 Codex 模型(如
gpt-5.4)开始使用
设备码授权注意事项(页面也会显示)
- 登录前:请先在 ChatGPT 网页端 → 设置 → 账户安全与登录 中打开“为 Codex 启用设备代码授权”开关(未开启将无法授权);
- 授权:先复制页面显示的设备代码,再点击“使用 OpenAI 账号登录”,按提示填入该设备代码;
- 登录后:建议返回 ChatGPT 网页端关闭该开关——不影响本次登录,但下次重新登录前需重新开启。
⚙️ 工作原理
- 设备码 OAuth 流程直接对接
auth.openai.com,令牌直连chatgpt.com/backend-api(与官方 Codex CLI 相同的通道与认证方式) - access token / refresh token 存入 DSH 凭证库(
OPENAI_CODEX_API_KEY/OPENAI_CODEX_REFRESH_TOKEN);仅 Host 侧在请求和刷新时解析,绝不返回浏览器 - 凭证引用写入
llm-pi-ai.providers.openai-codex.apiKeyEnv,激活 DSH 内置的openai-codex路由(routeAuth会在 OAuth 旁附加 harness apiKey 通道) - 后台任务每分钟检查 access token 过期时间,剩余不足 10 分钟时自动刷新并轮换;同机多实例通过刷新锁串行处理
⚠️ 注意事项
- 与 Codex CLI 共享同一 OAuth 会话:任一侧刷新令牌后,另一侧持有的旧 refresh token 可能失效(届时在 Codex CLI 侧重新
codex login即可) - 不需要 API Key:本插件消费的是 ChatGPT 订阅额度,不是 OpenAI API 计费
- 需要 DSH
>= 0.1.0-rc.6 - 可用模型由当前 DSH 版本和 OpenAI 账户权限决定
🔒 安全与隐私
- access token 与 refresh token 只写入 DSH 凭证库;浏览器端只接收脱敏账号信息和登录状态
- 请勿在 Issue、Discussion、日志或截图中公开设备代码、OAuth token、
~/.dsh/.credentials.yaml或~/.codex/auth.json的内容 - 安全问题请按 SECURITY.md 通过 GitHub 私下报告
兼容性
当前版本针对 @deepseek-ai/dsh 0.1.0-rc.6 和 Node.js 22 验证。DSH 尚处于 RC 阶段,后续版本若调整插件接口,本插件也可能需要同步升级。
🛠️ 开发
| 文件 | 说明 |
|---|---|
lib/index.js | host 插件:设备码 OAuth、凭证存取、令牌刷新、Typert Remote 服务(codexProvider) |
lib/client.js | client 插件:设置页“供应商”分区 UI(ModuleLoader bundle 格式) |
📄 License
免责声明
这是社区维护的非官方插件,与 OpenAI、DeepSeek 或 DeepSeek Harness 官方没有隶属或背书关系。OpenAI、ChatGPT、Codex 和 DeepSeek 等名称与商标归各自权利人所有。
Read the usage guide →
Install steps, key points, FAQ and compatibility for this plugin — auto-derived from indexed fields.
Listing badge
[](https://deepseek-plugin.org/plugins/Hu9956/dsh-codex-provider)Paste this markdown into your GitHub README to link back to this listing. The badge only states the listing — not a security endorsement.