|
1 | 1 | <div align="center"> |
2 | | - <h1>ChatMock |
3 | | - <div align="center"> |
4 | | -<a href="https://github.com/RayBytes/ChatMock/stargazers"><img src="https://img.shields.io/github/stars/RayBytes/ChatMock" alt="Stars Badge"/></a> |
5 | | -<a href="https://github.com/RayBytes/ChatMock/network/members"><img src="https://img.shields.io/github/forks/RayBytes/ChatMock" alt="Forks Badge"/></a> |
6 | | -<a href="https://github.com/RayBytes/ChatMock/pulls"><img src="https://img.shields.io/github/issues-pr/RayBytes/ChatMock" alt="Pull Requests Badge"/></a> |
7 | | -<a href="https://github.com/RayBytes/ChatMock/issues"><img src="https://img.shields.io/github/issues/RayBytes/ChatMock" alt="Issues Badge"/></a> |
8 | | -<a href="https://github.com/RayBytes/ChatMock/graphs/contributors"><img alt="GitHub contributors" src="https://img.shields.io/github/contributors/RayBytes/ChatMock?color=2b9348"></a> |
9 | | -<a href="https://github.com/RayBytes/ChatMock/blob/master/LICENSE"><img src="https://img.shields.io/github/license/RayBytes/ChatMock?color=2b9348" alt="License Badge"/></a> |
10 | | -</div> |
11 | | - </h1> |
12 | | - |
13 | | - <p><b>OpenAI & Ollama compatible API powered by your ChatGPT plan.</b></p> |
14 | | - <p>Use your ChatGPT Plus/Pro account to call OpenAI models from code or alternate chat UIs.</p> |
15 | | - <br> |
16 | | -</div> |
17 | 2 |
|
18 | | -## What It Does |
| 3 | +# ChatMock |
| 4 | + |
| 5 | +**Allows Codex to work in your favourite chat apps and coding tools.** |
| 6 | + |
| 7 | +[](https://pypi.org/project/chatmock/) |
| 8 | +[](https://pypi.org/project/chatmock/) |
| 9 | +[](LICENSE) |
| 10 | +[](https://github.com/RayBytes/ChatMock/stargazers) |
| 11 | +[](https://github.com/RayBytes/ChatMock/commits/main) |
| 12 | +[](https://github.com/RayBytes/ChatMock/issues) |
19 | 13 |
|
20 | | -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. <br> |
21 | | -This does require a paid ChatGPT account. |
| 14 | +<br> |
| 15 | + |
| 16 | + |
| 17 | +</div> |
22 | 18 |
|
23 | | -## Quickstart |
| 19 | +<br> |
24 | 20 |
|
25 | | -### Homebrew |
| 21 | +## Install |
26 | 22 |
|
| 23 | +#### Homebrew |
27 | 24 | ```bash |
28 | 25 | brew tap RayBytes/chatmock |
29 | 26 | brew install chatmock |
30 | 27 | ``` |
31 | 28 |
|
32 | | -### CLI |
33 | | - |
| 29 | +#### pipx / pip |
34 | 30 | ```bash |
35 | 31 | pipx install chatmock |
36 | 32 | ``` |
37 | 33 |
|
38 | | -### GUI |
| 34 | +#### GUI |
| 35 | +Download from [releases](https://github.com/RayBytes/ChatMock/releases) (macOS & Windows) |
39 | 36 |
|
40 | | -If you're on **macOS** or **Windows**, you can download the GUI app from the [GitHub releases](https://github.com/RayBytes/ChatMock/releases). |
| 37 | +#### Docker |
| 38 | +See [DOCKER.md](DOCKER.md) |
41 | 39 |
|
42 | | -### Python |
43 | | -If you wish to just simply run this as a python flask server, you are also freely welcome too. |
| 40 | +<br> |
44 | 41 |
|
45 | | -Clone or download this repository, then cd into the project directory. Then follow the instrunctions listed below. |
| 42 | +## Getting Started |
46 | 43 |
|
47 | | -1. Sign in with your ChatGPT account and follow the prompts |
48 | 44 | ```bash |
49 | | -python chatmock.py login |
50 | | -``` |
51 | | -You can make sure this worked by running `python chatmock.py info` |
52 | | - |
53 | | -2. After the login completes successfully, you can just simply start the local server |
| 45 | +# 1. Sign in with your ChatGPT account |
| 46 | +chatmock login |
54 | 47 |
|
55 | | -```bash |
56 | | -python chatmock.py serve |
| 48 | +# 2. Start the server |
| 49 | +chatmock serve |
57 | 50 | ``` |
58 | | -Then, you can simply use the address and port as the baseURL as you require (http://127.0.0.1:8000 by default) |
59 | | - |
60 | | -**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) |
61 | 51 |
|
62 | | -### Docker |
| 52 | +The server runs at `http://127.0.0.1:8000` by default. Use `http://127.0.0.1:8000/v1` as your base URL for OpenAI-compatible apps. |
63 | 53 |
|
64 | | -Read [the docker instrunctions here](https://github.com/RayBytes/ChatMock/blob/main/DOCKER.md) |
| 54 | +<br> |
65 | 55 |
|
66 | | -# Examples |
| 56 | +## Usage |
67 | 57 |
|
68 | | -### Python |
| 58 | +<details open> |
| 59 | +<summary><b>Python</b></summary> |
69 | 60 |
|
70 | 61 | ```python |
71 | 62 | from openai import OpenAI |
72 | 63 |
|
73 | 64 | client = OpenAI( |
74 | 65 | base_url="http://127.0.0.1:8000/v1", |
75 | | - api_key="key" # ignored |
| 66 | + api_key="anything" # not checked |
76 | 67 | ) |
77 | 68 |
|
78 | | -resp = client.chat.completions.create( |
| 69 | +response = client.chat.completions.create( |
79 | 70 | model="gpt-5.4", |
80 | | - messages=[{"role": "user", "content": "hello world"}] |
| 71 | + messages=[{"role": "user", "content": "hello"}] |
81 | 72 | ) |
82 | | - |
83 | | -print(resp.choices[0].message.content) |
| 73 | +print(response.choices[0].message.content) |
84 | 74 | ``` |
85 | 75 |
|
86 | | -### curl |
| 76 | +</details> |
| 77 | + |
| 78 | +<details> |
| 79 | +<summary><b>cURL</b></summary> |
87 | 80 |
|
88 | 81 | ```bash |
89 | 82 | curl http://127.0.0.1:8000/v1/chat/completions \ |
90 | | - -H "Authorization: Bearer key" \ |
91 | 83 | -H "Content-Type: application/json" \ |
92 | 84 | -d '{ |
93 | 85 | "model": "gpt-5.4", |
94 | | - "messages": [{"role":"user","content":"hello world"}] |
| 86 | + "messages": [{"role": "user", "content": "hello"}] |
95 | 87 | }' |
96 | 88 | ``` |
97 | 89 |
|
98 | | -# What's supported |
99 | | - |
100 | | -- Tool/Function calling |
101 | | -- Vision/Image understanding |
102 | | -- Thinking summaries (through thinking tags) |
103 | | -- Thinking effort |
| 90 | +</details> |
104 | 91 |
|
105 | | -## Notes & Limits |
| 92 | +<br> |
106 | 93 |
|
107 | | -- Requires an active, paid ChatGPT account. |
108 | | -- Some context length might be taken up by internal instructions (but they dont seem to degrade the model) |
109 | | -- Use responsibly and at your own risk. This project is not affiliated with OpenAI, and is a educational exercise. |
| 94 | +## Supported Models |
110 | 95 |
|
111 | | -# Supported models |
112 | 96 | - `gpt-5.4` |
113 | 97 | - `gpt-5.4-mini` |
114 | 98 | - `gpt-5.2` |
115 | 99 | - `gpt-5.1` |
116 | 100 | - `gpt-5` |
117 | 101 | - `gpt-5.3-codex` |
118 | | -- `gpt-5-codex` |
| 102 | +- `gpt-5.3-codex-spark` |
119 | 103 | - `gpt-5.2-codex` |
| 104 | +- `gpt-5-codex` |
120 | 105 | - `gpt-5.1-codex` |
121 | 106 | - `gpt-5.1-codex-max` |
122 | 107 | - `gpt-5.1-codex-mini` |
123 | 108 | - `codex-mini` |
124 | 109 |
|
125 | | -# Customisation / Configuration |
| 110 | +<br> |
126 | 111 |
|
127 | | -### Thinking effort |
| 112 | +## Features |
128 | 113 |
|
129 | | -- `--reasoning-effort` (choice of none,minimal,low,medium,high,xhigh)<br> |
130 | | -GPT-5 has a configurable amount of "effort" it can put into thinking, which may cause it to take more time for a response to return, but may overall give a smarter answer. Applying this parameter after `serve` forces the server to use this reasoning effort by default, unless overrided by the API request with a different effort set. The default reasoning effort without setting this parameter is `medium`.<br> |
131 | | - The `gpt-5.1` family (including codex) supports `low`, `medium`, and `high` while `gpt-5.1-codex-max` adds `xhigh`. The `gpt-5.2` and `gpt-5.3` families (including codex) support `low`, `medium`, `high`, and `xhigh`. `gpt-5.4` supports `none`, `low`, `medium`, `high`, and `xhigh`. |
| 114 | +- Tool / function calling |
| 115 | +- Vision / image input |
| 116 | +- Thinking summaries (via think tags) |
| 117 | +- Configurable thinking effort |
| 118 | +- Fast mode for supported models |
| 119 | +- Web search tool |
| 120 | +- OpenAI-compatible `/v1/responses` (HTTP + WebSocket) |
| 121 | +- Ollama-compatible endpoints |
| 122 | +- Reasoning effort exposed as separate models (optional) |
132 | 123 |
|
133 | | -### Thinking summaries |
| 124 | +<br> |
134 | 125 |
|
135 | | -- `--reasoning-summary` (choice of auto,concise,detailed,none)<br> |
136 | | -Models like GPT-5 do not return raw thinking content, but instead return thinking summaries. These can also be customised by you. |
| 126 | +## Configuration |
137 | 127 |
|
138 | | -### OpenAI Tools |
| 128 | +All flags go after `chatmock serve`. These can also be set as environment variables. |
139 | 129 |
|
140 | | -- `--enable-web-search`<br> |
141 | | -You can also access OpenAI tools through this project. Currently, only web search is available. |
142 | | -You can enable it by starting the server with this parameter, which will allow OpenAI to determine when a request requires a web search, or you can use the following parameters during a request to the API to enable web search: |
143 | | -<br><br> |
144 | | -`responses_tools`: supports `[{"type":"web_search"}]` / `{ "type": "web_search_preview" }`<br> |
145 | | -`responses_tool_choice`: `"auto"` or `"none"` |
| 130 | +| Flag | Env var | Options | Default | Description | |
| 131 | +|------|---------|---------|---------|-------------| |
| 132 | +| `--reasoning-effort` | `CHATGPT_LOCAL_REASONING_EFFORT` | none, minimal, low, medium, high, xhigh | medium | How hard the model thinks | |
| 133 | +| `--reasoning-summary` | `CHATGPT_LOCAL_REASONING_SUMMARY` | auto, concise, detailed, none | auto | Thinking summary verbosity | |
| 134 | +| `--reasoning-compat` | `CHATGPT_LOCAL_REASONING_COMPAT` | legacy, o3, think-tags | think-tags | How reasoning is returned to the client | |
| 135 | +| `--fast-mode` | `CHATGPT_LOCAL_FAST_MODE` | true/false | false | Priority processing for supported models | |
| 136 | +| `--enable-web-search` | `CHATGPT_LOCAL_ENABLE_WEB_SEARCH` | true/false | false | Allow the model to search the web | |
| 137 | +| `--expose-reasoning-models` | `CHATGPT_LOCAL_EXPOSE_REASONING_MODELS` | true/false | false | List each reasoning level as its own model | |
| 138 | + |
| 139 | +<details> |
| 140 | +<summary><b>Web search in a request</b></summary> |
146 | 141 |
|
147 | | -#### Example usage |
148 | 142 | ```json |
149 | 143 | { |
150 | 144 | "model": "gpt-5.4", |
151 | | - "messages": [{"role":"user","content":"Find current METAR rules"}], |
152 | | - "stream": true, |
| 145 | + "messages": [{"role": "user", "content": "latest news on ..."}], |
153 | 146 | "responses_tools": [{"type": "web_search"}], |
154 | 147 | "responses_tool_choice": "auto" |
155 | 148 | } |
156 | 149 | ``` |
157 | 150 |
|
158 | | -### Expose reasoning models |
| 151 | +</details> |
| 152 | + |
| 153 | +<details> |
| 154 | +<summary><b>Fast mode in a request</b></summary> |
| 155 | + |
| 156 | +```json |
| 157 | +{ |
| 158 | + "model": "gpt-5.4", |
| 159 | + "input": "summarize this", |
| 160 | + "fast_mode": true |
| 161 | +} |
| 162 | +``` |
| 163 | + |
| 164 | +</details> |
159 | 165 |
|
160 | | -- `--expose-reasoning-models`<br> |
161 | | -If your preferred app doesn’t support selecting reasoning effort, or you just want a simpler approach, this parameter exposes each reasoning level as a separate, queryable model. Each reasoning level also appears individually under /v1/models, so model pickers in your favorite chat apps will list all reasoning options as distinct models you can switch between. |
| 166 | +<br> |
162 | 167 |
|
163 | 168 | ## Notes |
164 | | -If you wish to have the fastest responses, I'd recommend setting `--reasoning-effort` to low, and `--reasoning-summary` to none. <br> |
165 | | -All parameters and choices can be seen by sending `python chatmock.py serve --h`<br> |
166 | | -The context size of this route is also larger than what you get access to in the regular ChatGPT app.<br> |
167 | 169 |
|
168 | | -When the model returns a thinking summary, the model will send back thinking tags to make it compatible with chat apps. **If you don't like this behavior, you can instead set `--reasoning-compat` to legacy, and reasoning will be set in the reasoning tag instead of being returned in the actual response text.** |
| 170 | +Use responsibly and at your own risk. This project is not affiliated with OpenAI. |
169 | 171 |
|
| 172 | +<br> |
170 | 173 |
|
171 | 174 | ## Star History |
172 | 175 |
|
|
0 commit comments