安装 Codex CLI
npm install -g @openai/codex
在 Ollama 中使用
Codex 需要较大的上下文窗口。建议使用至少 64k token 的上下文窗口。
快速设置
仅配置(不启动)
ollama launch codex --config
手动设置
要在 Ollama 中使用 codex,请使用 --oss 标志
要使用特定模型,请传递 -m 标志
codex --oss -m gpt-oss:120b
使用云端模型
codex --oss -m gpt-oss:120b-cloud
基于配置文件的设置
如需进行持久化配置,请在 ~/.codex/config.toml 中添加 Ollama 提供商和配置文件
[model_providers.ollama-launch]
name = "Ollama"
base_url = "https://:11434/v1"
[profiles.ollama-launch]
model = "gpt-oss:120b"
model_provider = "ollama-launch"
[profiles.ollama-cloud]
model = "gpt-oss:120b-cloud"
model_provider = "ollama-launch"
然后运行
codex --profile ollama-launch
codex --profile ollama-cloud