LLM Code Autocomplete for VSCode
AI-powered code completion using any OpenAI-compatible API endpoint. Get intelligent code suggestions with support for OpenAI, Groq, Anthropic, and other providers that support the OpenAI API format.
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 Providers: Works with any OpenAI-compatible API endpoint
Flexible Configuration: Customize API endpoints, models, and parameters
Quick Start
Prerequisites
- API Key: Get one from your preferred LLM provider:
- Node.js: Version 16.x or higher
- VSCode: Version 1.85.0 or higher
Installation
Clone this repository:
git clone <repository-url>
cd llm-code-autocomplete
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 settings in VSCode:
- Open Settings (Ctrl/Cmd + ,)
- Search for "LLM Code Autocomplete"
- Enter your API key and endpoint
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 "LLM Code Autocomplete"):
Setting |
Description |
Default |
apiKey |
Your API key for the LLM provider |
- |
apiEndpoint |
The OpenAI-compatible API endpoint URL |
http://localhost:8000/v1 |
model |
AI model to use (any model name supported by your endpoint) |
Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8 |
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 |
Example Endpoint Configurations
OpenAI:
- Endpoint:
https://api.openai.com/v1
- Models:
gpt-4
, gpt-3.5-turbo
, etc.
Groq:
- Endpoint:
https://api.groq.com/openai/v1
- Models:
mixtral-8x7b-32768
, llama3-70b-8192
, etc.
Local/Custom (e.g., vLLM, Ollama, etc.):
- Endpoint:
http://localhost:8000/v1
(default)
- Models: Depends on your setup (e.g.,
Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8
)
- API Key: Not required for vLLM (use "dummy" if needed)
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 suitable for your provider
- Increase maxTokens in settings
- Provide more context with comments
"API key not set"
- Check VSCode settings (LLM Code Autocomplete section)
- Or set environment variable:
export LLM_API_KEY=your_key
API endpoint errors
- Verify your endpoint URL is correct
- Ensure it includes
/v1
suffix for OpenAI compatibility
- Check that your API key is valid for the endpoint
Slow responses
- Try a smaller/faster model
- 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 OpenAI SDK
- Inspired by GitHub Copilot and similar tools
- Thanks to the VSCode extension API documentation