Skip to content

Configuration

Magic Shell requires an API key from one of the supported providers. Run the setup wizard:

Terminal window
msh --setup

This will guide you through:

  1. Selecting a provider (OpenCode Zen or OpenRouter)
  2. Entering your API key
  3. Choosing a default model

OpenCode Zen offers curated models optimized for coding, including free models.

  1. Visit opencode.ai/auth
  2. Create an account or sign in
  3. Copy your API key

You can also set your API key via environment variables:

Terminal window
# OpenCode Zen
export OPENCODE_ZEN_API_KEY="your-key-here"
# OpenRouter
export OPENROUTER_API_KEY="your-key-here"

Add these to your shell profile (~/.bashrc, ~/.zshrc, etc.) for persistence.

Magic Shell stores configuration in ~/.magic-shell/config.json:

{
"provider": "opencode-zen",
"defaultModel": "big-pickle",
"safetyLevel": "moderate",
"dryRunByDefault": false,
"theme": "opencode"
}
OptionDescriptionDefault
providerAI provider (opencode-zen or openrouter)opencode-zen
defaultModelDefault model IDbig-pickle
safetyLevelSafety strictness (strict, moderate, relaxed)moderate
dryRunByDefaultAlways show commands without executingfalse
themeColor theme nameopencode

API keys are stored securely in your system’s keychain:

PlatformStorage Location
macOSmacOS Keychain
Linuxlibsecret (secret-tool)
WindowsWindows Credential Manager
Terminal window
# Change provider
msh --provider openrouter
# Change default model
msh --model claude-3-5-sonnet
# Change theme
msh --theme tokyonight
# List available models
msh --models
# List available themes
msh --themes

In TUI mode (mshell), use keyboard shortcuts:

  • Ctrl+X M - Change model
  • Ctrl+X S - Switch provider
  • Ctrl+X T - Change theme
  • Ctrl+X C - View config

Enable API response debugging:

Terminal window
DEBUG_API=1 msh "your query"

This shows the full API request and response, useful for troubleshooting.