feat: support for dedicated configuration file for API keys
Resolved 💬 6 comments Opened Apr 23, 2025 by tim-watcha Closed Aug 7, 2025
Current Behavior
Currently, the codex project supports setting the OpenAI API key in two ways:
- As an environment variable:
export OPENAI_API_KEY="your-api-key-here" - In a
.envfile at the root of the project:OPENAI_API_KEY=your-api-key-here
Requested Feature
Add support for storing the OpenAI API key in a dedicated, user-wide configuration file (e.g., ~/.codex.config) that would be specific to the codex tool.
Motivation
- Persistence: Avoids having to re-export environment variables in every new terminal session
- Separation of concerns: Keeps API keys separate from project files and specific to the codex tool
- Security: Provides a dedicated location for sensitive credentials outside of project directories
- User convenience: Makes it easier for users who work with multiple projects but want a consistent API key setup
Proposed Implementation
Add the ability to read OpenAI API keys from a dedicated configuration file at ~/.codex.config (or similar location). For example:
# ~/.codex.config
OPENAI_API_KEY=your-api-key-here
The configuration file could use a simple format like the existing .env approach or a more structured format like YAML/JSON if additional configuration options might be needed in the future.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