xtekky/gpt4free
The official gpt4free repository | various collection of powerful language models | opus 4.6 gpt 5.3 kimi 2.5 deepseek v3.2 gemini 3
GPT4Free (g4f) – Community‑driven multi‑provider LLM toolkit
What it is – A Python package (also available as Docker images and a small web GUI) that lets you call a wide range of large‑language‑model and media‑generation services through a single, OpenAI‑compatible interface. It aggregates public APIs, browser‑automated providers, and local inference back‑ends, exposing them via:
- a Python client (
g4f.client/g4f.AsyncClient) - a browser‑side JavaScript client (
g4f.devCDN) - an optional FastAPI “Interference” server that mimics the OpenAI REST API
- a local web GUI for chatting and media generation
- an MCP server that lets other assistants (e.g., Claude) invoke web search, scraping, or image generation.
Key components
| Component | Purpose |
|---|---|
| Python library | Client/AsyncClient provide chat.completions.create and images.generate methods that automatically pick a provider (model="auto") or let you specify one (e.g., flux, glm-5.3). |
| Web GUI | Simple chat UI reachable at http://localhost:8080/chat/. Can be started with run_gui() or via the CLI. |
| FastAPI Interference API | Exposes an OpenAI‑compatible /v1 endpoint, useful for existing tooling that expects OpenAI. Swagger UI at /docs. |
| Docker images | Full image (hlohaus789/g4f) and slim image (…:latest-slim) for x86_64/arm64. Volumes store browser HAR/cookies and generated media. |
| MCP server | JSON‑RPC/HTTP service that offers web_search, web_scrape, and image_generation tools for external AI agents. |
| Provider adapters | Code under g4f/Provider/ implements connectors to services such as OpenAI‑compatible endpoints, PerplexityLabs, Gemini, MetaAI, Pollinations (media), and local model runtimes. |
How to get started
- Install –
pip install -U g4f[all](or pull the Docker image). - Run –
- GUI:
python -m g4f.cli gui --port 8080 - API:
python -m g4f --port 8080 - MCP:
g4f mcp --http --port 8765
- GUI:
- Call the API – Example Python snippet:
The library selects the best available provider automatically.from g4f.client import Client c = Client() resp = c.chat.completions.create(model="auto", messages=[{"role":"user","content":"Hello!"}]) print(resp.choices[0].message.content)
Why it matters – It lowers the barrier to experiment with many LLM services without juggling separate SDKs or API keys. By offering an OpenAI‑compatible layer, existing codebases (LangChain, Pydantic‑AI, etc.) can switch to free or community‑hosted back‑ends with minimal changes.
Licensing & community – GPL‑v3 licensed, encouraging open collaboration. Development is driven by @xtekky (creator) and @hlohaus (maintainer) with an active Discord/Telegram community and sponsorship options via GitHub.
Typical use‑cases
- Rapid prototyping of chatbots that can fall back to any reachable model.
- Media generation (images, audio, video) through providers like Pollinations.
- Running a self‑hosted OpenAI‑compatible endpoint for internal tools.
- Enabling other AI assistants to perform web searches or generate images via the MCP server.
Resources
- Docs & live demo: https://g4f.dev
- PyPI: https://pypi.org/project/g4f
- Docker Hub: https://hub.docker.com/r/hlohaus789/g4f
- GitHub: https://github.com/xtekky/gpt4free
Related
- Project
- Project
- Project
- Project
- Project