Production-ready OpenAI & Ollama compatible API powered by your ChatGPT plan.
Use your ChatGPT Plus/Pro account to call OpenAI models from code or alternate chat UIs.
Now with high-performance server, web dashboard, and automatic HTTPS support.
β οΈ Fork Notice: This is a personal fork of RayBytes/ChatMock maintained for personal use only. For feature requests, bug reports, and general support, please visit the original repository and contact the original author.
- β‘ 3-5x Faster: Gunicorn with gevent workers (200-500+ RPS vs 50 RPS)
- π High Concurrency: Handle 1000+ concurrent connections
- π Production-Ready: Battle-tested WSGI server with automatic worker management
- π Real-time Statistics: Monitor usage, rate limits, and analytics
- βοΈ Configuration UI: Change settings via web interface
- π Model Browser: Explore all available models and capabilities
- Access: http://localhost:8000/webui
- π Automatic HTTPS: Let's Encrypt SSL certificates
- π Reverse Proxy: Production-ready deployment
- βοΈ Load Balancing: Horizontal scaling support
π Complete Documentation | π¨ WebUI Guide | π Production Setup | π Traefik Guide
ChatMock runs a local server that creates an OpenAI/Ollama compatible API, and requests are then fulfilled using your authenticated ChatGPT login with the oauth client of Codex, OpenAI's coding CLI tool. This allows you to use GPT-5, GPT-5-Codex, and other models right through your OpenAI account, without requiring an api key. You are then able to use it in other chat apps or other coding tools.
This does require a paid ChatGPT account.
If you're on macOS, you can download the GUI app from the GitHub releases.
Note: Since ChatMock isn't signed with an Apple Developer ID, you may need to run the following command in your terminal to open the app:
xattr -dr com.apple.quarantine /Applications/ChatMock.app
You can also install ChatMock as a command-line tool using Homebrew:
brew tap RayBytes/chatmock
brew install chatmock
If you wish to just simply run this as a python flask server, you are also freely welcome too.
Clone or download this repository, then cd into the project directory. Then follow the instrunctions listed below.
- Sign in with your ChatGPT account and follow the prompts
python chatmock.py loginYou can make sure this worked by running python chatmock.py info
- After the login completes successfully, you can just simply start the local server
python chatmock.py serveThen, you can simply use the address and port as the baseURL as you require (http://127.0.0.1:8000 by default)
Reminder: When setting a baseURL in other applications, make you sure you include /v1/ at the end of the URL if you're using this as a OpenAI compatible endpoint (e.g http://127.0.0.1:8000/v1)
Quick Start:
# 1. Clone repository
git clone https://github.com/thebtf/ChatMock.git
cd ChatMock
# 2. Copy environment file
cp .env.example .env
# 3. Login with ChatGPT account
docker-compose --profile login up chatmock-login
# 4. Start server
docker-compose up -d
# 5. Access WebUI
# Open http://localhost:8000/webui in your browserProduction Deployment with Traefik (Automatic HTTPS):
# Configure domain in .env
echo "CHATMOCK_DOMAIN=chatmock.example.com" >> .env
echo "TRAEFIK_ACME_EMAIL=admin@example.com" >> .env
# Deploy with Traefik
docker-compose -f docker-compose.traefik.yml up -d
# Access at https://chatmock.example.com/webuiπ Complete Docker Documentation | π Production Guide | π Traefik Setup
from openai import OpenAI
client = OpenAI(
base_url="http://127.0.0.1:8000/v1",
api_key="key" # ignored
)
resp = client.chat.completions.create(
model="gpt-5",
messages=[{"role": "user", "content": "hello world"}]
)
print(resp.choices[0].message.content)curl http://127.0.0.1:8000/v1/chat/completions \
-H "Authorization: Bearer key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"messages": [{"role":"user","content":"hello world"}]
}'ChatMock now includes a modern web dashboard for monitoring and configuration.
Access the WebUI:
- Local: http://localhost:8000/webui
- Production: https://your-domain.com/webui
Features:
- π Real-time Statistics: View total requests, tokens, and usage patterns
- π Rate Limit Monitoring: Visual progress bars for 5-hour and weekly limits
- π Analytics Charts: Requests by model and date
- π¨ Model Browser: Explore all available models with capabilities
- βοΈ Configuration Management: Change settings via UI (runtime only)
- π Authentication Status: View your ChatGPT account info and plan
API Endpoints (also available for custom integrations):
GET /api/status- Authentication and user infoGET /api/stats- Usage statistics and rate limitsGET /api/models- Available models with detailsGET /api/config- Current configurationPOST /api/config- Update runtime settings
π WebUI Documentation
| Configuration | Requests/Sec | Avg Latency | P95 Latency | Memory |
|---|---|---|---|---|
| Flask Dev Server | 50 | 100ms | 200ms | 150MB |
| Gunicorn (4 workers) | 200 | 80ms | 150ms | 600MB |
| Gunicorn (8 workers) | 350 | 60ms | 120ms | 1.2GB |
| Gunicorn (16 workers) | 500 | 50ms | 100ms | 2.4GB |
Production Configuration:
USE_GUNICORN=1 # Enable Gunicorn (default)
GUNICORN_WORKERS=8 # Number of worker processesπ Production Deployment Guide
- Tool/Function calling
- Vision/Image understanding
- Thinking summaries (through thinking tags)
- Responses API (experimental)
- Thinking effort
- Web search (OpenAI native)
- High-performance production server
- Real-time monitoring dashboard
- Automatic HTTPS with Traefik
- Requires an active, paid ChatGPT account.
- Some context length might be taken up by internal instructions (but they dont seem to degrade the model)
- Use responsibly and at your own risk. This project is not affiliated with OpenAI, and is a educational exercise.
gpt-5gpt-5.1gpt-5.2gpt-5-codexgpt-5.2-codexgpt-5.1-codexgpt-5.1-codex-maxgpt-5.1-codex-minicodex-mini
ChatMock can be configured via environment variables (Docker) or command-line parameters (Python).
Copy .env.example to .env and customize:
# Server
PORT=8000
USE_GUNICORN=1 # Enable production server
GUNICORN_WORKERS=4 # Number of workers
# Reasoning
CHATGPT_LOCAL_REASONING_EFFORT=medium # minimal|low|medium|high|xhigh
CHATGPT_LOCAL_REASONING_SUMMARY=auto # auto|concise|detailed|none
CHATGPT_LOCAL_REASONING_COMPAT=think-tags # legacy|o3|think-tags|current
# Features
CHATGPT_LOCAL_ENABLE_WEB_SEARCH=false # Enable web search
CHATGPT_LOCAL_EXPOSE_REASONING_MODELS=false # Expose reasoning as models
VERBOSE=false # Enable verbose logging
# Traefik (Production)
CHATMOCK_DOMAIN=chatmock.example.com
TRAEFIK_ACME_EMAIL=admin@example.comπ Complete .env.example Reference
Access http://localhost:8000/webui to change settings in real-time:
- Reasoning effort and summary
- Web search enablement
- Verbose logging
- Model exposure
Note: WebUI changes are runtime only and reset on restart. For persistent changes, update environment variables.
python chatmock.py serve \
--reasoning-effort high \
--reasoning-summary detailed \
--enable-web-search \
--expose-reasoning-modelsAll parameters: python chatmock.py serve --help
PORT- Server port (default: 8000)USE_GUNICORN- Enable Gunicorn for production (default: 1)GUNICORN_WORKERS- Number of worker processes (default: CPU Γ 2 + 1)VERBOSEorCHATGPT_LOCAL_VERBOSE- Enable verbose request/response loggingDEBUG_LOGorCHATGPT_LOCAL_DEBUG- Enable compact debug loggingAPI_KEYorCHATGPT_LOCAL_API_KEY- Require API key for all/v1/*endpoints
Protect your ChatMock instance with API key authentication:
# Via environment variable
API_KEY=your-secret-key python chatmock.py serve
# Or via CLI argument
python chatmock.py serve --api-key your-secret-keyClients must include the key in requests:
curl http://127.0.0.1:8000/v1/models \
-H "Authorization: Bearer your-secret-key"Note: Health endpoints (/, /health) and WebUI (/webui/*, /api/*) remain unprotected.
-
CHATGPT_LOCAL_REASONING_EFFORT(minimal|low|medium|high|xhigh)- Controls computational effort for reasoning
- Higher effort = slower but potentially smarter responses
- Default:
medium - Note:
gpt-5.1family supportslow,medium, andhighwhilegpt-5.1-codex-maxaddsxhigh; neither offers aminimalvariant
-
CHATGPT_LOCAL_REASONING_SUMMARY(auto|concise|detailed|none)- Controls how reasoning summaries are presented
noneprovides fastest responses- Default:
auto
-
CHATGPT_LOCAL_REASONING_COMPAT(legacy|o3|think-tags|current)- Controls reasoning output format
think-tags: Returns in message text with thinking tagslegacy: Returns in separate reasoning field- Default:
think-tags
CHATGPT_LOCAL_ENABLE_WEB_SEARCH- Enable web search tool by defaultCHATGPT_LOCAL_EXPOSE_REASONING_MODELS- Expose reasoning levels as separate models (e.g., gpt-5-high, gpt-5-low)CHATGPT_LOCAL_DEBUG_MODEL- Force specific model for all requestsCHATGPT_LOCAL_ENABLE_RESPONSES_API- Enable experimental Responses API at/v1/responsesCHATGPT_LOCAL_RESPONSES_NO_BASE_INSTRUCTIONS- Forward client instructions as-is (don't inject base prompt)
Enable web search globally:
CHATGPT_LOCAL_ENABLE_WEB_SEARCH=trueOr per-request via API:
{
"model": "gpt-5",
"messages": [{"role":"user","content":"Find current METAR rules"}],
"responses_tools": [{"type": "web_search"}],
"responses_tool_choice": "auto"
}Supported tools:
{"type": "web_search"}- Standard web search{"type": "web_search_preview"}- Preview mode
Tool choice: "auto" (let model decide) or "none" (disable)
ChatMock supports the OpenAI Responses API at /v1/responses. Enable it with:
python chatmock.py serve --enable-responses-apiOr via environment variable:
CHATGPT_LOCAL_ENABLE_RESPONSES_API=trueImportant: This proxies to ChatGPT's internal endpoint, which has limitations compared to the official OpenAI Platform API:
store=trueis handled locally only (upstream requiresstore=false)previous_response_idis simulated locally (not supported upstream)- ChatMock provides local polyfills for these features
Streaming example:
curl -sN http://127.0.0.1:8000/v1/responses \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-5",
"stream": true,
"input": [
{"role":"user","content":[{"type":"input_text","text":"hello world"}]}
]
}'Non-streaming with storage:
curl -s http://127.0.0.1:8000/v1/responses \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-5",
"stream": false,
"store": true,
"input": [{"role":"user","content":[{"type":"input_text","text":"Say hi"}]}]
}'Retrieve stored response:
curl -s http://127.0.0.1:8000/v1/responses/{response_id}Supported features:
- Streaming and non-streaming modes
- Function tools and web_search
store(local storage forGET /v1/responses/{id})previous_response_id(local threading simulation)- Input formats: Responses
input, Chat-stylemessages, orpromptstring
For optimal production performance:
# High performance
USE_GUNICORN=1
GUNICORN_WORKERS=8
CHATGPT_LOCAL_REASONING_EFFORT=medium
CHATGPT_LOCAL_REASONING_SUMMARY=auto
# Fastest responses
USE_GUNICORN=1
GUNICORN_WORKERS=16
CHATGPT_LOCAL_REASONING_EFFORT=minimal
CHATGPT_LOCAL_REASONING_SUMMARY=none- Fastest responses: Set
reasoning_effort=minimalandreasoning_summary=none - Context size: Larger than regular ChatGPT interface
- Thinking tags: Use
reasoning_compat=legacyto avoid thinking tags in response text - Model variants: Enable
expose_reasoning_modelsfor easy model picker selection in chat apps
ChatMock supports multiple deployment strategies for different use cases:
Simple Python server for local testing:
python chatmock.py serve
# Access: http://localhost:8000Production-ready deployment with Gunicorn:
docker-compose up -d
# Access: http://localhost:8000
# WebUI: http://localhost:8000/webuiFeatures:
- β‘ High-performance Gunicorn server
- π Automatic worker management
- π¦ Persistent data storage
- π§ Easy configuration via .env
Full production stack with automatic HTTPS:
docker-compose -f docker-compose.traefik.yml up -d
# Access: https://chatmock.example.com
# WebUI: https://chatmock.example.com/webuiFeatures:
- π Automatic SSL/TLS certificates (Let's Encrypt)
- π Reverse proxy with health monitoring
- βοΈ Load balancing ready
- π Traefik dashboard integration
π Traefik Setup Guide
Scale horizontally with Kubernetes:
apiVersion: apps/v1
kind: Deployment
metadata:
name: chatmock
spec:
replicas: 3
# ... see docs/PRODUCTION.md for complete exampleFeatures:
- π Horizontal auto-scaling
- π₯ Health checks and liveness probes
- π Rolling updates
- π Resource limits and monitoring
π Complete Production Guide
| Method | Performance | Complexity | Best For |
|---|---|---|---|
| Python | Low | Simple | Development |
| Docker | High | Easy | Production (single server) |
| Traefik | High | Medium | Production (HTTPS) |
| Kubernetes | Very High | Advanced | Enterprise / High-scale |
Complete guides for all aspects of ChatMock:
- π Documentation Index - Start here
- π¨ WebUI Guide - Dashboard features and API
- π Production Deployment - Performance tuning and scaling
- π Traefik Integration - Automatic HTTPS setup
- π Docker Instructions - Docker basics and deployment
- βοΈ .env Reference - All configuration options
- Verify server is running:
docker-compose ps - Check logs:
docker-compose logs chatmock - Ensure port 8000 is accessible
- Increase workers:
GUNICORN_WORKERS=8 - Check resources:
docker stats chatmock - See Performance Guide
- Verify DNS points to server
- Check Traefik logs:
docker logs traefik - See Traefik Guide
For more help, check the documentation or open an issue.