Environment Variables
Codex อ่าน environment variables สำหรับ shell-scoped configuration overrides, automation secrets, installer behavior, และ diagnostics ซึ่งเสริมการตั้งค่าถาวรที่เก็บใน config.toml
Core Location Variables
CODEX_HOME
ค่าเริ่มต้น: ~/.codex
กำหนด root directory สำหรับ Codex state, configuration, authentication, logs, sessions, และ skills directory ต้องมีอยู่แล้วหากคุณตั้งค่านี้
CODEX_SQLITE_HOME
ค่าเริ่มต้น: CODEX_HOME
ระบุตำแหน่งที่เก็บ SQLite-backed state Relative paths resolve จาก current working directory
Installer Variables
ตัวแปรเหล่านี้ใช้กับ standalone install scripts จาก https://chatgpt.com/codex/install.sh และ PowerShell equivalent
CODEX_NON_INTERACTIVE
ค่าเริ่มต้น: false
ตั้งค่าเป็น 1, true, หรือ yes เพื่อข้าม installer prompts และใช้ค่าเริ่มต้น มีประโยชน์สำหรับ scripted, unattended installations
ตัวอย่าง unattended install:
curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh
CODEX_INSTALL_DIR
ค่าเริ่มต้น: platform-specific
เปลี่ยนตำแหน่งการติดตั้งสำหรับ codex command standalone package cache ยังคงอยู่ที่ CODEX_HOME/packages/standalone
Authentication และ Network Variables
CODEX_API_KEY
ให้ API key สำหรับ single non-interactive runs ผ่าน codex exec ใช้แบบ inline แทนการตั้งค่า job-wide สำหรับ repository-controlled code
CODEX_ACCESS_TOKEN
ให้ ChatGPT หรือ Codex access token สำหรับ trusted automation และ persistent login scenarios
CODEX_CA_CERTIFICATE และ SSL_CERT_FILE
ชี้ไปยัง PEM CA bundles สำหรับ corporate TLS interception หรือ private root CAs CODEX_CA_CERTIFICATE มีความสำคัญสูงกว่า
Diagnostics Variables
RUST_LOG
ควบคุม log filtering และ verbosity ค่าเริ่มต้นคือ error สำหรับ codex exec หากไม่ได้ override รับค่าเช่น:
| ค่า | คำอธิบาย |
|---|---|
error | แสดงเฉพาะ errors |
warn | แสดง warnings และ errors |
info | แสดงข้อมูลทั่วไป |
debug | แสดงข้อมูล debug |
trace | แสดงทุกอย่าง |
รองรับ targeted filters เช่น codex_core=debug
ตัวอย่างกับ plaintext logging:
RUST_LOG=debug codex -c log_dir=./.codex-log
ตัวอย่างการใช้งานร่วมกัน
# ตั้งค่า CODEX_HOME ที่กำหนดเอง
export CODEX_HOME="/opt/codex-data"
# รัน Codex ด้วย API key เฉพาะสำหรับ automation
CODEX_API_KEY="sk-..." codex exec "run the test suite"
# Debug mode
RUST_LOG=debug CODEX_HOME=~/.codex-debug codex