A local proxy for OpenAI-compatible API that detects model refusals and automatically rewrites prompts for retry.
- Transparent proxy — Forwards all
/v1/*requests to your target model endpoint - Fake
/v1/models— Returns a local model list so clients can check connectivity - Refusal detection — Scans the model's last reply against a configurable denylist
- Automatic prompt rewriting — When refusal is detected, an auxiliary model rewrites the last user message and retries
- GUI & CLI — Comes with both a desktop GUI (CustomTkinter) and a CLI mode
- Rust-accelerated filtering — Optional Aho-Corasick matcher via PyO3 for high-performance keyword detection
- Streaming support — Fully handles SSE streaming responses with buffered analysis
Client → GptBypass Proxy → Target Model
↓ ↓
Denylist Check Model Response
↓ ↓
Hit? → Rewrite Clean → Forward
Prompt via Aux to Client
Model → Retry
- Client sends a request through the proxy
- First attempt goes straight to the target model (no rewrite)
- Proxy buffers and analyzes the response
- If the response matches any denial keyword → discard, rewrite the prompt via the auxiliary model, and retry
- If the response is clean → forward to client
- Python 3.10+
- A target model API endpoint (OpenAI, local, or any compatible API)
- An auxiliary model API endpoint for prompt rewriting
git clone https://github.com/YOUR_USERNAME/GptBypass.git
cd GptBypass
pip install -r requirements.txtCopy the example config and fill in your API details:
cp config.example.json config.jsonEdit config.json:
{
"target_model": {
"model": "gpt-5.4",
"message_type": "responses",
"reasoning_depth": "high",
"baseurl": "http://your-target-api/v1",
"apikey": "your-target-api-key"
},
"optimization_model": {
"model": "your-aux-model",
"baseurl": "https://openrouter.ai/api/v1",
"apikey": "your-aux-api-key",
"max_retries": 5
},
"response_filter": {
"denylist": ["抱歉", "不能协助", "I'm sorry", "I cannot assist"]
}
}
⚠️ Never commit yourconfig.jsonwith real API keys. It is already in.gitignore.
GUI mode:
python gui_app.pyCLI mode:
# Start proxy server
python cli_app.py serve --host 127.0.0.1 --port 8999
# Or use the simple runner
python run_proxy.py --host 127.0.0.1 --port 8999Then point your client (Cursor, Continue, etc.) to http://127.0.0.1:8999/v1.
The model you ultimately want to use.
| Field | Description |
|---|---|
model |
Model name forwarded to the target backend |
message_type |
API type: responses or chat.completions |
reasoning_depth |
Reasoning effort level (e.g. high, medium, low) |
baseurl |
Target API endpoint URL (include /v1) |
apikey |
Target API key (leave empty if not needed) |
The auxiliary model used to rewrite prompts when refusal is detected.
| Field | Description |
|---|---|
model |
Auxiliary model name |
baseurl |
Auxiliary API endpoint |
apikey |
Auxiliary API key |
system_prompt |
System prompt for the rewriting model |
log_full_refined_content |
Log full rewritten prompts (true/false) |
only_main_user_request |
Only rewrite main requests, skip auxiliary ones like title generation |
max_retries |
Maximum retry attempts after refusal |
| Field | Description |
|---|---|
denylist |
List of keywords/phrases. If the model's last reply contains any, it triggers a rewrite + retry |
For better keyword matching performance, build the native Rust module:
cd rust_filter
pip install maturin
maturin develop --releaseThis provides Aho-Corasick based matching via PyO3. The proxy automatically falls back to Python if the Rust module is unavailable.
CLI executable:
.\build_exe.ps1GUI executable:
.\build_gui_exe.ps1Outputs are placed in dist/ and dist_gui/ respectively.
GptBypass/
├── proxy/
│ ├── __init__.py
│ └── main.py # Core proxy engine (FastAPI)
├── rust_filter/
│ ├── src/lib.rs # Rust Aho-Corasick filter (PyO3)
│ └── Cargo.toml
├── gui_app.py # Desktop GUI (CustomTkinter)
├── cli_app.py # CLI entry point
├── run_proxy.py # Simple proxy runner
├── app_defaults.py # Default configuration
├── config.example.json # Example config (no secrets)
├── guide.html # Usage guide (Chinese)
├── app_icon.ico # Application icon
├── ico.png # Icon PNG
├── tests/
│ ├── test_app.py # Unit & integration tests
│ └── test_client.py # Simple client test
├── build_exe.ps1 # Build CLI exe
├── build_gui_exe.ps1 # Build GUI exe
├── requirements.txt
├── LICENSE
└── README.md
The proxy exposes these HTTP endpoints:
| Method | Path | Description |
|---|---|---|
| GET/HEAD | /v1/models |
Returns a fake model list for client compatibility |
| * | /{path:path} |
Proxies everything else to the target model |
You can control bypass behavior per-request using custom headers:
| Header | Value | Effect |
|---|---|---|
x-jmp-main-request |
true |
Force treat as main request (always rewrite on refusal) |
x-jmp-aux-request |
true |
Force treat as auxiliary request (skip rewrite) |
x-jmp-skip-optimize |
true |
Skip optimization entirely |
Default log file: proxy.log (alongside the executable)
Common log patterns:
请求进入— New request received首轮直发目标模型— First attempt, sent directly命中过滤 | #1— Response matched denylist改写 | #2— Starting rewrite retry放行 | stream=True— Clean response forwarded to client
一个基于 FastAPI 的 OpenAI 兼容 API 本地代理工具,主要用于自动检测模型拒答并改写提示词重试。
- 客户端请求发往本地代理
- 首轮请求原样转发目标模型
- 代理检测模型回复是否命中拒答关键词
- 命中 → 丢弃该回复,调用辅助模型改写用户提示词后重试
- 未命中 → 正常返回给客户端
pip install -r requirements.txt
cp config.example.json config.json
# 编辑 config.json 填入你的 API 地址和密钥
python gui_app.py # 图形界面
python cli_app.py serve # 命令行target_model— 目标模型接口配置(最终请求转发目标)optimization_model— 辅助改写模型配置(拒答后用于改写提示词)response_filter.denylist— 拒答关键词列表,命中任一关键词即触发改写重试
详见
guide.html或复制config.example.json查看完整配置项。