Mehaisi CodeSwarm provides intelligent credential management that automatically prompts you for API keys when needed, eliminating the need to manually export environment variables.
cd your-project
codeswarm init --model kimi-k2.5:cloudcodeswarm credentialsThis command will:
- ✅ Detect which providers need credentials
- ✅ Prompt you for missing API keys
- ✅ Optionally save keys to config file
- ✅ Validate credentials work
Example session:
🔐 Setting up credentials for configured providers
Provider: ollama-cloud
⚠ Ollama Cloud API key not found
You can get an API key from: https://ollama.com
? Enter your Ollama Cloud API key: ****************************************
? Save API key to config file (.mehaisi/config.json)? Yes
✓ API key saved to config
✓ Credential setup complete
# No export needed! Just run your command
codeswarm pipeline cautious
# If credentials are missing, you'll be prompted automaticallyWhen you run any command that requires credentials:
- Check environment variables first (e.g.,
OLLAMA_CLOUD_API_KEY) - Check config file for saved credentials
- Prompt interactively if credentials not found
- Cache in memory for the session
You're never blocked - Mehaisi CodeSwarm will always ask when it needs something.
1. Environment Variable → export OLLAMA_CLOUD_API_KEY="..."
2. Config File → .mehaisi/config.json
3. Interactive Prompt → Asks you when needed
# Interactively setup credentials for all providers
codeswarm credentialsCredentials are requested automatically when you use a provider:
# First time running with ollama-cloud
codeswarm run api-detective
# You'll be prompted:
⚠ Ollama Cloud API key not found
? Enter your Ollama Cloud API key: When prompted, choose Yes to save to config:
? Save API key to config file (.mehaisi/config.json)? Yes
✓ API key saved to config
Pros:
- ✅ Never prompted again
- ✅ Persists across sessions
- ✅ Project-specific
Cons:
⚠️ Stored in plain text⚠️ Don't commit config to git with keys
Set once per session:
export OLLAMA_CLOUD_API_KEY="your-key-here"
codeswarm pipeline cautiousPros:
- ✅ Not stored in files
- ✅ More secure
- ✅ Easy to rotate
Cons:
⚠️ Must export in each terminal session
Choose No when prompted:
? Save API key to config file (.mehaisi/config.json)? No
💡 Tip: Set OLLAMA_CLOUD_API_KEY environment variable to avoid this prompt
You'll be prompted every time the credential is needed.
Get API key from: https://ollama.com
codeswarm credentials
# Or manually:
export OLLAMA_CLOUD_API_KEY="your-key-here"No credentials needed! Just start Ollama:
ollama serveexport CLAUDE_CODE_SESSION_ACCESS_TOKEN="your-token"Get API key from: https://platform.openai.com/api-keys
codeswarm credentials
# Or manually:
export OPENAI_API_KEY="sk-..."- Use environment variables in production
- Add
.mehaisi/config.jsonto.gitignore(auto-added during init) - Rotate keys regularly
- Use the
credentialscommand to setup keys securely
- Commit API keys to git
- Share config files with credentials
- Store credentials in code
- Use production keys in development
Make sure you either:
- Chose "Yes" when prompted to save to config, or
- Set environment variable in your shell profile:
# Add to ~/.bashrc or ~/.zshrc
export OLLAMA_CLOUD_API_KEY="your-key"Check the config file:
cat .mehaisi/config.json | grep api_keyIf missing, run codeswarm credentials again.
Edit .mehaisi/config.json or run:
codeswarm credentials # Re-enter when promptedYour API key may be invalid. Verify:
- Key is correct (no extra spaces)
- Key hasn't expired
- You have access to the model you're trying to use
If you've been manually exporting keys:
# Required before every command ❌
export OLLAMA_CLOUD_API_KEY="key"
export CLAUDE_CODE_SESSION_ACCESS_TOKEN="token"
codeswarm pipeline cautious# One-time setup ✅
codeswarm credentials
# Then just run commands
codeswarm pipeline cautious
codeswarm run api-detective
codeswarm workflow investigate✅ No more manual exports - Credentials are managed automatically
✅ Interactive prompts - You're asked when something is needed
✅ Multiple storage options - Choose what works for you
✅ Secure by default - Config files are gitignored
✅ Provider-agnostic - Works with all configured providers
Just run codeswarm credentials once and you're ready to go!