Groq Code Completion for VSCode
AI-powered code completion using Groq's lightning-fast inference API. Get intelligent code suggestions with low latency using models like Mixtral, Llama 3, and more.
Features
Smart Context Detection: Automatically detects where to complete code
- Completion markers (
// TODO:
, // COMPLETE:
, etc.)
- Empty function bodies
- Empty code blocks
- Current cursor position
Multi-file Context: Analyzes all open tabs to understand your project structure
Fast Streaming: See code being generated in real-time
Multiple Models: Choose from various Groq models optimized for different use cases
Quick Start
Prerequisites
- Groq API Key: Get one from console.groq.com
- Node.js: Version 16.x or higher
- VSCode: Version 1.85.0 or higher
Installation
Clone this repository:
git clone <repository-url>
cd groq-code-completion
Install dependencies:
npm install
Compile the extension:
npm run compile
Open in VSCode:
code .
Press F5
to launch a new Extension Development Host window
Configure your API key in VSCode settings:
- Open Settings (Ctrl/Cmd + ,)
- Search for "Groq"
- Enter your API key
Usage
Method 1: Using Markers
Add a marker where you want AI to complete code:
function calculateTotal(items) {
// TODO: implement calculation logic
}
Then press Ctrl+Shift+G (Cmd+Shift+G on Mac)
Method 2: Empty Functions
def process_data(data):
# Place cursor here and press Ctrl+Shift+G
Method 3: Empty Blocks
if (user.isAuthenticated) {
// Cursor here + Ctrl+Shift+G
}
Method 4: Anywhere
Just place your cursor and press the hotkey!
Configuration
Access settings through VSCode Settings (search for "Groq"):
Setting |
Description |
Default |
apiKey |
Your Groq API key |
- |
model |
AI model to use |
mixtral-8x7b-32768 |
maxTokens |
Maximum tokens to generate |
2048 |
temperature |
Creativity (0=deterministic, 1=creative) |
0.3 |
streaming |
Enable live streaming |
true |
contextFileLimit |
Max open files to include as context |
5 |
Available Models
- mixtral-8x7b-32768: Best for code (32k context) - Recommended
- llama3-70b-8192: Large, powerful model (8k context)
- llama3-8b-8192: Fast, efficient model (8k context)
- gemma-7b-it: Lightweight model
- gemma2-9b-it: Improved lightweight model
Tips for Best Results
Use descriptive markers:
// TODO: implement binary search with error handling
Keep related files open: The AI uses all open tabs for context
Define function signatures first:
def merge_sort(arr: List[int]) -> List[int]:
# AI will implement based on signature
Adjust temperature:
- Low (0.1-0.3): Predictable, conventional code
- High (0.5-0.7): More creative solutions
Development
Building from Source
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Watch mode (auto-compile)
npm run watch
# Run linter
npm run lint
Packaging
To create a .vsix file for distribution:
npm install -g vsce
vsce package
Publishing
vsce publish
Troubleshooting
"No completion generated"
- Try a different model (mixtral-8x7b-32768 is most reliable)
- Increase maxTokens in settings
- Provide more context with comments
"API key not set"
- Check VSCode settings (Groq Code Completion section)
- Or set environment variable:
export GROQ_API_KEY=your_key
Slow responses
- Try llama3-8b-8192 for faster inference
- Reduce contextFileLimit in settings
- Disable streaming for single-shot completion
Incorrect completions
- Add comments explaining what you need
- Open related files for better context
- Use more specific markers
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
MIT License - see LICENSE file for details
Acknowledgments
- Built with the Groq SDK
- Inspired by GitHub Copilot and similar tools
- Thanks to the VSCode extension API documentation