Local AI Bridge runs a localhost server inside VS Code and exposes chat-capable vscode.lm models through:
- HTTP/WebSocket endpoints for local clients
- streamed responses (SSE or WebSocket)
- a built-in browser chat UI at
http://127.0.0.1:<port>/
The bridge is provider-agnostic. It discovers models via vscode.lm.selectChatModels() and does not hardcode model vendors.
- Developers who want a local bridge between VS Code
vscode.lmmodels and external clients - Teams validating chat integration behavior (streaming, stop/cancel, connection lifecycle)
- Developers testing OpenAI-ready apps against local model providers with a thin adapter layer
Local AI Bridge exposes a custom bridge API (/chat, /models, /chat/stream, /chat/ws), not a full OpenAI API clone. If your app expects OpenAI endpoints directly, add an adapter/proxy layer.
- Binds to
127.0.0.1only (never0.0.0.0) - Activity Bar integration with a dedicated Local AI Bridge icon
- Native collapsible sidebar sections:
Connection(status + Start/Stop)Controls(port/transport/autoStart + Save/Reset)Event Logs(live bridge events)
- Command Palette support:
Local AI: Start ServerLocal AI: Stop Server
- Streaming transport modes:
- SSE (
/chat/stream) - WebSocket (
/chat/ws)
- SSE (
- Built-in UI + standalone external demo web app
- VS Code
^1.95.0 - Node.js 18+ (recommended for local build)
- At least one VS Code extension that exposes models through
vscode.lm
- Open this project in VS Code.
- Run:
npm install npm run compile
- Press
F5to launch an Extension Development Host window. - In the host window, click the Local AI Bridge icon in the Activity Bar.
- Build and package:
npm install npm run compile npx @vscode/vsce package
- Install:
- Command Palette:
Extensions: Install from VSIX... - choose the generated
.vsix(for examplelocal-ai-bridge-0.0.1.vsix)
- Command Palette:
- Reload VS Code and open the Local AI Bridge Activity Bar view.
- Shows current status (
Ready/Stopped/ error) - Shows URL, transport, and port
StartandStopcontrol the bridge server
- Edit runtime settings:
PortTransport(sseorwebsocket)Auto start on launch
Savepersists settingsResetre-syncs fields from current extension state
- Displays live bridge-wide events (
/events) - Includes request/response, stream, and connection lifecycle logs
{
"localAI.transport": "sse",
"localAI.port": 3000,
"localAI.autoStart": true
}localAI.transport:"sse"or"websocket"(default:"sse")localAI.port:1024-65535(default:3000)localAI.autoStart: starts server on VS Code launch
If the server is running, changing localAI.port or localAI.transport restarts it automatically.
Use either client depending on your goal:
- Built-in UI (
webview/index.html)- URL:
http://127.0.0.1:<port>/ - Best for quick validation of extension behavior
- URL:
- External demo web (
demo-web/index.html)- Run:
npm run demo - URL:
http://127.0.0.1:3001 - Best for testing an external browser app against the bridge API
- Run:
Base URL: http://127.0.0.1:<port>
GET /health->{ "ok": true }GET /config->{ "transport": "sse|websocket", "port": <number>, "version": "..." }GET /models->{ "models": [...] }POST /chat- request:
{ "prompt": "...", "model": "...", "clientId": "..." } - response:
202 { "accepted": true, "clientId": "..." }
- request:
POST /chat/stop- request:
{ "clientId": "..." } - response:
{ "stopped": true|false, "clientId": "..." }
- request:
GET /chat/stream?clientId=...(SSE mode only)WS /chat/ws?clientId=...(WebSocket mode only)- optional client message:
{ "type": "stop" }
- optional client message:
{ "delta": "partial text", "done": false }{ "delta": "", "done": true }{ "error": "message", "done": true }npm run compilebuild TypeScript toout/npm run watchTypeScript watch modenpm run demorun external demo web athttp://127.0.0.1:3001npm run vscode:prepublishprepublish compile
vscode.lm stream
|
v
StreamTransport (interface)
|-- SseTransport -> GET /chat/stream
`-- WebSocketTransport -> WS /chat/ws
Key files:
src/extension.tsactivation, commands, config lifecycle, sidebar wiringsrc/sidebar.tsActivity Bar multi-view webview UIsrc/server.tsserver bootstrap, localhost restriction, static/config routessrc/routes/chat.tschat/model/stream routing and client sessionssrc/llm.tsmodel lookup and token streaming fromvscode.lmsrc/transport/*transport implementations
- Server binds to localhost only
- Non-local remote addresses are rejected
- CORS is enabled for local web app interoperability
- No authentication (intended for trusted local use)
- No models listed:
- install/sign in to a provider extension that supports
vscode.lm
- install/sign in to a provider extension that supports
409onPOST /chat:- connect stream endpoint first (
/chat/streamor/chat/ws) with sameclientId
- connect stream endpoint first (
- Transport endpoint errors:
- ensure endpoint matches
localAI.transport
- ensure endpoint matches
- Port conflict:
- change
localAI.portand retry
- change

