-
-
Notifications
You must be signed in to change notification settings - Fork 27
Architecture
Suhaib Bin Younis edited this page Dec 23, 2025
·
1 revision
The GitHub Copilot API Gateway is designed as a secure, local proxy that standardizes interactions with GitHub Copilot's underlying models. It transforms various API formats (OpenAI, Anthropic, Google) into a unified interface that communicates with the Copilot backend.
graph TD
Client[Client App (Cursor, LangChain, etc.)] -->|HTTP/REST| Gateway[Copilot API Gateway (Localhost:3030)]
Gateway -->|Auth Handshake| VSCode[VS Code Authentication]
Gateway -->|Model Inference| GitHub[GitHub Copilot API]
subgraph "Extension Internals"
Gateway --> Router[Endpoint Router]
Router -->|/v1/chat/completions| OpenAILayer[OpenAI Compatibility Layer]
Router -->|/v1/messages| AnthropicLayer[Anthropic Compatibility Layer]
Router -->|/v1beta/models| GoogleLayer[Google Compatibility Layer]
Gateway --> Security[Security & Redaction]
Gateway --> Audit[Audit Logging]
Gateway --> MCP[MCP Service]
end
The heart of the extension. It spins up a Node.js HTTP/S server that listens for incoming requests.
-
Port Management: Default port
3030, configurable. - Protocol Support: HTTP, HTTPS, and WebSockets.
-
Request Lifecycle:
-
Authentication: Verifies
Authorizationheader against configured API key. - Security Checks: Validates IP against Allowlist and checks rate limits.
- Redaction: Scans request body for sensitive PII (redaction patterns) before processing.
- Routing: Dispatches to the appropriate provider handler.
- Proxying: Authenticates with GitHub using the user's active VS Code session and forwards the request.
- Telemetry: Logs usage, tokens, and latency.
-
Authentication: Verifies
Security is paramount since the gateway exposes an API.
- IP Allowlisting: Middleware that rejects connections from unknown IPs/CIDRs.
- Data Redaction: A Regex-based engine that sanitizes both input prompts and output responses.
-
Audit Logging:
AuditServicerecords immutable logs of all traffic for compliance.
A built-in platform for "Micro-Apps" that leverage the local API.
-
Registry:
src/apps/registry.tsmanages available apps. - Execution: Apps run within the extension host but can interact with the VS Code UI via the side panel.
Implements the standardized protocol for connecting AI models to external tools and data contexts.