The official gpt4free repository | various collection of powerful language models | opus 4.6 gpt 5.3 kimi 2.5 deepseek v3.2 gemini 3
The official gpt4free repository | various collection of powerful language models | opus 4.6 gpt 5.3 kimi 2.5 deepseek v3.2 gemini 3
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
mkdir -p ${PWD}/har_and_cookies ${PWD}/generated_media
sudo chown -R 1200:1201 ${PWD}/har_and_cookies ${PWD}/generated_mediadocker pull hlohaus789/g4fdocker 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:latestNotes:
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-slimNotes:
👉 Check out the Windows launcher for GPT4Free:
🔗 https://github.com/gpt4free/g4f.exe 🚀
g4f.exe.zip from:
https://github.com/xtekky/gpt4free/releases/latestg4f.exe.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:
from g4f.gui import run_gui
run_gui()python -m g4f.cli gui --port 8080 --debugpython -m g4f --port 8080 --debughttp://localhost:1337/v1http://localhost:1337/docspython -m g4f.cli gui --port 8080 --debugGPT4Free 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.mcpStarting 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 3000HTTP mode provides:
POST http://localhost:8765/mcp - JSON-RPC endpointGET http://localhost:8765/health - Health checkConfiguring with Claude Desktop:
Add to your claude_desktop_config.json:
{
"mcpServers": {
"gpt4free": {
"command": "python",
"args": ["-m", "g4f.mcp"]
}
}
}Available MCP Tools:
web_search - Search the web using DuckDuckGoweb_scrape - Extract text content from web pages image_generation - Generate images from text promptsFor detailed MCP documentation, see g4f/mcp/README.md
http://localhost:7900/?autoconnect=1&resize=scale&password=secretInstall:
pip install -U g4f[all]Synchronous text example:
from g4f.client import Client
client = Client()
response = client.chat.completions.create(
model="gpt-4o-mini",
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="gpt-4o-mini",
messages=[{"role": "user", "content": "Explain quantum computing briefly"}],
)
print(response.choices[0].message.content)
asyncio.run(main())Notes:
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: 'gpt-4.1', // Or "gpt-4o", "deepseek-v3", etc.
messages: [{ role: 'user', content: 'Explain quantum computing' }]
});
console.log(result.choices[0].message.content);
</script>Notes:
Provider requirements may include:
Add model reliability ratings to README
[Bug] Puter provider relays tool_calls without stringifying function.arguments → AI_TypeValidationError in opencode
[Bug] [OpenaiChat] Empty reply
Can it run locally on Ubuntu/Kali?
Untrusted impersonation of the project at gpt4free.org