# ChatGPT2API-Pro Session — 2026-07-04 ## Session Goal Fork `lanqian528/chat2api`, add function calling + MCP + GPT-5.5 support, deploy on Windows with Hermes, connect K12 ChatGPT account. ## Key Decisions - **Forked** `lanqian528/chat2api` (3.7k⭐) → `nikita4a/chatgpt2api-pro` (ChatGPT-specific, not multi-provider) - **Function calling**: prompt engineering (inject tool JSON into system prompt, parse JSON from response) - **MCP**: JSON-RPC 2.0 endpoint at `/mcp` with `initialize`, `tools/list`, `tools/call` - **Model mapping**: Added GPT-5.5 and GPT-5 to `set_model()` - **Conversation tracking**: Added `conversation_id` capture in non-stream responses ## Account Details - **First account**: [REDACTED-NAME]@gmail.com, planType=`free` → GPT-3.5 + GPT-4o work - **Second account**: [REDACTED-NAME]@gmail.com, planType=`k12`, structure=`workspace` → GPT-4o + O3-mini + GPT-5.5 work. O1 blocked by anti-abuse. ## Deployment Path ``` C:\Users\User\AppData\Local\hermes\chatgpt2api-pro\ ├── .venv/ # isolated Python venv ├── tokens.txt # K12 access token (gitignored) ├── api/ │ ├── function_calling.py # NEW: prompt-eng tool use │ ├── mcp.py # NEW: JSON-RPC 2.0 gateway │ └── chat2api.py # MODIFIED: FC flow, conv tracking ├── chatgpt/ │ └── ChatService.py # MODIFIED: GPT-5.5 mapping, thinking mode └── app.py # MODIFIED: MCP registration ``` ## Errors & Fixes ### Error 1: `ModuleNotFoundError: No module named 'utils.configs'` - **Cause**: Hermes has `C:\Users\User\AppData\Local\hermes\hermes-agent\utils\` in sys.path, shadows project `utils/` - **Fix**: Added `__init__.py` to `utils/`, `chatgpt/`, `api/`. Run with `PYTHONPATH=;$PYTHONPATH`. ### Error 2: `Proof of work difficulty too high: 061a80` - **Cause**: `pow_difficulty` is read as string from `.env`. String comparison `"061a80" <= "000032"` fails. - **Fix**: Set `POW_DIFFICULTY=0` in `.env` to disable check. ### Error 3: `[Errno 10048] port 5005 already in use` - **Cause**: Old server processes from previous background launches linger. - **Fix**: `netstat -ano | grep :5005` → `taskkill //F //PID `. ### Error 4: tokens.txt pushed to GitHub - **Cause**: `tokens.txt` not in `.gitignore`. - **Fix**: Added to `.gitignore`, `git rm --cached`, force push. ### Error 5: O1 returns "unusual activity detected" - **Cause**: ChatGPT anti-abuse on O1 model via web API. - **Status**: Unresolved. O3-mini works fine. Arkose solver needed. ### Error 6: `ua_generator` not found - **Cause**: Running with system Python that has Hermes packages but not project deps. - **Fix**: Use `.venv/Scripts/python` instead of system `python`. ## Token Extraction - **Hermes Bridge**: extension at `localhost:8002` — captures cookies/tokens from browser - **Direct URL**: `cmd //c start https://chatgpt.com/api/auth/session` → user copies `accessToken` - **Comet cookies**: `%LOCALAPPDATA%\Perplexity\Comet\User Data\Default\Network\Cookies` (SQLite, locked while Comet runs) ## Verified Models | Model | Status | Note | |-------|--------|------| | gpt-3.5-turbo | ✅ | Free + K12 | | gpt-4o | ✅ | Free + K12 | | o3-mini | ✅ | K12 only | | gpt-5.5 | ✅ | K12, thinking auto-enabled | | o1 | ❌ | Anti-abuse block | ## GPT-5.5 Thinking Investigation (2026-07-04) **Problem**: GPT-5.5 отвечала, но `reasoning_content` был пустым. Пользователь сказал "Thinking там в настройках включается у него". **Fix**: Добавлено авто-включение `thinking: True` и `reasoning_effort: medium` для reasoning-моделей в `ChatService.set_model()`: ```python if "gpt-5.5" in self.origin_model: self.req_model = "gpt-5.5" self.data["thinking"] = True if "reasoning_effort" not in self.data: self.data["reasoning_effort"] = "medium" ``` **Результат**: `thinking: True` отправляется в запросе к ChatGPT backend. Но API-ответ НЕ СОДЕРЖИТ reasoning/thinking. Никакого `reasoning_content` в metadata, `message_type` всегда `next`, `content_type` всегда `text`. **Вывод**: Thinking — UI-фича ChatGPT веб-интерфейса. Через backend API `/conversation` thinking не возвращается. Параметр `thinking: True` в запросе влияет только на отображение в вебе, не на API-ответ. **Отладка**: Добавлялся debug-лог `logger.info(f"DEBUG_RAW: status={status} ctype={content.get('content_type')} meta_keys={list(meta_data.keys())}")` в `chatFormat.py` → `stream_response()`. Показал: в metadata нет ключей reasoning/thinking, только `message_type: next`. ## GitHub - **Repo**: https://github.com/nikita4a/chatgpt2api-pro - **Commits**: 5 commits (initial fork + FC/MCP + GPT-5.5 + conv tracking + token cleanup)