Skip to content

Commit f7fa71b

Browse files
committed
fix: 将 README 中 Codex WS 配置迁移至使用密钥弹窗
- 移除 README.md / README_CN.md 中的 Codex CLI WebSocket v2 配置示例 - UseKeyModal OpenAI 分组新增 "Codex CLI (WebSocket)" tab,区分普通模式与 WS 模式 - 普通模式 config.toml 不含 WebSocket 字段,WS 模式包含 supports_websockets 和 features 配置 - 所有配置统一使用 sub2api 作为 model_provider 名称
1 parent fbfbb26 commit f7fa71b

5 files changed

Lines changed: 48 additions & 57 deletions

File tree

README.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,6 @@ Sub2API is an AI API gateway platform designed to distribute and manage API quot
5757

5858
---
5959

60-
## Codex CLI WebSocket v2 Example
61-
62-
To enable OpenAI WebSocket Mode v2 in Codex CLI with Sub2API, add the following to `~/.codex/config.toml`:
63-
64-
```toml
65-
model_provider = "aicodx2api"
66-
model = "gpt-5.3-codex"
67-
review_model = "gpt-5.3-codex"
68-
model_reasoning_effort = "xhigh"
69-
disable_response_storage = true
70-
network_access = "enabled"
71-
windows_wsl_setup_acknowledged = true
72-
73-
[model_providers.aicodx2api]
74-
name = "aicodx2api"
75-
base_url = "https://api.sub2api.ai"
76-
wire_api = "responses"
77-
supports_websockets = true
78-
requires_openai_auth = true
79-
80-
[features]
81-
responses_websockets_v2 = true
82-
```
83-
84-
After updating the config, restart Codex CLI.
85-
86-
---
87-
8860
## Deployment
8961

9062
### Method 1: Script Installation (Recommended)

README_CN.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,6 @@ Sub2API 是一个 AI API 网关平台,用于分发和管理 AI 产品订阅(
6262
- 当请求包含 `function_call_output` 时,需要携带 `previous_response_id`,或在 `input` 中包含带 `call_id``tool_call`/`function_call`,或带非空 `id` 且与 `function_call_output.call_id` 匹配的 `item_reference`
6363
- 若依赖上游历史记录,网关会强制 `store=true` 并需要复用 `previous_response_id`,以避免出现 “No tool call found for function call output” 错误。
6464

65-
## Codex CLI 开启 OpenAI WebSocket Mode v2 示例配置
66-
67-
如需在 Codex CLI 中通过 Sub2API 启用 OpenAI WebSocket Mode v2,可将以下配置写入 `~/.codex/config.toml`
68-
69-
```toml
70-
model_provider = "aicodx2api"
71-
model = "gpt-5.3-codex"
72-
review_model = "gpt-5.3-codex"
73-
model_reasoning_effort = "xhigh"
74-
disable_response_storage = true
75-
network_access = "enabled"
76-
windows_wsl_setup_acknowledged = true
77-
78-
[model_providers.aicodx2api]
79-
name = "aicodx2api"
80-
base_url = "https://api.sub2api.ai"
81-
wire_api = "responses"
82-
supports_websockets = true
83-
requires_openai_auth = true
84-
85-
[features]
86-
responses_websockets_v2 = true
87-
```
88-
89-
配置更新后,重启 Codex CLI 使其生效。
90-
91-
---
92-
9365
## 部署方式
9466

9567
### 方式一:脚本安装(推荐)

frontend/src/components/keys/UseKeyModal.vue

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ const clientTabs = computed((): TabConfig[] => {
268268
case 'openai':
269269
return [
270270
{ id: 'codex', label: t('keys.useKeyModal.cliTabs.codexCli'), icon: TerminalIcon },
271+
{ id: 'codex-ws', label: t('keys.useKeyModal.cliTabs.codexCliWs'), icon: TerminalIcon },
271272
{ id: 'opencode', label: t('keys.useKeyModal.cliTabs.opencode'), icon: TerminalIcon }
272273
]
273274
case 'gemini':
@@ -306,7 +307,7 @@ const showShellTabs = computed(() => activeClientTab.value !== 'opencode')
306307
307308
const currentTabs = computed(() => {
308309
if (!showShellTabs.value) return []
309-
if (props.platform === 'openai') {
310+
if (activeClientTab.value === 'codex' || activeClientTab.value === 'codex-ws') {
310311
return openaiTabs
311312
}
312313
return shellTabs
@@ -401,6 +402,9 @@ const currentFiles = computed((): FileConfig[] => {
401402
402403
switch (props.platform) {
403404
case 'openai':
405+
if (activeClientTab.value === 'codex-ws') {
406+
return generateOpenAIWsFiles(baseUrl, apiKey)
407+
}
404408
return generateOpenAIFiles(baseUrl, apiKey)
405409
case 'gemini':
406410
return [generateGeminiCliContent(baseUrl, apiKey)]
@@ -524,6 +528,47 @@ requires_openai_auth = true`
524528
]
525529
}
526530
531+
function generateOpenAIWsFiles(baseUrl: string, apiKey: string): FileConfig[] {
532+
const isWindows = activeTab.value === 'windows'
533+
const configDir = isWindows ? '%userprofile%\\.codex' : '~/.codex'
534+
535+
// config.toml content with WebSocket v2
536+
const configContent = `model_provider = "sub2api"
537+
model = "gpt-5.3-codex"
538+
model_reasoning_effort = "high"
539+
network_access = "enabled"
540+
disable_response_storage = true
541+
windows_wsl_setup_acknowledged = true
542+
model_verbosity = "high"
543+
544+
[model_providers.sub2api]
545+
name = "sub2api"
546+
base_url = "${baseUrl}"
547+
wire_api = "responses"
548+
supports_websockets = true
549+
requires_openai_auth = true
550+
551+
[features]
552+
responses_websockets_v2 = true`
553+
554+
// auth.json content
555+
const authContent = `{
556+
"OPENAI_API_KEY": "${apiKey}"
557+
}`
558+
559+
return [
560+
{
561+
path: `${configDir}/config.toml`,
562+
content: configContent,
563+
hint: t('keys.useKeyModal.openai.configTomlHint')
564+
},
565+
{
566+
path: `${configDir}/auth.json`,
567+
content: authContent
568+
}
569+
]
570+
}
571+
527572
function generateOpenCodeConfig(platform: string, baseUrl: string, apiKey: string, pathLabel?: string): FileConfig {
528573
const provider: Record<string, any> = {
529574
[platform]: {

frontend/src/i18n/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ export default {
501501
claudeCode: 'Claude Code',
502502
geminiCli: 'Gemini CLI',
503503
codexCli: 'Codex CLI',
504+
codexCliWs: 'Codex CLI (WebSocket)',
504505
opencode: 'OpenCode',
505506
},
506507
antigravity: {

frontend/src/i18n/locales/zh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ export default {
503503
claudeCode: 'Claude Code',
504504
geminiCli: 'Gemini CLI',
505505
codexCli: 'Codex CLI',
506+
codexCliWs: 'Codex CLI (WebSocket)',
506507
opencode: 'OpenCode'
507508
},
508509
antigravity: {

0 commit comments

Comments
 (0)