Dev.to · 3 min read

I Built a Local Gateway for Using ChatGPT and Gemini from VS Code

I Built a Local Gateway for Using ChatGPT and Gemini from VS Code

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.

This is a summary aggregated from Dev.to. Read the complete article on the original site:

Read full article at Dev.to

More AI & Machine Learning News