Skip to content
| Marketplace
Sign in
Visual Studio Code>AI>CopilotAPI BridgeNew to Visual Studio Code? Get it now.
CopilotAPI Bridge

CopilotAPI Bridge

Mahesh-AI-Ethusiast

|
5 installs
| (0) | Free
Bridge GitHub Copilot to local REST API with OpenAI-compatible endpoints. Requires active GitHub Copilot subscription.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CopilotAPI Bridge

A VS Code extension that bridges GitHub Copilot models to provide universal API access via a local REST server with OpenAI-compatible endpoints.

✨ Features

  • 🌉 Multiple AI Models: Access to AI models based on your GitHub Copilot subscription
  • 🔌 OpenAI-Compatible API: Drop-in replacement for OpenAI API clients
  • 🔐 Enterprise Security: API key authentication & rate limiting (200 req/15min)
  • 💬 Chat Participant: Use @bridge in VS Code chat for instant AI assistance
  • 🚀 Local Server: Runs on localhost:4000 - no external dependencies
  • 📊 Dual API Format: Both OpenAI-compatible and enhanced endpoints

🚀 Quick Start

Prerequisites

  1. Install GitHub Copilot Extension (if not already installed)
  2. Sign in to GitHub Copilot in VS Code
  3. Verify Copilot is Active - Ensure you see the Copilot icon in VS Code status bar

Setup CopilotAPI Bridge

  1. Install Extension (from VSIX or Marketplace)
  2. Start Server: Press Ctrl+Shift+P → Start CopilotAPI Bridge API Server
  3. Get API Key: Press Ctrl+Shift+P → Show API Key
  4. Check Available Models: curl http://localhost:4000/v1/models
  5. Start Coding: Use the API in your applications!

📡 API Endpoints

Public Endpoints (No Authentication)

Endpoint Method Description
/health GET Health check
/v1/models GET List available AI models (OpenAI format)
/v1/chat/completions POST OpenAI-compatible chat completions
/security/status GET Security status & rate limit info

Authenticated Endpoints (Requires X-API-Key Header)

Endpoint Method Description
/api GET API information & endpoint list
/api/test GET Test API connection & authentication
/api/chat POST Enhanced chat with custom response format
/api/explain POST Code explanation
/api/review POST Code review

💻 Usage Examples

OpenAI-Compatible Format

# List all available models
curl http://localhost:4000/v1/models

# Chat completion (no API key required for /v1 endpoints)
curl -X POST http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

PowerShell Example

# Get your API key from VS Code command palette first

# Test with GPT-4o
$body = @{
    model = "gpt-4o"
    messages = @(
        @{ role = "user"; content = "What is 2+2?" }
    )
} | ConvertTo-Json -Depth 10

Invoke-RestMethod -Uri "http://localhost:4000/v1/chat/completions" `
  -Method Post `
  -Headers @{"Content-Type"="application/json"} `
  -Body $body

Enhanced API Format (Requires Authentication)

# Get API info
curl http://localhost:4000/api \
  -H "X-API-Key: your_api_key_here"

# Enhanced chat
curl -X POST http://localhost:4000/api/chat \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": "Explain async/await"}
    ]
  }'

# Code explanation
curl -X POST http://localhost:4000/api/explain \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "function add(a, b) { return a + b; }",
    "language": "javascript"
  }'

🤖 Available Models

Model availability depends on your GitHub Copilot subscription:

GitHub Copilot Free/Pro

  • Basic models like GPT-3.5-turbo, GPT-4o-mini
  • Standard Claude models

GitHub Copilot Enterprise/Premium

Access to advanced models including:

  • GPT Family: gpt-4.1, gpt-5-mini, gpt-5, gpt-3.5-turbo, gpt-4o-mini, gpt-4, gpt-4-turbo, gpt-4o, gpt-5-codex
  • Claude Family: claude-3.5-sonnet, claude-sonnet-4, claude-sonnet-4.5, claude-haiku-4.5
  • Google: gemini-2.5-pro
  • Others: o3-mini, grok-code

Note: The extension automatically detects available models based on your active Copilot subscription. Use GET /v1/models to see your available models.

💬 Chat Participant

Use @bridge in VS Code chat:

  • @bridge /help - Get help
  • @bridge /explain - Explain selected code
  • @bridge /review - Review code
  • @bridge /api - Show API endpoints

🔐 Security Features

  • ✅ API Key Authentication (64-character keys with cb_ prefix)
  • ✅ Rate Limiting (200 requests per 15 minutes)
  • ✅ CORS Enabled for local development
  • ✅ Secure key storage in VS Code global state

📚 Commands

Access via Command Palette (Ctrl+Shift+P):

  • Start CopilotAPI Bridge API Server - Start the local API server
  • Stop CopilotAPI Bridge API Server - Stop the server
  • Show API Key - Display your API key
  • Regenerate API Key - Generate a new API key
  • Test AI Model Connection - Test connection to Copilot models
  • Show API Documentation - Open API docs in webview
  • Show Security Status - View security and rate limit status

🧪 Testing

See TESTING.md for comprehensive testing guide.

Quick test:

# Health check
curl http://localhost:4000/health

# List models
curl http://localhost:4000/v1/models

# Test chat
curl -X POST http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello!"}]}'

📦 Installation

From VSIX

code --install-extension copilotapi-bridge-1.0.3.vsix

From Marketplace

Coming soon! Search for "CopilotAPI Bridge" in VS Code Extensions.

🛠️ Development

# Install dependencies
npm install

# Build
npm run compile

# Package
npm run package

📖 Documentation

  • TESTING.md - Testing guide
  • CHAT_TESTING.md - Chat participant testing
  • QUICK_REFERENCE.md - Quick reference card
  • PUBLISHING.md - Publishing to marketplace

⚠️ Requirements

  • VS Code: Version 1.105.0 or higher
  • GitHub Copilot Extension: Must be installed and activated
  • GitHub Copilot Subscription: Active subscription (Free, Pro, or Enterprise)
    • Free/Pro: Access to basic models
    • Enterprise/Premium: Access to advanced models (GPT-5, Claude 4, Gemini, etc.)

Important: This extension acts as a bridge to GitHub Copilot. It requires an active GitHub Copilot extension and subscription. The available AI models depend on your specific Copilot plan.

🤝 Contributing

See CONTRIBUTING.md for contribution guidelines.

🔒 Security

Report security issues to: mahesh.ai.enthusiast@gmail.com

See SECURITY.md for security policy.

📝 License

ISC License - See LICENSE file for details

🙏 Acknowledgments

Built on top of VS Code Language Model API and GitHub Copilot.


Made with ❤️ by Mahesh

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft