gpt4free README

The project's README from github.com/xtekky/gpt4free. As one markdown file: README.md.

GPT4Free (g4f)

PyPI Docker Hub License: GPL v3 PyPI Downloads GitHub Repo stars

Community Day 2026

Created by @xtekky,
maintained by @hlohaus

Support the project on GitHub Sponsors ❤️

Live demo & docs: https://g4f.dev | Documentation: https://g4f.dev/docs


GPT4Free (g4f) is a community-driven project that aggregates multiple accessible providers and interfaces to make working with modern LLMs and media-generation models easier and more flexible. GPT4Free aims to offer multi-provider support, local GUI, OpenAI-compatible REST APIs, and convenient Python and JavaScript clients — all under a community-first license.

This README is a consolidated, improved, and complete guide to installing, running, and contributing to GPT4Free.

Table of contents


What’s included



Requirements & compatibility


Installation

  1. Install Docker: https://docs.docker.com/get-docker/
  2. Create persistent directories:
    • Example (Linux/macOS):
      mkdir -p ${PWD}/har_and_cookies ${PWD}/generated_media
      sudo chown -R 1200:1201 ${PWD}/har_and_cookies ${PWD}/generated_media
      
  3. Pull image:
    docker pull hlohaus789/g4f
    
  4. Run container:
    docker run -p 8080:8080 -p 7900:7900 \
      --shm-size="2g" \
      -v ${PWD}/har_and_cookies:/app/har_and_cookies \
      -v ${PWD}/generated_media:/app/generated_media \
      hlohaus789/g4f:latest
    

Notes:

Slim Docker image (x64 & arm64)

mkdir -p ${PWD}/har_and_cookies ${PWD}/generated_media
chown -R 1000:1000 ${PWD}/har_and_cookies ${PWD}/generated_media

docker run \
  -p 1337:8080 -p 8080:8080 \
  -v ${PWD}/har_and_cookies:/app/har_and_cookies \
  -v ${PWD}/generated_media:/app/generated_media \
  hlohaus789/g4f:latest-slim

Notes:

Windows Guide (.exe)

👉 Check out the Windows launcher for GPT4Free:
🔗 https://github.com/gpt4free/g4f.exe 🚀

  1. Download the release artifact g4f.exe.zip from: https://github.com/xtekky/gpt4free/releases/latest
  2. Unzip and run g4f.exe.
  3. Open GUI at: http://localhost:8080/chat/
  4. If Windows Firewall blocks access, allow the application.

Python Installation (pip / from source / partial installs)

Prerequisites:

Install from PyPI (recommended):

pip install -U g4f[all]

Partial installs

Install from source:

git clone https://github.com/xtekky/gpt4free.git
cd gpt4free
pip install -r requirements.txt
pip install -e .

Notes:


Running the app

GUI (web client)

from g4f.gui import run_gui
run_gui()
python -m g4f.cli gui --port 8080 --debug

FastAPI / Interference API

python -m g4f --port 8080 --debug

CLI

python -m g4f.cli gui --port 8080 --debug

MCP Server

GPT4Free now includes a Model Context Protocol (MCP) server that allows AI assistants like Claude to access web search, scraping, and image generation capabilities.

Starting the MCP server (stdio mode):

# Using g4f command
g4f mcp

# Or using Python module
python -m g4f.mcp

Starting the MCP server (HTTP mode):

# Start HTTP server on port 8765
g4f mcp --http --port 8765

# Custom host and port
g4f mcp --http --host 127.0.0.1 --port 3000

HTTP mode provides:

Configuring with Claude Desktop:

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "gpt4free": {
      "command": "python",
      "args": ["-m", "g4f.mcp"]
    }
  }
}

Available MCP Tools:

For detailed MCP documentation, see g4f/mcp/README.md

Optional provider login (desktop within container)


Using the Python client

Install:

pip install -U g4f[all]

Synchronous text example:

from g4f.client import Client

client = Client()
response = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Hello, how are you?"}],
    web_search=False
)
print(response.choices[0].message.content)

Expected:

Hello! How can I assist you today?

Image generation example:

from g4f.client import Client

client = Client()
response = client.images.generate(
    model="flux",
    prompt="a white siamese cat",
    response_format="url"
)
print(f"Generated image URL: {response.data[0].url}")

Async client example:

from g4f.client import AsyncClient
import asyncio

async def main():
    client = AsyncClient()
    response = await client.chat.completions.create(
        model="auto",
        messages=[{"role": "user", "content": "Explain quantum computing briefly"}],
    )
    print(response.choices[0].message.content)

asyncio.run(main())

Notes:


Using GPT4Free.js (browser JS client)

Use the official JS client in the browser—no backend required.

Example:

<script type="module">
  import Client from 'https://g4f.dev/dist/js/client.js';

  const client = new Client();
  const result = await client.chat.completions.create({
      model: 'auto',  // Or "glm-5.3", "kimi-k3", etc.
      messages: [{ role: 'user', content: 'Explain quantum computing' }]
  });
  console.log(result.choices[0].message.content);
</script>

Notes:


Providers & models (overview)

Provider requirements may include:


