GNU General Public License v3.0

项目介绍

aledipa/Free-GPT4-WEB-API 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 GNU General Public License v3.0 许可证,目前获得 727 个 Star、146 次 Fork。

仓库全名
aledipa/Free-GPT4-WEB-API
开源许可证
GNU General Public License v3.0
Star 数
727
Fork 数
146
未关闭 Issue
2

README 摘要

Free-GPT4-WEB-API 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. Key Features Free to use - No API keys or subscriptions required Unlimited requests - No rate limiting Simple HTTP interface - Returns plain text responses Optional Web GUI - Easy…

完整内容见 GitHub 原始 README 或本页 。

常见问题

Free-GPT4-WEB-API 用什么语言开发?

主要使用 Python 编写,采用 GNU General Public License v3.0 许可证,目前有 727 个 Star。

Free-GPT4-WEB-API 可以免费商用吗?

仓库标注的许可证为 GNU General Public License v3.0,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 Free-GPT4-WEB-API 的源码?

可以直接克隆仓库:git clone https://github.com/aledipa/Free-GPT4-WEB-API.git,默认分支为 main;安装与运行步骤见仓库 README。

Free-GPT4-WEB-API 最近还在维护吗?

仓库最近一次更新为 2 天前,当前有 2 个未关闭 Issue;Star 数为 727,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Not just GPT4! Easy to use, Self-Hosted, Unlimited and Free WEB API of the latest A.I. like Gemini, DeepSeek, Claude and GPT

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

CSS
Dockerfile
HTML
JavaScript
Python

Release

README

Docker Image CI GPT4-API-PyApp Docker Pulls

Free-GPT4-WEB-API

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.

Key Features

  • Free to use - No API keys or subscriptions required
  • Unlimited requests - No rate limiting
  • Simple HTTP interface - Returns plain text responses
  • Optional Web GUI - Easy configuration through browser
  • Docker support - Ready-to-use container available
  • Smart timeout handling - Automatic retry with optimized timeouts

Note: The demo server, when available, can be overloaded and may not always respond.


Table of contents

  • Features
  • Screenshots
  • Quick start
    • Run with Docker
    • Run from source
  • Usage
    • Quick examples (browser, curl, Python)
    • File input
    • Web GUI
  • Command-line options
  • Configuration
    • Cookies
    • Proxies
    • Models and providers
    • Private mode and password
  • Siri integration
  • Requirements
  • Star history
  • Contributing
  • License

Screenshots


Quick start

Option A: Run with Docker

Pull and run with an optional cookies.json and port mapping. In Docker, setting a GUI password is recommended (and required by some setups).

  • Minimal (no cookies):
docker run -p 5500:5500 d0ckmg/free-gpt4-web-api:latest
  • With cookies (read-only mount):
docker run \
  -v /path/to/your/cookies.json:/cookies.json:ro \
  -p 5500:5500 \
  d0ckmg/free-gpt4-web-api:latest
  • Override container port mapping:
docker run -p YOUR_PORT:5500 d0ckmg/free-gpt4-web-api:latest
  • docker-compose.yml:
version: "3.9"
services:
  api:
    image: "d0ckmg/free-gpt4-web-api:latest"
    ports:
      - "YOUR_PORT:5500"
    #volumes:
    #  - /path/to/your/cookies.json:/cookies.json:ro

Note:

  • If you plan to use the Web GUI in Docker, set a password (see “Command-line options”).
  • The API listens on port 5500 in the container.

Option B: Run from source

  1. Clone the repo
git clone https://github.com/aledipa/Free-GPT4-WEB-API.git
cd Free-GPT4-WEB-API
  1. Install dependencies
pip install -r requirements.txt
  1. Start the server (basic)
python3 src/FreeGPT4_Server.py

Security Note

When using the Web GUI, always set a secure password:

python3 src/FreeGPT4_Server.py --enable-gui --password your_secure_password

Usage

The API returns plain text by default.

Examples:

curl examples

  • Simple text prompt:
curl "http://127.0.0.1:5500/?text=Explain%20quicksort%20in%20simple%20terms"
  • File input (see --file-input in options):
fileTMP="$1"
curl -s -F file=@"${fileTMP}" http://127.0.0.1:5500/

Python example

import requests

