GPT4Free

Active
GitHub Python GPL-3.0

Description

GPT4Free (g4f) is a community-driven multi-provider LLM aggregation tool uniting dozens of LLM and media-generation APIs behind a single OpenAI-compatible interface. Includes Python/JS client, Docker images, and an MCP server.

Key Features

  • Multi-provider unified interface — One OpenAI-compatible API transparently routes to dozens of LLM and media-generation providers
  • Python / JS client — drop-in Client API identical to the openai library, zero learning curve to migrate
  • MCP server — Built-in MCP server exposes web search, scraping, and image generation to Claude and other AI assistants
  • One-click Docker deployment — Official full and slim Docker images include a VNC desktop for provider cookie login

Use Cases

💡 Call multiple LLM providers through a single OpenAI SDK-compatible API, eliminating vendor lock-in
💡 Run a multi-model inference service inside a Docker container as an internal API gateway for your team
💡 Equip Claude Desktop and other tools with web search and image generation via the built-in MCP server

Quick Start

# pip install (full features)
pip install -U g4f[all]

# Or one-click Docker start (recommended)
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

# Python client usage
from g4f.client import Client
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}]
)

Related Projects