DEV Community

Onwuka Gideon
Onwuka Gideon

Posted on

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Create the local environment file:

cp .env.example .env
Enter fullscreen mode Exit fullscreen mode

Start the services:

docker compose up -d
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

You should receive:

{"status":"ok"}
Enter fullscreen mode Exit fullscreen mode

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"
      }
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

Connecting it to VS Code

In VS Code:

  1. Open the model picker in the Chat view.
  2. Select Manage Models.
  3. Select Add Models.
  4. Choose Custom Endpoint.
  5. Create a model group, such as Chat Model Relay.
  6. Set the endpoint to:
http://localhost:8650/v1
Enter fullscreen mode Exit fullscreen mode
  1. Choose the Chat Completions API format.
  2. Add the model name:
catgpt-browser
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)