Chatgpt Gateway
OpenAI-compatible API gateway that uses your logged-in ChatGPT browser session
Ask AI about Chatgpt Gateway
Powered by Claude Β· Grounded in docs
I know everything about Chatgpt Gateway. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
ChatGPT Gateway
Use ChatGPT from any code, script, or tool β without an API key.
This is a browser extension paired with a tiny local server that exposes your logged-in ChatGPT session as a standard OpenAI-compatible API at localhost:18790. Any application that speaks the OpenAI chat completions format can use it out of the box β just swap the base URL.
Why? OpenAI API access requires a separate paid plan and API keys. If you already have a ChatGPT subscription (Free, Plus, or Team), this tool lets you use it programmatically. It automates the ChatGPT web interface through your browser β exactly like you would manually, but from code.
![]()
How it works
Your app / curl / any OpenAI-compatible client
β HTTP POST (localhost:18790)
Local gateway server (Node.js)
β WebSocket
Browser extension (background worker)
β chrome.tabs message
Content script on chatgpt.com
β DOM automation (type β send β read response)
ChatGPT (your logged-in browser session)
The extension's content script types your message into ChatGPT's input field, clicks send, waits for the response to finish streaming, extracts the text, and returns it through the chain. The gateway server wraps the result in an OpenAI-compatible JSON response.
Can I keep using my browser?
Yes. The extension only interacts with the ChatGPT tab. All other tabs work normally. You can browse, work, watch videos β whatever you want.
The only rule: don't manually type in the ChatGPT tab while a request is in progress. The content script is actively using that tab's input field and reading the response DOM. Between requests, you can use ChatGPT manually as usual.
You do not need a separate browser profile or window. Your everyday Chrome or Firefox works fine.
Setup
1. Install the extension
Chrome:
- Go to
chrome://extensions - Enable Developer mode (toggle in top-right)
- Click Load unpacked β select this repo's root directory
Firefox:
- Go to
about:debugging#/runtime/this-firefox - Click Load Temporary Add-on β select
manifest.firefox.json
2. Start the gateway server
npm install
npm start
3. Open ChatGPT
Navigate to chatgpt.com and make sure you're logged in. Click the extension icon to verify β both dots should be green.
Usage
curl
curl -X POST http://localhost:18790/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Hello!"}]}'
Python
from openai import OpenAI
client = OpenAI(base_url="http://localhost:18790/v1", api_key="unused")
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
Node.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "http://localhost:18790/v1", apiKey: "unused" });
const response = await client.chat.completions.create({
model: "auto",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);
API
POST /v1/chat/completions
OpenAI-compatible chat completions endpoint.
| Field | Type | Default | Description |
|---|---|---|---|
messages | array | required | Array of {role, content} message objects |
model | string | "auto" | Model hint β attempts to select via ChatGPT's model picker |
new_conversation | boolean | true | Start a fresh chat for each request |
timeout | number | 180000 | Max wait time in ms for ChatGPT to respond |
Response format matches the OpenAI Chat Completions API.
GET /health
{"status": "ok", "extensionConnected": true}
MCP Server
The mcp/ directory contains a Model Context Protocol server that wraps the gateway. This lets AI tools like Claude Code use ChatGPT directly as a tool.
Install
cd mcp && npm install
Configure (Claude Code)
Add to your MCP settings (~/.claude/settings.json or project .claude/settings.json):
{
"mcpServers": {
"chatgpt": {
"command": "node",
"args": ["/path/to/chatgpt-gateway/mcp/index.mjs"]
}
}
}
Tools
| Tool | Description |
|---|---|
chatgpt_status | Check if the gateway is running and extension is connected |
chatgpt_ask | Send a message to ChatGPT and get the response (10-120s, sends progress notifications) |
The chatgpt_ask tool supports progress notifications per the MCP spec β clients will see status updates like "Typing message...", "Waiting for response..." while ChatGPT processes the request.
Project structure
βββ manifest.json # Chrome extension manifest (MV3)
βββ manifest.firefox.json # Firefox extension manifest (MV3)
βββ background.js # Service worker β WebSocket bridge to gateway
βββ content.js # Content script β ChatGPT DOM automation
βββ popup.html / popup.js # Extension popup β connection status UI
βββ server.mjs # Gateway HTTP + WebSocket server
βββ icons/ # Extension icons (16/32/48/128px)
βββ package.json # Server dependencies
βββ mcp/ # MCP server
βββ index.mjs # MCP stdio server
βββ package.json # MCP dependencies
Limitations
- One request at a time. The extension automates a single ChatGPT tab, so requests are serialized. Concurrent requests will queue on the server side.
- No streaming. Responses are returned after ChatGPT finishes generating. Streaming support may come later.
- DOM-dependent. If ChatGPT significantly changes its UI, the content script selectors may need updating.
- Session-bound. If your ChatGPT session expires, refresh the tab or re-login.
Requirements
- Node.js 18+
- Chrome or Firefox
- Active ChatGPT session (Free, Plus, or Team)
License
MIT