Local inference & media


Configuration & customization


Running on smartphone


Interference API (OpenAI‑compatible)


Examples & common patterns


Contributing

Contributions are welcome — new providers, features, docs, and fixes are appreciated.

How to contribute:

  1. Fork the repository.
  2. Create a branch for your change.
  3. Run tests and linters.
  4. Open a Pull Request with a clear description and tests/examples if applicable.

Repository: https://github.com/xtekky/gpt4free

How to create a new provider

How AI can help you write code


Security, privacy & takedown policy


Credits, contributors & attribution

Many more contributors are acknowledged in the repository.


Powered-by highlights


Changelog & releases


Manifesto / Project principles

GPT4Free is guided by community principles:

  1. Open access to AI tooling and models.
  2. Collaboration across providers and projects.
  3. Opposition to monopolistic, closed systems that restrict creativity.
  4. Community-centered development and broad access to AI technologies.
  5. Promote innovation, creativity, and accessibility.

https://g4f.dev/manifesto


License

This program is licensed under the GNU General Public License v3.0 (GPLv3). See the full license: https://www.gnu.org/licenses/gpl-3.0.txt

Summary:

Copyright notice

xtekky/gpt4free: Copyright (C) 2025 xtekky

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

Contact & sponsorship


Appendix: Quick commands & examples

Install (pip):

pip install -U g4f[all]

Run GUI (Python):

python -m g4f.cli gui --port 8080 --debug
# or
python -c "from g4f.gui import run_gui; run_gui()"

Docker (full):

docker pull hlohaus789/g4f
docker run -p 8080:8080 -p 7900:7900 \
  --shm-size="2g" \
  -v ${PWD}/har_and_cookies:/app/har_and_cookies \
  -v ${PWD}/generated_media:/app/generated_media \
  hlohaus789/g4f:latest

Docker (slim):

docker run -p 1337:8080 -p 8080:8080 \
  -v ${PWD}/har_and_cookies:/app/har_and_cookies \
  -v ${PWD}/generated_media:/app/generated_media \
  hlohaus789/g4f:latest-slim

Python usage patterns:

Docs & deeper reading


Thank you for using and contributing to GPT4Free — together we make powerful AI tooling accessible, flexible, and community-driven.

gpt4free (xtekky/gpt4free)

Searching Database…

66.9K ·GitHub
Что это такое?GPT4Free (g4f) — проект, который развивает сообщество. Он объединяет множество бесплатных способов доступа к коммерческим LLM (GPT-4, Claude, Gemini, DeepSeek и др.) и моделям генерации медиа, полученным методом реверс-инжиниринга, и предоставляет их через единый клиент для Python и JS, веб-интерфейс и API, совместимый с OpenAI.
Это библиотека на Python, готовое приложение или и то, и другое?И то, и другое: проект распространяется как устанавливаемая клиентская библиотека для Python, а также запускается как самостоятельно размещаемое приложение с веб-интерфейсом и сервером на FastAPI, совместимым с OpenAI («Interference API»).
Как это запустить?Проще всего через Docker: скачайте образ g4f и запустите контейнер, который отдаёт веб-интерфейс и API на порту 8080. Также можно установить Python-пакет из PyPI, запустить проект из исходников или скачать лаунчер g4f.exe для Windows.
Что нужно установить заранее?Рекомендуется Python 3.10+. Для провайдеров, которые работают через автоматизацию браузера, нужен Chrome или Chromium. Docker — вариант, если не хочется настраивать Python на своём компьютере.
Провайдеры работают сразу после установки?Не всегда. Многие провайдеры — это бесплатный доступ к платным сервисам, полученный методом реверс-инжиниринга, поэтому некоторым нужны API-ключи или cookie-файлы браузера либо HAR-файлы. Их получают, входя в аккаунт на сайте провайдера через рабочий стол, встроенный в контейнер.
Безопасно ли подключать к этому свои аккаунты провайдеров?Проект предупреждает, что нужно следовать мерам безопасности, принятым для каждого провайдера, и не хранить и не передавать конфиденциальные учётные данные. Данные cookie и HAR хранятся в локальных смонтированных директориях и не отправляются мейнтейнерам.
Для чего нужен MCP-сервер?GPT4Free включает сервер Model Context Protocol, чтобы ИИ-ассистенты, например Claude Desktop, могли напрямую вызывать его инструменты веб-поиска, веб-скрапинга и генерации изображений.
Можно ли использовать GPT4Free в браузере без бэкенда?Да, есть официальный клиент GPT4Free.js, который распространяется через CDN и работает полностью в браузере, без настройки сервера.
Что такое 'Interference API'?Это совместимая с OpenAI конечная точка на основе FastAPI. Она позволяет направлять запросы чата и завершения через выбор провайдеров GPT4Free так же, как с официальным API OpenAI.
Может ли он генерировать только текст или также изображения?Помимо текстовых чат-запросов, он также поддерживает генерацию изображений, аудио и видео через медиа-провайдеров, например Pollinations.
Creator
xtekky
Size
234.7 MB
Stars
66.9K
Age
3y
Commits · 90 Days