CostPilot
Intelligently route Copilot Chat prompts to the optimal model — save up to 65% on AI API costs.
💸 Why CostPilot?
If you use GitHub Copilot Business or Enterprise, you're likely paying maximum API costs because the chat defaults to the smartest, most expensive model (like Claude 3.5 Sonnet or GPT-4o) for every single prompt.
CostPilot fixes this. It acts as a lightweight router that sits between you and Copilot. When you ask a simple question like "how to center a div", it routes it to a fast, cheap model (like Gemini 3.5 Flash). When you ask a complex architectural question, it dynamically routes it to the most powerful model (like Claude Opus).
Based on performance simulations, CostPilot reduces AI compute costs by over 60% with zero noticeable drop in response quality.
🧠 The 6-Layer Intelligence Pipeline
CostPilot doesn't just guess. It uses a sophisticated 6-layer pipeline to calculate a Complexity Score (0-100) for every prompt in milliseconds:
- Local Classifier: Instantly scans your prompt for technical keywords, reasoning markers, and code complexity.
- Meta-Model Router: Asks a lightweight model (Gemini Flash) for a second opinion on the prompt's difficulty.
- Conversation History: Automatically escalates to smarter models if you are deep in a long debugging session.
- File Context: Detects what file you have open. (e.g., C++ or Rust automatically get a complexity bump).
- Adaptive Feedback: Learns from your thumbs-up/down ratings. If a cheap model failed at debugging last time, it remembers to use a smarter model next time.
- Budget Enforcer: Tracks your monthly token limit and automatically downgrades models to save money when you're running low.
🚀 Features
- Zero-Config Setup: Works instantly out of the box. No custom API keys required; it uses your existing Copilot subscription.
- Budget Tracking: Set a monthly token limit and get a visual dashboard of your usage.
- Intent-Optimized System Prompts: Automatically injects specialized system instructions depending on if you are debugging, refactoring, or writing new code.
- Project-Level Overrides: Drop a
.costpilot.json in your workspace to enforce specific models for specific repositories.
🎮 How to Use
Simply mention @costpilot in your Copilot Chat:
@costpilot explain what a Promise is in JavaScript
(CostPilot detects a basic question -> Routes to Claude Haiku)
@costpilot debug this memory leak in my Node.js websocket server
(CostPilot detects a complex debugging task -> Routes to GPT-5.6 Luna)
Slash Commands
@costpilot /stats - View your session routing stats, cost savings, and budget.
@costpilot /budget - View token budget usage and remaining allowance.
@costpilot /models - List all available models in your routing hierarchy.
@costpilot /feedback-up - Rate the last routing as good.
@costpilot /feedback-down - Rate the last routing as poor (CostPilot will learn).
⚙️ Configuration
You can fully customize the routing hierarchy in VS Code Settings (Cmd/Ctrl + , -> search for "CostPilot").
| Tier |
Default Model |
Description |
| Trivial |
Gemini 3.5 Flash |
Basic definitions, syntax lookup |
| Basic |
Claude Haiku 4.5 |
Simple how-tos |
| Simple |
GPT-5 mini |
Boilerplate generation |
| Moderate |
GPT-5.4 mini |
Standard component writing |
| Intermediate |
Gemini 2.5 Pro |
Multi-file logic |
| Standard |
GPT-5.4 |
Moderate refactoring |
| Advanced |
GPT-5.5 |
Complex logic, edge cases |
| Complex |
GPT-5.6 Luna |
Heavy debugging, performance |
| Expert |
Claude Sonnet 5 |
System design, architecture |
| Master |
Claude Opus 4.7 |
Deep theoretical problems |
🔒 Privacy & Data
CostPilot runs entirely locally in your VS Code instance (except for the Meta-Router, which leverages the standard Copilot API). Your prompts are never stored, logged, or sent to any third-party servers.
Launch Note: This extension is currently 100% FREE. Install it now to lock in your access to the core intelligence pipeline.
Built with ❤️ by Madhav Anand.