AI & ML
I Built a Local Gateway for Using ChatGPT and Gemini from VS Code
Onwuka Gideon Dev.to (EN Zone)
7 views
I wanted to use my existing ChatGPT and Gemini browser sessions from developer tools such as VS Code without managing separate API keys, model subscriptions, and provider-specific integrations.
That led me to build Chat Model Relay.
It is a self-hosted, experimental gateway that connects an IDE client to a logged-in browser session:
VS Code → Chat Model Relay → ChatGPT or Gemini browser session
The gateway exposes familiar API endpoints while the provider interaction happens through a persistent browser session.
What it supports
OpenAI-compatible chat completions
ChatGPT and Gemini browser sessions
VS Code custom model endpoints
Persistent conversations and session routing
File attachments and vision requests
Tool-call translation
Image-generation requests where supported
Long-prompt attachment fallback
Docker Compose deployment
Health checks and optional API authentication
The project is designed primarily for VS Code. Other compatible clients may work, but should be tested individually.
Quick start
Clone the repository:
git clone https://github.com/dongido001/chat-model-relay.git
cd chat-model-relay
Create the local environment file:
cp .env.example .env
Start the services:
docker compose up -d
Then open the browser login pages:
ChatGPT: http://localhost:5800
Gemini: http://localhost:5801
After logging in, verify the gateway:
curl http://localhost:8650/healthz
You should receive:
{"status":"ok"}
A basic request looks like this:
curl http://localhost:8650/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "catgpt-browser",
"messages": [
{
"role": "user",
"content": "Explain this function"
}
]
}'
Connecting it to VS Code
In VS Code:
Open the model picker in the Chat view.
Select Manage Models.
Select Add Models.
Choose Custom Endpoint.
Create a model group, such as Chat Model Relay.
Set the endpoint to:
http://localhost:8650/v1
Choose the Chat Completions API format.
Add the model name:
catgpt-browser
If authentication is enabled, add the API key configured in .env.
Why browser-backed?
This project is aimed at local experimentation with services that users already access through browser accounts. It can be useful for testing IDE workflows, prompt handling, file uploads, and compatibility layers without immediately building a separate provider integration for every service.
That approach also introduces limitations. Browser layouts can change, login sessions can expire, provider behavior can vary, and browser automation is slower and less predictable than a native API.
The stream=true option is accepted for client compatibility, but browser generation completes before the gateway emits the response chunks. It is not live token streaming from the provider.
Long prompts
One useful feature is the long-prompt fallback. When a prompt is too large for the browser composer, the gateway can upload it as a temporary UTF-8 attachment and submit a shorter request referring to that attachment.
This avoids freezing the composer, but adds upload time and depends on the provider accepting file uploads.
Important disclaimer
Chat Model Relay is experimental software for personal testing. It is not an official ChatGPT or Gemini API, and it should not be exposed publicly without appropriate authentication and network controls.
Use it at your own risk, follow each provider’s terms, and never commit credentials or expose a logged-in browser session.
The project is available here:
github.com/dongido001/chat-model-relay
I’m especially interested in feedback from people using local gateways with VS Code, browser-backed providers, or custom language-model endpoints.
Read original: https://dev.to/dongido/i-built-a-local-gateway-for-using-chatgpt-and-gemini-from-vs-code-3aa6
← Previous
LG TVs caught spying even when offline or on standby
Next →
You Are Not Selling Your Code. You Are Selling the Next Commit
Related
Your AI Coding Agent Needs a Dependency Graph, Not Just a Repository
AI & ML
1
DEV Community
Where second-hand price data actually comes from: every source I tried, measured
AI & ML
0
DEV Community
A Rule Can Be Specific and Still Be Too Broad
AI & ML
2
Dev.to (EN Zone)
Building a Schema With an AI Agent Without Naming a Single Column
AI & ML
3
Dev.to (EN Zone)
Comments0
No comments yet — be the first