2.14.0
v24.19.0
Windows 10.0.26200 x64 (win32), PowerShell 7.7.0
cn
# 1. 登录 Token Plan bl auth login --config token-plan --api-key [REDACTED] # 2. 按官方引导配置 Codex bl config agent --agent codex --region cn-beijing --key [REDACTED] --model qwen3.8-max # → Codex configured successfully. # Written: ~/.codex/config.toml # Written: ~/.codex/auth.json # Exit code: 0 # 3. 不设置 OPENAI_API_KEY 环境变量,直接运行 codex exec --skip-git-repo-check "hi"
命令退出码 0 并提示 configured successfully 之后,Codex 应能直接使用:provider 走 requires_openai_auth = true + auth.json 里的 key。
requires_openai_auth = true
auth.json
bl config agent 提示 configured successfully(Exit code: 0),但随后的 codex exec 直接失败(输出见 Full output)。其余观察:
bl config agent
codex exec
codex login status
API key configured - sk-sp-***
OPENAI_API_KEY
$ codex exec --skip-git-repo-check "hi" model: qwen3.8-max provider: bailian-cli ERROR: Missing environment variable: `OPENAI_API_KEY`. Exit code: 1
Always
Agent (Cursor, Claude, etc.)
补充环境:Codex codex-cli 0.169.0;Windows 10.0.26200 x64(win32),PowerShell 7.7.0
命令写入的 provider 配置(~/.codex/config.toml):
~/.codex/config.toml
model = "qwen3.8-max" model_provider = "bailian-cli" [model_providers.bailian-cli] name = "bailian-cli" base_url = "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1" env_key = "OPENAI_API_KEY" wire_api = "responses" requires_openai_auth = true
~/.codex/auth.json:{"OPENAI_API_KEY": "[REDACTED]"}
~/.codex/auth.json
{"OPENAI_API_KEY": "[REDACTED]"}
Missing environment variable
requires_openai_auth=true
env_key
codex debug app-server send-message-v2
requires_openai_auth=false
{"code":"InvalidApiKey","message":"No API-key provided."}
结论:在 Codex 0.169.0 上,只要 provider 写了 env_key,Codex 就强制要求该环境变量,不再回退到 auth.json。bl config agent --agent codex 写出的 env_key + requires_openai_auth + auth.json 组合,在没有 OPENAI_API_KEY 环境变量的机器上不可用,而命令的成功提示里没有提到需要设置环境变量。
bl config agent --agent codex
requires_openai_auth
env_key = "OPENAI_API_KEY"
[model_providers.bailian-cli]
Activity