Skip to main content
Codex and Windsurf use TOML configuration format and only support system-level (global) configuration. The CLI automatically detects which variant you have installed.
Windsurf is a variant of Codex with enhanced features. The configuration is identical for both.

Configuration File

Location: ~/.codex/config.toml
Codex/Windsurf only supports system-level configuration. Project-level configuration is not available.

Environment Variable

The configuration references an environment variable for the API key:
This is added to your shell configuration file:
  • ~/.bashrc (bash)
  • ~/.zshrc (zsh)
  • ~/.config/fish/config.fish (fish)
  • PowerShell profile (Windows)

Verify Environment Variable

Manual Setup

If you prefer not to use the CLI:

Configuration Options

Model Selection

Change the default model in the configuration:
Available models:
  • gpt-5 - Latest GPT model
  • gpt-4 - GPT-4
  • gpt-4o - GPT-4 Optimized
  • claude-opus-4-1-20250805 - Claude Opus
  • claude-sonnet-4 - Claude Sonnet
  • gemini-2.5-pro - Gemini Pro
  • See Models Catalog for full list

Tool Settings

Enable or disable integrated tools:

Advanced Configuration

Multiple API Keys

If you need different API keys for different purposes:

Using Environment Variables

Switching Configurations

Windsurf-Specific Features

Windsurf includes additional configuration options:

Verification

Check Configuration File

Test API Connection

Test Codex/Windsurf

Troubleshooting

Check if directory exists:
Create if missing:
Verify file path:
Check environment variable is set:
If empty:
Verify key format:
  • Must start with sk-mega-
  • At least 20 characters
  • No extra spaces or quotes
Test the key:
Check config file:
Verify base_url:
Ensure no typos:
Validate syntax:
Common TOML mistakes:
Restart Codex/Windsurf:
Check for multiple config files:
Verify permissions:

Why System-Level Only?

Codex and Windsurf don’t support project-level configuration because:
  1. Single Instance - Codex/Windsurf runs as a single instance across all projects
  2. Global Settings - Tool preferences apply system-wide
  3. Simplified Management - One configuration to manage
Workaround for Project-Specific Keys: Use environment variables in your project:
Or create shell aliases:

Best Practices

Backup Configuration

Keep backup of config.toml before making changes

Use Environment Variables

Store API keys in environment variables, not in config file

Version Control

You can commit config.toml if env_key is used (no hardcoded keys)

Regular Updates

Keep Codex/Windsurf updated for latest features

Comparison: Codex vs Windsurf

Both Codex and Windsurf use the same configuration file location and format.

Next Steps

Claude Code Config

Configure Claude Code

OpenCode Config

Configure OpenCode

Examples

See practical examples

All Agents Config

Configure all CLI and GUI agents

Models Catalog

Browse available models