Turn ChatGPT into a FREE OpenAI-compatible API in seconds — no API key required.
- Kareem Adel — Owner & CEO at Wzila
mse_ai_api is a high-performance proxy server built with FastAPI and Playwright. It perfectly mimics the official OpenAI API structure by automating ChatGPT's free web interface in the background — making it a seamless drop-in replacement for n8n's OpenAI and HTTP nodes.
This version has been completely rewritten to support Advanced AI Agent Tool Calling reliably, bypassing strict JSON validation errors that plagued earlier approaches.
NEW UPDATE: Introducing
cli.py— a beautiful, interactive terminal client that connects directly to your mse_ai_api server!
- 🎨 Beautiful Terminal UI — Colored output with response numbering, timestamps, and elapsed time
- 💬 Full Conversation Memory — Maintains chat history within a session
- ⚡ Zero Dependencies — Uses only Python standard library (
urllib,json,textwrap) - 🔧 Fully Configurable — Server URL, API key, model, and display width via environment variables
- 💸 Zero API Costs — Uses ChatGPT's web interface via background browser automation
- ⚡ Lightning Fast — Built on asynchronous Python with FastAPI
- 🤖 Full n8n Agent Support — Advanced ChatGPT tool calling and JSON parsing
- 🔌 OpenAI-Compatible — Drop-in replacement for OpenAI API clients
- 🐳 Dockerized — One-command deployment
- 🔒 Secure — Protected by your own configurable API secret key
- 🖥️ CLI Client — Interactive terminal chat client included (
cli.py)
This proxy relies on a robust technical architecture in main.py designed for production AI workflows:
-
AsyncBrowserThread(The Engine) — Instead of spinning up a new browser per request, the API launches a single detached Python thread running an async Chrome browser via Playwright. It uses anti-bot bypass techniques (--disable-blink-features=AutomationControlled, spoofed user agents, webdriver hiding) so ChatGPT treats it as a real user session. -
Smart Prompt Injection (
format_prompt&format_tools_instruction) — When n8n sends tool definitions (via AI Agent nodes), the script dynamically rebuilds the prompt and injects precise system instructions commanding ChatGPT to output only valid JSON — guaranteeing it behaves like the programmatic API. -
Regex Parsing (
parse_tool_calls) — Once ChatGPT replies, the proxy scans the response for JSON blocks. If a tool call is detected, it extracts and formats it to meet OpenAI's strict function calling schema, then signals n8n to execute the tool locally. -
Flexible Endpoints — Natively supports both
/v1/chat/completions(legacy n8n setups) and/v1/responses(modern Responses API) for broad compatibility.
Deploying with Docker guarantees all dependencies (including headless Chrome and fonts) are perfectly configured.
git clone https://github.com/MohamedElsayed-debug/mse_ai_api.git
cd mse_ai_api
docker-compose up --build -dServer starts on http://localhost:7777
Requires Python 3.10+.
pip install -r requirements.txt
python main.pyOnce your server is running (via Docker or manually), you can chat with it directly from the terminal:
python cli.pyOr with custom settings:
MSE_SERVER=http://your-server:7777 MSE_API_KEY=your-key MSE_MODEL=gpt-4o python cli.py| Command | Description |
|---|---|
.help |
Show available commands |
.clear |
Reset conversation history |
.history |
Show message count this session |
.model |
Show active model name |
.status |
Ping server and show latency |
.exit |
Quit the CLI |
| Variable | Default | Description |
|---|---|---|
API_SECRET_KEY |
change-secret-key-2026 |
Your server's API key |
| Variable | Default | Description |
|---|---|---|
MSE_SERVER |
http://localhost:7777 |
Server URL to connect to |
MSE_API_KEY |
change-secret-key-2026 |
API key for authentication |
MSE_MODEL |
gpt-4o-mini |
Model name to send in requests |
MSE_WIDTH |
80 |
Terminal output width |
Base URL: http://localhost:7777
Endpoints:
POST /v1/chat/completions— Legacy OpenAI-compatible endpointPOST /v1/responses— Modern Responses API endpoint
Header: Authorization: Bearer <your-secret-key>
curl -X POST "http://localhost:7777/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer change-secret-key-2026" \
-d '{
"messages": [{ "role": "user", "content": "Hello, AI!" }],
"model": "gpt-4o-mini"
}'- Add an HTTP Request node in your n8n workflow
- Method:
POST - URL:
http://localhost:7777/v1/chat/completions - Header:
Authorization: Bearer change-secret-key-2026 - Body (JSON):
{
"messages": [{ "role": "user", "content": "Hello, AI!" }],
"model": "gpt-4o-mini"
}- In n8n, create a new OpenAI Account credential
- Set Base URL to:
http://localhost:7777/v1 - Set API Key to your server's secret (
change-secret-key-2026by default) - Use this credential across any AI Agent or LLM node seamlessly!
mse_ai_api is great for personal workflows. The PRO Version is built for teams and production environments on Django.
| Feature | This Repo | PRO Version |
|---|---|---|
| Free ChatGPT Web Backend | ✅ | ✅ |
| Advanced n8n Tool Calling | ✅ | ✅ |
| Image Analysis (HTTP URL) | ❌ | ✅ |
| Image Analysis (Base64/Binary) | ❌ | ✅ |
| Admin Dashboard (GUI) | ❌ | ✅ |
| Multi-User Management | ❌ | ✅ |
| Usage Statistics & Logging | ❌ | ✅ |
| Token Tracking & Quotas | ❌ | ✅ |
| Priority Support | ❌ | ✅ |
Interested in the PRO version or a custom integration?
- Telegram: @MohMsE
- LinkedIn: Mohamed Elsayed
- Facebook: Melsayed2001
- GitHub: @MohamedElsayed-debug
MIT License — see LICENSE for details.
Disclaimer: This project automates a web browser for personal and educational use. Usage must comply with the terms of service of the underlying platforms. The authors are not responsible for misuse.
