malv ai
Configure an AI API key for semantic search and info summary generation.
Usage
# Store an API key
malv ai set sk-...
# Check if a key is configured
malv ai check
# Remove the stored key
malv ai remove
Commands
| Command | Description |
|---|---|
set <api-key> |
Store an API key (auto-detects provider) |
check |
Check if a key is configured (alias: status) |
remove |
Remove the stored key (aliases: rm, delete) |
Provider Detection
The command automatically detects which AI provider to use based on the key format:
| Key Format | Provider |
|---|---|
sk-ant-... |
Anthropic |
| Other | OpenAI |
Examples
# Store an OpenAI key
malv ai set sk-proj-abc123...
# Store an Anthropic key
malv ai set sk-ant-abc123...
# Check status
malv ai check
# Remove the key
malv ai remove
Output
$ malv ai set sk-proj-abc123...
✓ OpenAI API key saved
$ malv ai check
✓ API key configured
Provider: OpenAI
Key: sk-proj-...abc (masked)
$ malv ai remove
✓ API key removed
What It's Used For
The AI API key powers two features:
Info Summary Generation
When an app contains static reference data (CSVs, JSONs in /info directories), the summary generator creates semantic descriptions. These descriptions enable AI-powered data discovery.
Semantic Search
The key is used to generate embeddings for semantic search across your storage. See Semantic Search for details.
Environment Variable Alternative
Instead of storing a key with malv ai set, you can use an environment variable:
export MALV_AI_API_KEY="sk-..."
The environment variable takes precedence over the config file. This is useful for:
- CI/CD environments
- Sharing keys across projects
- Temporary key usage
Storage Location
The key is saved to ~/.malv/ai-config.json:
{
"provider": "openai",
"apiKey": "sk-..."
}
This file is created with restricted permissions (600) for security.
Common Issues
Invalid key format
Error: Invalid API key format
Ensure you're using a valid OpenAI or Anthropic API key.
Key not working
Error: API request failed: Invalid API key
Verify the key is active and has the required permissions in your provider's dashboard.
Related
- Semantic Search - Using semantic search in your apps