gg addkey
Configure your AI provider API key for GitGuru's intelligent features.
Usage
bash
gg addkeySupported AI Provider
GitGuru is currently powered by Google's Gemini AI:
Google Gemini AI
Fast, powerful, and free tier available
Get key: https://aistudio.google.com/app/api-keysOpenAI, Anthropic, Ollama
Coming soon...
Interactive Setup
Running gg addkey starts an interactive wizard:
bash
$ gg addkey YOUR_GEMINI_API_KEY
š API Key Configuration
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā API key validated successfully!
ā Fetching available models...
Available Models:
1. gemini-2.0-flash-exp (Latest experimental, fast and powerful)
2. gemini-1.5-pro (Most capable, best for complex tasks)
3. gemini-1.5-flash (Fast and efficient, good balance)
4. gemini-pro (Stable, reliable performance)
Select model: 2
ā Configuration saved!
Provider: Google Gemini
Model: gemini-1.5-pro
You can now use GitGuru's AI features.Key Storage
Your API key is stored securely in your system's credential manager or in
~/.gitguru/config with restricted permissions. It is never transmitted anywhere except to your chosen AI provider.Using Environment Variables
You can also set your API key via environment variable:
bash
# Set Gemini API key
export GEMINI_API_KEY="your-api-key-here"
# GitGuru will automatically detect and use thisConfiguration Storage
Your configuration is stored in ~/.gitguru/config.json:
json
{
"apiKey": "YOUR_API_KEY",
"model": "gemini-1.5-pro",
"aiCommitEnabled": true,
"aiDiffEnabled": true,
"aiStatusEnabled": false,
"aiLogEnabled": false
}Security
Never commit API keys to version control. Add
.env to your .gitignore file.Verifying Your Key
Test that your API key is working:
bash
# Test the connection
gg ask "hello"
# Or check configuration
gg config --get apiKey
gg config --get providerGetting a Gemini API Key
Follow these steps to get your free Gemini API key:
- Visit Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy the key
- Run
gg addkey YOUR_KEY
Free Tier Includes
- 15 requests per minute
- 1 million tokens per minute
- 1,500 requests per day
Available Models
Choose the model that best fits your needs:
| Model | Description |
|---|---|
gemini-2.0-flash-exp | Latest experimental, fast and powerful |
gemini-1.5-pro | Most capable, best for complex tasks |
gemini-1.5-flash | Fast and efficient, good balance |
gemini-pro | Stable, reliable performance |
Troubleshooting
Invalid API Key
bash
$ gg ask "hello"
ā Error: Invalid API key
Check your API key:
gg config --get apiKey
Reconfigure:
gg addkeyRate Limits
bash
$ gg ask "explain this large codebase"
ā ļø Rate limit reached
Solutions:
1. Wait a few minutes
2. Upgrade your API plan
3. Use a local model: gg config --set provider ollama