resp = requests.get("http://127.0.0.1:5500/", params={"text": "Give me a limerick"})
print(resp.text)

Web GUI

  • Start with GUI enabled:
python3 FreeGPT4_Server.py --enable-gui

From the GUI you can configure common options (e.g., model, provider, keyword, history, cookies).


Command-line options

Show help:

python3 src/FreeGPT4_Server.py [-h] [--remove-sources] [--enable-gui]
                                [--private-mode] [--enable-history] [--password PASSWORD]
                                [--cookie-file COOKIE_FILE] [--file-input] [--port PORT]
                                [--model MODEL] [--provider PROVIDER] [--keyword KEYWORD]
                                [--system-prompt SYSTEM_PROMPT] [--enable-proxies] [--enable-virtual-users]

Options:

  • -h, --help Show help and exit
  • –remove-sources Remove sources from responses
  • –enable-gui Enable graphical settings interface
  • –private-mode Require a private token to access the API
  • –enable-history Enable message history
  • –password PASSWORD Set/change the password for the settings page
    • Note: Mandatory in some Docker environments
  • –cookie-file COOKIE_FILE Use a cookie file (e.g., /cookies.json)
  • –file-input Enable file-as-input support (see curl example)
  • –port PORT HTTP port (default: 5500)
  • –model MODEL Model to use (default: gpt-4)
  • –provider PROVIDER Provider to use (default: Bing)
  • –keyword KEYWORD Change input query keyword (default: text)
  • –system-prompt SYSTEM_PROMPT System prompt to steer answers
  • –enable-proxies Use one or more proxies to reduce blocking
  • –enable-virtual-users Enable virtual users to divide requests among multiple users

Configuration

Cookies

Some providers require cookies to work properly. For the Bing model, only the “_U” cookie is needed.

  • Passing cookies via file:
    • Use --cookie-file /cookies.json when running from source
    • In Docker, mount your cookies file read-only: -v /path/to/cookies.json:/cookies.json:ro
  • The GUI also exposes cookie-related settings.

Proxies

Enable proxies to mitigate blocks:

  • Start with --enable-proxies
  • Ensure your environment is configured for aiohttp/aiohttp_socks if you need SOCKS/HTTP proxies.

Models and providers

  • Models: gpt-4, gpt-4o, deepseek-r1, and other modern LLMs
  • Default model: gpt-4
  • Default provider: DuckDuckGo (reliable fallback)
  • Provider Fallback: Automatic switching between Bing, DuckDuckGo, and other providers
  • Health Monitoring: Real-time provider status tracking

Change via flags or in the GUI:

--model gpt-4o --provider Bing

Reliability Features

  • Smart Timeout Handling: Optimized 30-second timeouts with automatic retry
  • Provider Fallback: Automatic switching when primary provider fails
  • Health Monitoring: Continuous provider status tracking
  • Blacklist System: Automatic exclusion of problematic providers

Private mode and password

  • --private-mode requires a private token to access the API
  • --password protects the settings page (mandatory in Docker setups)
  • Security Enhancement: Authentication system hardened against bypass attacks
  • Logging: All authentication attempts are logged for security monitoring
  • Use a strong password if you expose the API beyond localhost

Important: Always set a password when using the Web GUI to prevent unauthorized access.


Siri integration

Use the GPTMode Apple Shortcut to ask your self-hosted API via Siri.

Shortcut:

Say “GPT Mode” to Siri and ask your question when prompted.


Requirements

For development and testing:

  • pytest
  • pytest-asyncio

Troubleshooting

Common Issues

  1. Timeout Errors: The system now automatically retries with fallback providers
  2. Provider Blocks: Health monitoring automatically switches to working providers
  3. Authentication Issues: Ensure you set a strong password and check logs for failed attempts
  4. Docker Permission Issues: Use read-only mounts for sensitive files like cookies.json

Getting Help

If you encounter issues:

  1. Check the application logs for detailed error information
  2. Verify your provider configuration in the Web GUI
  3. Ensure cookies are properly formatted (if using)
  4. Try different providers through the fallback system

Star history

Star History Chart


Contributing

Contributions are welcome! Feel free to open issues and pull requests to improve features, docs, or reliability.


License

GNU General Public License v3.0

See LICENSE for details.

评论

暂无评论