One extension. Every AI model. Zero vendor lock-in.
CodeBridge is an open-source VS Code extension that gives you a single, unified interface to every major AI coding provider — Anthropic Claude, OpenAI GPT, Google Gemini, and local models via Ollama. Instead of juggling separate subscriptions and extensions, CodeBridge intelligently routes each task to the optimal model based on complexity, cost, and your preferences.
Today's developers face a fragmented AI tooling landscape:
| Pain Point | What Happens |
|---|---|
| Vendor lock-in | You pay for Copilot, then need Claude for complex refactoring, then Gemini for long-context tasks |
| Cost blindness | No visibility into how much you're spending across providers |
| Manual model selection | You constantly decide "which AI should I use for this?" |
| Multiple extensions | Each provider has its own extension, keybindings, and UX |
CodeBridge solves all four problems with two core innovations:
Every request is classified by complexity (1–10 scale) and automatically routed to the best model. A simple variable rename doesn't need GPT-4 — it goes to a fast, cheap model. A complex multi-file refactor gets escalated to a premium model. You never think about model selection again.
Real-time cost tracking across all providers, with monthly budgets and automatic downgrade when limits are hit. See exactly where your money goes — by provider, by task type, by day.
- 5 routing strategies: Balanced, Cost-Optimized, Quality-First, Local-First, Manual
- Automatic complexity classification based on code structure, language, and task type
- Tier-based model selection: Economy → Standard → Premium based on what the task needs
- Budget-aware fallback: Automatically routes to cheapest model when budget is exceeded
- Anthropic Claude — Sonnet 4, Haiku 4.5, Opus 4.6
- OpenAI — GPT-4.1, GPT-4.1 Mini, o3
- Google Gemini — 2.0 Flash, 2.5 Pro
- Ollama — Any local model (CodeLlama, DeepSeek Coder, Qwen 2.5 Coder)
- OpenAI-compatible APIs — Azure OpenAI, LM Studio, LocalAI, vLLM
- Explain Code — Clear breakdown of what selected code does
- Refactor Code — Clean code improvements with one click
- Generate Tests — Comprehensive unit tests with edge cases
- Code Review — Structured feedback with severity ratings
- Add Documentation — JSDoc/docstrings/inline comments
- Fix Error — Root cause analysis and auto-fix
- Streaming responses in a VS Code sidebar panel
- Routing info badge on every response (which model, why)
- Per-message cost display
- Code context from active editor automatically included
- Ghost-text suggestions as you type
- Debounced to avoid excessive API calls
- Routed to fastest/cheapest model for low-latency
- Real-time monthly spend in the status bar
- Breakdown by provider, task type, and time period
- Configurable monthly budget with warning thresholds
- Automatic cost-saving mode when budget is exceeded
- VS Code 1.85+
- At least one API key (or Ollama installed locally)
# Clone the repository
git clone https://github.com/saurabh-oss/code-bridge.git
cd code-bridge
# Install dependencies
npm install
# Compile
npm run compile
# Option A: Run in development mode
# Press F5 in VS Code to launch Extension Development Host
# Option B: Package and install
npm run package
# Then install the .vsix: Extensions → ⋯ → Install from VSIX- Open Command Palette (
Cmd+Shift+P/Ctrl+Shift+P) - Run "CodeBridge: Run Setup Wizard"
- Select your providers and enter API keys
- Choose a routing strategy (Balanced recommended)
- Done — start coding!
| Provider | Where to get it |
|---|---|
| Anthropic | console.anthropic.com |
| OpenAI | platform.openai.com/api-keys |
| aistudio.google.com/apikey | |
| Ollama | No key needed — install Ollama and pull a model |
┌──────────────────────────────────────────────────────┐
│ VS Code Extension │
│ │
│ ┌─────────┐ ┌──────────────┐ ┌──────────────────┐ │
│ │ Chat │ │ Commands │ │ Inline │ │
│ │ Panel │ │ (Actions) │ │ Completions │ │
│ └────┬─────┘ └──────┬───────┘ └────────┬─────────┘ │
│ │ │ │ │
│ └───────────────┼───────────────────┘ │
│ ▼ │
│ ┌────────────────────────┐ │
│ │ Intelligent Router │ ◄── Routing │
│ │ ┌────────────────┐ │ Strategy │
│ │ │ Task Classifier│ │ │
│ │ └────────────────┘ │ │
│ └───────────┬────────────┘ │
│ │ │
│ ┌───────────▼────────────┐ │
│ │ Provider Registry │ │
│ └───┬─────┬─────┬───┬───┘ │
│ │ │ │ │ │
│ ┌───▼┐ ┌──▼┐ ┌─▼┐ ┌▼────┐ │
│ │ An │ │ OA│ │Go│ │Olla │ │
│ │thro│ │ I │ │og│ │ ma │ │
│ └────┘ └───┘ └──┘ └─────┘ │
│ │
│ ┌────────────────────────┐ │
│ │ Cost Tracker │ ◄── Budget │
│ │ (persist to global) │ Management │
│ └────────────────────────┘ │
└──────────────────────────────────────────────────────┘
Plugin Architecture — Each provider is a self-contained class implementing IAiProvider. Adding a new provider (Mistral, Cohere, etc.) means creating one file with ~150 lines of code.
Strategy Pattern for Routing — The router applies different strategies without changing core logic. Strategies are swappable at runtime via the status bar.
Zero-Dependency Core — The extension uses no npm runtime dependencies. All HTTP calls use Node's built-in fetch. This keeps the bundle small and eliminates supply-chain risk.
Persistent Cost Tracking — Cost records are stored in VS Code's globalState (survives restarts). Records older than 90 days are auto-pruned.
All settings are under codeBridge.* in VS Code settings:
| Setting | Description |
|---|---|
providers.anthropic.apiKey |
Anthropic API key |
providers.anthropic.enabled |
Enable/disable Anthropic |
providers.openai.apiKey |
OpenAI API key |
providers.openai.enabled |
Enable/disable OpenAI |
providers.openai.baseUrl |
Custom base URL (Azure, LM Studio) |
providers.google.apiKey |
Google AI API key |
providers.google.enabled |
Enable/disable Google |
providers.ollama.enabled |
Enable/disable Ollama |
providers.ollama.baseUrl |
Ollama server URL |
providers.ollama.model |
Default Ollama model |
| Setting | Default | Description |
|---|---|---|
routing.strategy |
balanced |
Routing strategy |
routing.maxComplexityForCheapModel |
3 |
Complexity threshold for economy models |
| Setting | Default | Description |
|---|---|---|
cost.monthlyBudget |
0 |
Monthly budget in USD (0 = unlimited) |
cost.warningThreshold |
80 |
Warning at this % of budget |
| Setting | Default | Description |
|---|---|---|
completion.enabled |
true |
Enable inline completions |
completion.debounceMs |
500 |
Debounce delay |
| Action | Windows/Linux | macOS |
|---|---|---|
| Open Chat | Ctrl+Shift+A |
Cmd+Shift+A |
| Inline Complete | Ctrl+Shift+Space |
Cmd+Shift+Space |
| Explain Code | Ctrl+Shift+E |
Cmd+Shift+E |
When you trigger any AI action, the router follows this pipeline:
1. CLASSIFY → Analyze code structure, language, task type → complexity score (1-10)
2. STRATEGIZE → Apply your chosen routing strategy to pick the target model tier
3. BUDGET → Check if monthly budget allows this tier, downgrade if over budget
4. EXECUTE → Call the selected provider's API
5. TRACK → Record tokens, cost, and latency
| Signal | Weight | Example |
|---|---|---|
| Task type difficulty | 35% | inline-completion = 2, refactor = 7 |
| Code length | 20% | 10 lines = 1, 300+ lines = 9 |
| Structural complexity | 20% | Few control flows = 2, many nested = 8 |
| Language difficulty | 15% | Python = 3, Rust = 5, Haskell = 6 |
| Multi-file context | 10% | Few imports = 1, many imports = 7 |
CodeBridge is designed for extensibility. To add a new provider:
- Create
src/providers/yourprovider.ts - Extend
BaseProvider - Implement
complete(),completeStream(),validateConnection() - Register it in
src/providers/registry.ts - Add configuration entries in
package.json
// src/providers/mistral.ts
export class MistralProvider extends BaseProvider {
readonly id: ProviderId = 'mistral'; // Add to ProviderId union type
readonly name = 'Mistral AI';
readonly models: ProviderModel[] = [
// ... define models with pricing
];
async complete(request: AiRequest): Promise<AiResponse> {
// Call Mistral API
}
// ...
}- Multi-turn chat memory — Maintain conversation context across messages
- Project-level context — Automatically include relevant files from the workspace
- Custom routing rules — "Always use Claude for Python, GPT for TypeScript"
- Response caching — Cache identical requests to avoid duplicate API calls
- Team sharing — Share cost dashboards and routing configs across a team
- Provider health monitoring — Auto-failover when a provider is down
- VS Code Marketplace publishing — One-click install
- Telemetry dashboard — Latency percentiles, error rates, model comparison
Contributions welcome! This is an open-source project and we value community input.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Watch mode (auto-recompile on changes)
npm run watch
# Run in Extension Development Host
# Press F5 in VS Code
# Lint
npm run lintApache License 2.0 — See LICENSE for details.
Built with the conviction that AI coding tools should be open, interoperable, and cost-transparent.