|
1 | | - |
2 | 1 | <img src="./img/FreeGPT4_Banner(Nicoladipa).png" style="width:100%; max-width:500px; min-width:200px; aspect-ratio: 5/2"/> |
3 | 2 |
|
4 | 3 | [](https://github.com/aledipa/Free-GPT4-WEB-API/actions/workflows/docker-image.yml) |
5 | 4 | [](https://github.com/aledipa/Free-GPT4-WEB-API/actions/workflows/python-app.yml) |
6 | 5 |  |
7 | 6 |
|
8 | | -<!-- <img src="https://status.freegpt4.ddns.net/getstatus" width="256" height="40" /> --> |
9 | | - |
10 | 7 | # Free-GPT4-WEB-API |
11 | 8 |
|
12 | | -FreeGPT4-WEB-API is a python server that allows you to have a self-hosted GPT-4 Unlimited and Free WEB API, via the latest AI providers. |
| 9 | +Self-hosted web API that exposes free, unlimited access to modern LLM providers through a single, simple HTTP interface. It includes an optional web GUI for configuration and supports running via Python or Docker. |
| 10 | + |
| 11 | +- Free to use |
| 12 | +- Unlimited requests |
| 13 | +- Simple HTTP interface (returns plain text) |
| 14 | +- Optional Web GUI |
| 15 | +- Docker image available |
| 16 | + |
| 17 | +Note: The demo server, when available, can be overloaded and may not always respond. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Table of contents |
| 22 | + |
| 23 | +- Features |
| 24 | +- Screenshots |
| 25 | +- Quick start |
| 26 | + - Run with Docker |
| 27 | + - Run from source |
| 28 | +- Usage |
| 29 | + - Quick examples (browser, curl, Python) |
| 30 | + - File input |
| 31 | + - Web GUI |
| 32 | +- Command-line options |
| 33 | +- Configuration |
| 34 | + - Cookies |
| 35 | + - Proxies |
| 36 | + - Models and providers |
| 37 | + - Private mode and password |
| 38 | +- Siri integration |
| 39 | +- Requirements |
| 40 | +- Star history |
| 41 | +- Contributing |
| 42 | +- License |
| 43 | + |
| 44 | +--- |
13 | 45 |
|
14 | 46 | ## Features |
| 47 | + |
15 | 48 | - Self-hosted DeepSeek-R1 and GPT-4o API |
16 | 49 | - Unlimited usage |
17 | 50 | - Free of cost |
18 | 51 | - User-friendly GUI |
19 | 52 |
|
| 53 | +## Screenshots |
20 | 54 |
|
21 | | -## GUI Preview: |
22 | | - |
23 | | -<!-- round angles images --> |
24 | 55 | <img src="./img/login.png" style="width:100%; max-width:500px; min-width:200px; aspect-ratio: 4/3" /> |
25 | 56 | <img src="./img/settings.png" style="width:100%; max-width:500px; min-width:200px; aspect-ratio: 4/3" /> |
| 57 | +<img src="./img/profile.png" style="width:100%; max-width:500px; min-width:200px; aspect-ratio: 4/3" /> |
26 | 58 |
|
27 | | -## Installation |
28 | | -1. Clone the repository: `git clone https://github.com/aledipa/Free-GPT4-WEB-API.git` |
29 | | -2. Navigate to the project directory: `cd Free-GPT4-WEB-API` |
30 | | -3. Install the required packages: `pip install -r requirements.txt` |
| 59 | +--- |
31 | 60 |
|
32 | | -## Requirements |
| 61 | +## Quick start |
33 | 62 |
|
34 | | -- Python 3 |
35 | | -- Flask[async] |
36 | | -- g4f (from [here](https://github.com/xtekky/gpt4free)). |
37 | | -- aiohttp |
38 | | -- aiohttp_socks |
39 | | -- auth |
40 | | -- Werkzeug |
| 63 | +### Option A: Run with Docker |
41 | 64 |
|
42 | | -## Usage |
| 65 | +Pull and run with an optional cookies.json and port mapping. In Docker, setting a GUI password is recommended (and required by some setups). |
43 | 66 |
|
44 | | -_Note: It is recommended to [use the GUI](#to-use-the-web-gui)._ |
| 67 | +- Minimal (no cookies): |
| 68 | +``` |
| 69 | +docker run -p 5500:5500 d0ckmg/free-gpt4-web-api:latest |
| 70 | +``` |
45 | 71 |
|
46 | | -### Run the server |
47 | | -Use the following command: |
48 | | -```shell |
49 | | -python3 FreeGPT4_Server.py [-h] [--remove-sources] [--enable-gui] |
50 | | - [--private-mode] [--enable-history] [--password PASSWORD] |
51 | | - [--cookie-file COOKIE_FILE] [--file-input] [--port PORT] |
52 | | - [--model MODEL] [--provider PROVIDER] [--keyword KEYWORD] |
53 | | - [--system-prompt SYSTEM_PROMPT] [--enable-proxies] |
| 72 | +- With cookies (read-only mount): |
| 73 | +``` |
| 74 | +docker run \ |
| 75 | + -v /path/to/your/cookies.json:/cookies.json:ro \ |
| 76 | + -p 5500:5500 \ |
| 77 | + d0ckmg/free-gpt4-web-api:latest |
54 | 78 | ``` |
55 | 79 |
|
| 80 | +- Override container port mapping: |
| 81 | +``` |
| 82 | +docker run -p YOUR_PORT:5500 d0ckmg/free-gpt4-web-api:latest |
| 83 | +``` |
56 | 84 |
|
57 | | -Options: |
| 85 | +- docker-compose.yml: |
| 86 | +```yaml |
| 87 | +version: "3.9" |
| 88 | +services: |
| 89 | + api: |
| 90 | + image: "d0ckmg/free-gpt4-web-api:latest" |
| 91 | + ports: |
| 92 | + - "YOUR_PORT:5500" |
| 93 | + #volumes: |
| 94 | + # - /path/to/your/cookies.json:/cookies.json:ro |
| 95 | +``` |
| 96 | + |
| 97 | +Note: |
| 98 | +- If you plan to use the Web GUI in Docker, set a password (see “Command-line options”). |
| 99 | +- The API listens on port 5500 in the container. |
| 100 | + |
| 101 | +### Option B: Run from source |
| 102 | + |
| 103 | +1. Clone the repo |
| 104 | +``` |
| 105 | +git clone https://github.com/aledipa/Free-GPT4-WEB-API.git |
| 106 | +cd Free-GPT4-WEB-API |
| 107 | +``` |
| 108 | + |
| 109 | +2. Install dependencies |
| 110 | +``` |
| 111 | +pip install -r requirements.txt |
| 112 | +``` |
58 | 113 |
|
59 | | - `-h, --help` show this help message and exit |
60 | | - |
61 | | - `--remove-sources` Remove the sources from the response |
62 | | - |
63 | | - `--enable-gui` Use a graphical interface for settings |
64 | | - |
65 | | - `--private-mode` Use a private token to access the API |
66 | | - |
67 | | - `--enable-history` Enable the history of the messages |
68 | | - |
69 | | - `--password PASSWORD` Set or change the password for the settings page [mandatory in docker envirtonment] |
70 | | - |
71 | | - `--cookie-file COOKIE_FILE` |
72 | | - Use a cookie file |
73 | | - |
74 | | - `--file-input` Add the file as input support |
75 | | - |
76 | | - `--port PORT` Change the port (default: 5500) |
77 | | - |
78 | | - `--model MODEL` Change the model (default: gpt-4) |
79 | | - |
80 | | - `--provider PROVIDER` Change the provider (default: Bing) |
81 | | - |
82 | | - `--keyword KEYWORD` Add the keyword support |
83 | | - |
84 | | - `--system-prompt SYSTEM_PROMPT` |
85 | | - Use a system prompt to 'customize' the answers |
86 | | - |
87 | | - `--enable-proxies` |
88 | | - Use one or more proxies to avoid being blocked or banned |
89 | | - |
90 | | -### Make questions |
91 | | -Once the server is up and running, make sure that you're able to reach its address and type `?text=` followed by your question next to it. |
92 | | -You can replace ‘text’ with whatever you wish, either by using the `--keyword` flag or by changing the value of the ‘Input Keyword’ field on the Web GUI. |
93 | | - |
94 | | -### Use the Web GUI |
95 | | -Once you've enabled it by running the server with the `--enable-gui` flag, just type `/settings` or `/login` next to the server's url |
96 | | - |
97 | | -### Use it with Curl |
98 | | -(credits to [@ayoubelmhamdi](https://github.com/ayoubelmhamdi)): |
99 | | - |
100 | | -```shell |
| 114 | +3. Start the server (basic) |
| 115 | +``` |
| 116 | +python3 FreeGPT4_Server.py |
| 117 | +``` |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +## Usage |
| 122 | + |
| 123 | +The API returns plain text by default. |
| 124 | + |
| 125 | +- Quick browser test: |
| 126 | + - Start the server |
| 127 | + - Open: http://127.0.0.1:5500/?text=Hello |
| 128 | + |
| 129 | +Examples: |
| 130 | +- GET http://127.0.0.1:5500/?text=Write%20a%20haiku |
| 131 | +- If you changed the keyword parameter (see `--keyword`), replace `text` with your chosen keyword. |
| 132 | + |
| 133 | +### curl examples |
| 134 | + |
| 135 | +- Simple text prompt: |
| 136 | +``` |
| 137 | +curl "http://127.0.0.1:5500/?text=Explain%20quicksort%20in%20simple%20terms" |
| 138 | +``` |
| 139 | + |
| 140 | +- File input (see `--file-input` in options): |
| 141 | +``` |
101 | 142 | fileTMP="$1" |
102 | 143 | curl -s -F file=@"${fileTMP}" http://127.0.0.1:5500/ |
103 | 144 | ``` |
104 | 145 |
|
| 146 | +### Python example |
105 | 147 |
|
106 | | -## Docker Installation |
107 | | -<img src="./img/docker-logo.webp" width="400" height="100" /> |
| 148 | +```python |
| 149 | +import requests |
108 | 150 |
|
109 | | -It's possible to install the docker image of this API by running this command: |
| 151 | +resp = requests.get("http://127.0.0.1:5500/", params={"text": "Give me a limerick"}) |
| 152 | +print(resp.text) |
| 153 | +``` |
110 | 154 |
|
111 | | -`docker container run -v /path/to/your/cookies.json:/cookies.json:ro -p YOUR_PORT:5500 d0ckmg/free-gpt4-web-api` |
| 155 | +### Web GUI |
112 | 156 |
|
113 | | -just omit <code>-v /path/to/your/cookies.json:/cookies.json:ro</code> for using it without cookies |
| 157 | +- Start with GUI enabled: |
| 158 | +``` |
| 159 | +python3 FreeGPT4_Server.py --enable-gui |
| 160 | +``` |
114 | 161 |
|
115 | | -or alternatively, you can use a docker-compose file: |
| 162 | +- Open settings or login: |
| 163 | + - http://127.0.0.1:5500/settings |
| 164 | + - http://127.0.0.1:5500/login |
116 | 165 |
|
117 | | -**docker-compose.yml** |
| 166 | +From the GUI you can configure common options (e.g., model, provider, keyword, history, cookies). |
118 | 167 |
|
119 | | -```yaml |
120 | | -version: "3.9" |
121 | | -services: |
122 | | - api: |
123 | | - image: "d0ckmg/free-gpt4-web-api:latest" |
124 | | - ports: |
125 | | - - "YOUR_PORT:5500" |
126 | | - #volumes: |
127 | | - # - /path/to/your/cookies.json:/cookies.json:ro |
| 168 | +--- |
| 169 | + |
| 170 | +## Command-line options |
| 171 | + |
| 172 | +Show help: |
| 173 | +``` |
| 174 | +python3 FreeGPT4_Server.py [-h] [--remove-sources] [--enable-gui] |
| 175 | + [--private-mode] [--enable-history] [--password PASSWORD] |
| 176 | + [--cookie-file COOKIE_FILE] [--file-input] [--port PORT] |
| 177 | + [--model MODEL] [--provider PROVIDER] [--keyword KEYWORD] |
| 178 | + [--system-prompt SYSTEM_PROMPT] [--enable-proxies] [--enable-virtual-users] |
128 | 179 | ``` |
129 | 180 |
|
130 | | -This will start the server and allow you to access the GPT-4 WEB API. |
| 181 | +Options: |
| 182 | +- -h, --help Show help and exit |
| 183 | +- --remove-sources Remove sources from responses |
| 184 | +- --enable-gui Enable graphical settings interface |
| 185 | +- --private-mode Require a private token to access the API |
| 186 | +- --enable-history Enable message history |
| 187 | +- --password PASSWORD Set/change the password for the settings page |
| 188 | + - Note: Mandatory in some Docker environments |
| 189 | +- --cookie-file COOKIE_FILE Use a cookie file (e.g., /cookies.json) |
| 190 | +- --file-input Enable file-as-input support (see curl example) |
| 191 | +- --port PORT HTTP port (default: 5500) |
| 192 | +- --model MODEL Model to use (default: gpt-4) |
| 193 | +- --provider PROVIDER Provider to use (default: Bing) |
| 194 | +- --keyword KEYWORD Change input query keyword (default: text) |
| 195 | +- --system-prompt SYSTEM_PROMPT |
| 196 | + System prompt to steer answers |
| 197 | +- --enable-proxies Use one or more proxies to reduce blocking |
| 198 | +- --enable-virtual-users |
| 199 | + Enable virtual users to divide requests among multiple users |
| 200 | + |
| 201 | +--- |
| 202 | + |
| 203 | +## Configuration |
| 204 | + |
| 205 | +### Cookies |
131 | 206 |
|
132 | | -Once the server is running, you can access the API by sending HTTP requests to the server's address. The data for the requests should be sent via hotlinking and the response will be returned as plain text. |
| 207 | +Some providers require cookies to work properly. For the Bing model, only the “_U” cookie is needed. |
133 | 208 |
|
134 | | -For example, to generate text using the API, you can send a GET request with the `text` parameter set to the text you want to use as a prompt and the (optional) `style` parameter set to the style you want to use. The default style is "balanced" and is recommended since it is faster. The generated text will be returned in the response as plain text. |
| 209 | +- Passing cookies via file: |
| 210 | + - Use `--cookie-file /cookies.json` when running from source |
| 211 | + - In Docker, mount your cookies file read-only: `-v /path/to/cookies.json:/cookies.json:ro` |
| 212 | +- The GUI also exposes cookie-related settings. |
135 | 213 |
|
136 | | -To stop the server, you can press `CTRL+C` in the terminal where the server is running. |
137 | | -(credits to [@git-malik](https://github.com/git-malik)) |
| 214 | +### Proxies |
| 215 | + |
| 216 | +Enable proxies to mitigate blocks: |
| 217 | +- Start with `--enable-proxies` |
| 218 | +- Ensure your environment is configured for aiohttp/aiohttp_socks if you need SOCKS/HTTP proxies. |
| 219 | + |
| 220 | +### Models and providers |
| 221 | + |
| 222 | +- Models: includes gpt-4 (and variants such as GPT-4o) and DeepSeek-R1 |
| 223 | +- Default model: `gpt-4` |
| 224 | +- Default provider: `Bing` |
| 225 | +- Change via flags or in the GUI: |
| 226 | +``` |
| 227 | +--model gpt-4o --provider Bing |
| 228 | +``` |
| 229 | + |
| 230 | +### Private mode and password |
| 231 | + |
| 232 | +- `--private-mode` requires a private token to access the API |
| 233 | +- `--password` protects the settings page (mandatory in some Docker setups) |
| 234 | +- Use a strong password if you expose the API beyond localhost |
| 235 | + |
| 236 | +--- |
| 237 | + |
| 238 | +## Siri integration |
138 | 239 |
|
139 | | -## Siri Integration |
140 | 240 | <img src="./img/GPTMode_Logo.png" width="400" height="133" /> |
141 | 241 |
|
142 | | -You can implement the power of GPT4 in Siri by using the [GPTMode Apple Shortcut](https://www.icloud.com/shortcuts/bfeed30555854958bd6165fa4d82e21b). |
143 | | -Then you can use it just by saying "GPT Mode" to Siri and then ask your question when prompted to do so. |
| 242 | +Use the GPTMode Apple Shortcut to ask your self-hosted API via Siri. |
144 | 243 |
|
145 | | -## Configuration |
| 244 | +Shortcut: |
| 245 | +- https://www.icloud.com/shortcuts/bfeed30555854958bd6165fa4d82e21b |
| 246 | + |
| 247 | +Say “GPT Mode” to Siri and ask your question when prompted. |
146 | 248 |
|
147 | | -The server can be configured by using the GUI or the corresponding parameters. The only cookie needed for the Bing model is _"_U"_. |
| 249 | +--- |
148 | 250 |
|
149 | | -## Star History |
| 251 | +## Requirements |
| 252 | + |
| 253 | +- Python 3 |
| 254 | +- Flask[async] |
| 255 | +- g4f (from https://github.com/xtekky/gpt4free) |
| 256 | +- aiohttp |
| 257 | +- aiohttp_socks |
| 258 | +- auth |
| 259 | +- Werkzeug |
| 260 | + |
| 261 | +--- |
| 262 | + |
| 263 | +## Star history |
150 | 264 |
|
151 | 265 | [](https://star-history.com/#aledipa/Free-GPT4-WEB-API&Date) |
152 | 266 |
|
153 | | -## Notes |
| 267 | +--- |
| 268 | + |
| 269 | +## Contributing |
| 270 | + |
| 271 | +Contributions are welcome! Feel free to open issues and pull requests to improve features, docs, or reliability. |
| 272 | + |
| 273 | +Credits: |
| 274 | +- Some examples and tips credited to community members, including @git-malik and @ayoubelmhamdi. |
| 275 | + |
| 276 | +--- |
| 277 | + |
| 278 | +## License |
154 | 279 |
|
155 | | -- The demo server may be overloaded and not always work as expected. (Check the "Demo Server Status" above) |
156 | | -- Any kind of contribution to the repository is welcome. |
| 280 | +GNU General Public License v3.0 |
157 | 281 |
|
158 | | -## Todo ✔️ |
159 | | -- [x] Fix Demo Server |
160 | | -- [x] Update README |
| 282 | +See LICENSE for details. |
0 commit comments