Gemini Code Completion
AI-powered inline code completion for VS Code using Google's Gemini API.
Features
- 🚀 Real-time inline completions powered by Google Gemini
- 🧠 Smart context-aware suggestions with configurable context size
- ⚡ Fast with built-in completion caching
- 🔧 Configurable - choose your model, temperature, tokens, and more
- 🎯 Works with any language supported by VS Code
- 🔐 Secure - your API key is stored locally in VS Code settings
Prerequisites
- Google Account with access to Google AI Studio
- API Key - Get a free Gemini API key from aistudio.google.com
- VS Code 1.82.0 or later
Installation
- Clone or download this repository
- Install dependencies:
npm install
- Build the extension:
npm run compile
- Package for local testing:
vsce package
- Install the
.vsix file in VS Code: Extensions → Install from VSIX
Or install directly from VS Code Extensions Marketplace (when published).
Quick Start
Set API Key:
- Run command:
Gemini: Set API Key
- Paste your Gemini API key (starts with
AIza...)
- Key is stored securely in VS Code settings
Start using completions:
- Type code in any file
- Completion suggestions appear after the debounce delay (default 500ms)
- Press
Tab or Enter to accept
- Press
Esc to dismiss
Configuration
Access settings via VS Code Settings (Cmd+, or Ctrl+,):
Core Settings
| Setting |
Type |
Default |
Description |
geminiCodeCompletion.enabled |
boolean |
true |
Enable/disable completions |
geminiCodeCompletion.apiKey |
string |
- |
Your Gemini API key |
geminiCodeCompletion.model |
string |
gemini-2.5-flash |
Model to use |
Generation Settings
| Setting |
Type |
Default |
Description |
geminiCodeCompletion.maxTokens |
number |
256 |
Max tokens in response |
geminiCodeCompletion.temperature |
number |
0.2 |
Creativity (0.0–1.0) |
geminiCodeCompletion.debounceDelay |
number |
500 |
Delay (ms) before requesting |
geminiCodeCompletion.contextLines |
number |
60 |
Lines of context to send |
Available Models
- gemini-2.5-flash - Fast, free tier (recommended for coding)
- gemini-2.5-pro - More capable, premium
- gemini-3-flash-preview - Latest Gemini 3, fast
- gemini-3.1-pro-preview - Most capable, premium only
- gemini-3.1-flash-lite-preview - Lightweight & efficient
Commands
| Command |
Shortcut |
Description |
Gemini: Set API Key |
- |
Configure your API key securely |
Gemini: Enable Code Completion |
- |
Turn on completions |
Gemini: Disable Code Completion |
- |
Turn off completions |
Gemini: Select Model |
Click status bar |
Choose a different Gemini model |
Gemini: Clear Completion Cache |
- |
Clear cached completions |
Development
Building
npm run compile # Compile TypeScript → JavaScript
npm run watch # Watch for changes and compile
npm run lint # Check code with ESLint
Debugging
- Open the workspace in VS Code
- Press
F5 or go to Run → Start Debugging
- A new VS Code window opens with the extension loaded
- Set breakpoints and debug as normal
- Output channel shows extension logs: Output → Gemini Code Completion
Testing
npm run test # Run extension tests
Project Structure
.
├── src/
│ └── extension.ts # Main extension code
├── out/ # Compiled JavaScript (generated)
├── .vscode/
│ ├── launch.json # Debug configuration
│ ├── tasks.json # Build tasks
│ └── settings.json # Workspace settings
├── package.json # Project manifest
├── tsconfig.json # TypeScript config
└── README.md # This file
Troubleshooting
- Run
Gemini: Set API Key command
- Verify the key starts with
AIza...
Completions not appearing
- Check the Output → Gemini Code Completion channel for errors
- Verify your API key is valid
- Check that
geminiCodeCompletion.enabled is true
- Try selecting a different model with
Gemini: Select Model
Rate limit errors
- Wait a moment before triggering more completions
- Switch to a different model
- Check your API quota at aistudio.google.com
Slow completions
- Increase
debounceDelay to reduce requests
- Reduce
contextLines to send less context
- Try
gemini-2.5-flash instead of gemini-2.5-pro
Security & Privacy
- Your API key is never sent anywhere except to Google's servers
- Keys are stored securely in VS Code's local settings
- No analytics or telemetry is collected by this extension
- All completions requests go directly to Google's Generative AI API
License
MIT
Support & Contributing
- Report issues: GitHub Issues
- Contributing: Pull requests welcome!
| |