gg addkey

Configure your AI provider API key for GitGuru's intelligent features.

Usage

bash
gg addkey

Supported 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-keys

OpenAI, 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 this

Configuration 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 provider

Getting a Gemini API Key

Follow these steps to get your free Gemini API key:

  1. Visit Google AI Studio
  2. Sign in with your Google account
  3. Click "Create API Key"
  4. Copy the key
  5. 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:

ModelDescription
gemini-2.0-flash-expLatest experimental, fast and powerful
gemini-1.5-proMost capable, best for complex tasks
gemini-1.5-flashFast and efficient, good balance
gemini-proStable, reliable performance

Troubleshooting

Invalid API Key

bash
$ gg ask "hello"

āŒ Error: Invalid API key

Check your API key:
  gg config --get apiKey

Reconfigure:
  gg addkey

Rate 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