OpenAI Codex¶
OpenAI Codex CLI provides quick code generation capabilities from the command line.
Overview¶
- Quick code snippets via command line
- No conversation history (single-turn only)
- Automatic installation via npm
- Direct API access (not routed through Databricks)
Authentication¶
OpenAI Codex CLI requires authentication before use. On first run, you'll be prompted to authenticate.
Method 1: ChatGPT Account (Recommended)¶
This method works with: - ChatGPT Plus - ChatGPT Pro - ChatGPT Team - ChatGPT Enterprise
Authentication uses OAuth 2.0 and credentials are stored in ~/.codex/auth.json.
Remote Server Authentication
When running on a remote server (such as a Databricks workspace), you cannot access the OAuth browser flow directly. To authenticate:
- On your local laptop, run the
codexCLI and complete the authentication flow - After authentication, copy the
~/.codex/auth.jsonfile from your laptop - Transfer the
auth.jsonfile to the remote server's~/.codex/folder
This allows you to use your authenticated session on the remote server without needing browser access.
Method 2: API Key¶
# Set your OpenAI API key
export OPENAI_API_KEY="sk-..."
# Add to ~/.bashrc for persistence
echo 'export OPENAI_API_KEY="sk-..."' >> ~/.bashrc
# Run codex
codex
Get your API key from platform.openai.com/api-keys.
Note: Enterprise sign-in support is coming later. Use API key authentication for now.
Usage¶
Basic Command¶
With Language Hint¶
codex --lang python --prompt "read a CSV file"
codex --lang javascript --prompt "fetch data from API"
Configuration¶
Codex requires an OpenAI API key (not automatically configured):
Note: In Databricks DevBox, Codex is installed but not pre-configured for Databricks models. It's included for completeness but requires manual API key setup.
When to Use¶
Use Codex for:
- ✅ Quick single-turn code generation
- ✅ Simple snippets and functions
- ✅ Language-specific code patterns
Use Claude Code instead for:
- ❌ Multi-turn conversations
- ❌ Code explanation and editing
- ❌ Complex multi-file projects
- ❌ Databricks-integrated workflows
Next Steps¶
-
More powerful alternative
-
Another option