AI Setup
Configure AI providers and models for msh AI features.
Quick Setup
msh config ai --provider openai --model gpt-4 --api-key env:OPENAI_API_KEY
Configuration Options
Provider
Set the AI provider using --provider:
msh config ai --provider <provider>
Supported Providers:
openai- OpenAI (GPT-4, GPT-3.5, etc.)anthropic- Anthropic (Claude 3 Opus, Sonnet, etc.)ollama- Ollama (local models, no API key needed)huggingface- HuggingFace (local models)azure- Azure OpenAI
Model
Set the model identifier using --model:
msh config ai --model <model>
Examples:
gpt-4- OpenAI GPT-4gpt-3.5-turbo- OpenAI GPT-3.5 Turboclaude-3-opus- Anthropic Claude 3 Opusclaude-3-sonnet- Anthropic Claude 3 Sonnetllama2- Ollama Llama 2
API Key
Set the API key using --api-key. Use env:VAR_NAME to reference environment variables:
msh config ai --api-key env:OPENAI_API_KEY
Security Best Practice: Always use environment variables, never hardcode API keys.
Custom Endpoint
For local or custom providers, set a custom endpoint:
msh config ai --endpoint http://localhost:11434/api/generate
Provider-Specific Examples
OpenAI
msh config ai \
--provider openai \
--model gpt-4 \
--api-key env:OPENAI_API_KEY
Environment Variable:
# .env
OPENAI_API_KEY=sk-...
Anthropic
msh config ai \
--provider anthropic \
--model claude-3-opus \
--api-key env:ANTHROPIC_API_KEY
Environment Variable:
# .env
ANTHROPIC_API_KEY=sk-ant-...
Ollama (Local)
msh config ai \
--provider ollama \
--model llama2 \
--endpoint http://localhost:11434/api/generate
Note: No API key needed for Ollama.
Azure OpenAI
msh config ai \
--provider azure \
--model gpt-4 \
--api-key env:AZURE_OPENAI_API_KEY \
--endpoint https://your-resource.openai.azure.com
Configuration Storage
AI configuration is stored in:
- Global:
~/.msh/config(applies to all projects) - Project-level:
msh.yaml(project-specific override)
Project-level configuration takes precedence over global configuration.
Verifying Configuration
After configuration, verify it works:
# Generate manifest (required before AI commands)
msh manifest
# Test AI command
msh ai explain assets/revenue.msh
Troubleshooting
"AI configuration incomplete"
Issue: AI commands fail with configuration error.
Solution:
- Check configuration:
cat ~/.msh/configor checkmsh.yaml - Verify API key is set:
echo $OPENAI_API_KEY - Reconfigure if needed:
msh config ai --provider ...
"API key not found"
Issue: Environment variable not set.
Solution:
- Set environment variable:
export OPENAI_API_KEY=sk-... - Or add to
.envfile:OPENAI_API_KEY=sk-... - Verify:
echo $OPENAI_API_KEY
"Provider not supported"
Issue: Provider name incorrect.
Solution:
- Check provider name spelling
- Use one of:
openai,anthropic,ollama,huggingface,azure
Next Steps
- AI Commands - Start using AI features
- Context Packs - Understand how context works
- AI Safety - Learn about safety features