Skip to main content

Configuration Locations

Configuration Levels

System-Level (Global)

Applies to all projects on your machine.
ToolLocation
Claude Code~/.claude/settings.json
~/.claude.json
Codex/Windsurf~/.codex/config.toml
OpenCode~/.config/opencode/opencode.json

Project-Level (Local)

Applies only to the current project directory.
ToolLocation
Claude Code./.claude/settings.json
./.claude/settings.local.json
Codex/Windsurf Not supported
OpenCode./opencode.json
Codex/Windsurf only supports system-level configuration

Environment Variables

The CLI automatically sets these environment variables in your shell configuration file.

Claude Code

export ANTHROPIC_BASE_URL="https://ai.megallm.io"
export ANTHROPIC_API_KEY="sk-mega-your-api-key-here"

Codex/Windsurf

export MEGALLM_API_KEY="sk-mega-your-api-key-here"

OpenCode

export MEGALLM_API_KEY="sk-mega-your-api-key-here"
Note: Codex/Windsurf and OpenCode share the same MEGALLM_API_KEY environment variable.

Verify Environment Variables

# Claude Code
echo $ANTHROPIC_BASE_URL
# Output: https://ai.megallm.io

echo $ANTHROPIC_API_KEY
# Output: sk-mega-your-api-key-here

# Codex/Windsurf & OpenCode
echo $MEGALLM_API_KEY
# Output: sk-mega-your-api-key-here

Configuration Priority

When multiple configurations exist, they’re applied in this order (highest to lowest):
1

Environment Variables

Highest priority - overrides all file-based configurations
2

Project-Level Config

Second priority - applies only to current project
3

System-Level Config

Default - applies globally across all projects

Backup Files

The CLI automatically creates backup files before modifying configurations:
~/.claude/settings.json.backup
~/.codex/config.toml.backup
~/.config/opencode/opencode.json.backup
To restore from backup:
mv ~/.claude/settings.json.backup ~/.claude/settings.json

Tool-Specific Configuration

Select your AI tool for detailed configuration information:

Quick Configuration Checks

Verify All Configurations

# Check Claude Code
ls -la ~/.claude/
cat ~/.claude/settings.json

# Check Codex
ls -la ~/.codex/
cat ~/.codex/config.toml

# Check OpenCode
ls -la ~/.config/opencode/
cat ~/.config/opencode/opencode.json

# Check environment variables
env | grep -E "ANTHROPIC|MEGALLM"

Test API Connection

# Test with Claude Code credentials
curl -H "Authorization: Bearer $ANTHROPIC_API_KEY" \
     -H "Content-Type: application/json" \
     $ANTHROPIC_BASE_URL/v1/models

# Test with Codex/OpenCode credentials
curl -H "Authorization: Bearer $MEGALLM_API_KEY" \
     -H "Content-Type: application/json" \
     https://ai.megallm.io/v1/models

Manual Configuration

If you prefer not to use the CLI, you can configure manually:
  • Claude Code
  • Codex/Windsurf
  • OpenCode
# Create directory
mkdir -p ~/.claude

# Create settings file
cat > ~/.claude/settings.json << 'EOF'
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://ai.megallm.io",
    "ANTHROPIC_API_KEY": "your-api-key"
  }
}
EOF

# Add to shell config
echo 'export ANTHROPIC_BASE_URL="https://ai.megallm.io"' >> ~/.bashrc
echo 'export ANTHROPIC_API_KEY="your-api-key"' >> ~/.bashrc
source ~/.bashrc

Configuration Best Practices

Use Project-Level for Teams

Keep project-specific configurations in version control (without API keys)

Secure API Keys

Never commit API keys. Use .gitignore and environment variables

Regular Backups

CLI creates automatic backups, but keep your own copies of important configs

Test After Changes

Always verify configuration works after manual modifications

Next Steps