{"slug": "i-built-a-local-gateway-for-using-chatgpt-and-gemini-from-vs-code", "title": "I Built a Local Gateway for Using ChatGPT and Gemini from VS Code", "summary": "A developer has released Chat Model Relay, an open-source gateway that lets VS Code connect to ChatGPT and Gemini browser sessions without separate API keys. The self-hosted tool exposes OpenAI-compatible endpoints and includes a long-prompt fallback, though it is experimental and not recommended for public exposure.", "body_md": "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.\n\nThat led me to build **[Chat Model Relay](https://github.com/dongido001/chat-model-relay)**.\n\nIt is a self-hosted, experimental gateway that connects an IDE client to a logged-in browser session:\n\n```\nVS Code → Chat Model Relay → ChatGPT or Gemini browser session\n```\n\nThe gateway exposes familiar API endpoints while the provider interaction happens through a persistent browser session.\n\nThe project is designed primarily for VS Code. Other compatible clients may work, but should be tested individually.\n\nClone the repository:\n\n```\ngit clone https://github.com/dongido001/chat-model-relay.git\ncd chat-model-relay\n```\n\nCreate the local environment file:\n\n```\ncp .env.example .env\n```\n\nStart the services:\n\n```\ndocker compose up -d\n```\n\nThen open the browser login pages:\n\n`http://localhost:5800`\n`http://localhost:5801`\nAfter logging in, verify the gateway:\n\n```\ncurl http://localhost:8650/healthz\n```\n\nYou should receive:\n\n```\n{\"status\":\"ok\"}\n```\n\nA basic request looks like this:\n\n```\ncurl http://localhost:8650/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"catgpt-browser\",\n    \"messages\": [\n      {\n        \"role\": \"user\",\n        \"content\": \"Explain this function\"\n      }\n    ]\n  }'\n```\n\nIn VS Code:\n\n`Chat Model Relay`.\n\n```\nhttp://localhost:8650/v1\ncatgpt-browser\n```\n\nIf authentication is enabled, add the API key configured in `.env`.\n\nThis 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.\n\nThat 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.\n\nThe `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.\n\nOne 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.\n\nThis avoids freezing the composer, but adds upload time and depends on the provider accepting file uploads.\n\nChat 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.\n\nUse it at your own risk, follow each provider’s terms, and never commit credentials or expose a logged-in browser session.\n\nThe project is available here:\n\n[github.com/dongido001/chat-model-relay](https://github.com/dongido001/chat-model-relay)\n\nI’m especially interested in feedback from people using local gateways with VS Code, browser-backed providers, or custom language-model endpoints.", "url": "https://wpnews.pro/news/i-built-a-local-gateway-for-using-chatgpt-and-gemini-from-vs-code", "canonical_source": "https://dev.to/dongido/i-built-a-local-gateway-for-using-chatgpt-and-gemini-from-vs-code-3aa6", "published_at": "2026-09-08 11:31:00+00:00", "updated_at": "2026-09-08 12:02:23.606865+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools"], "entities": ["Chat Model Relay", "VS Code", "ChatGPT", "Gemini", "dongido001"], "alternates": {"html": "https://wpnews.pro/news/i-built-a-local-gateway-for-using-chatgpt-and-gemini-from-vs-code", "markdown": "https://wpnews.pro/news/i-built-a-local-gateway-for-using-chatgpt-and-gemini-from-vs-code.md", "text": "https://wpnews.pro/news/i-built-a-local-gateway-for-using-chatgpt-and-gemini-from-vs-code.txt", "jsonld": "https://wpnews.pro/news/i-built-a-local-gateway-for-using-chatgpt-and-gemini-from-vs-code.jsonld"}}