Skip to main content

Free OpenAI-compatible API gateway — route requests to free LLM providers with zero-code setup. Save thousands on API costs.

Project description

FreeBuff Gateway

Free OpenAI-compatible API gateway — route requests to free LLM providers with zero-code setup. Save thousands on API costs.

Python 3.10+ License: MIT


Why?

OpenAI API costs add up fast. FreeBuff Gateway is a transparent proxy that sits between your existing tools (anything that speaks OpenAI API) and free LLM providers:

  • Primary: FreeBuff (freebuff.llm.pm) — free MiniMax M2.7, Gemini Flash, and more
  • Fallback: OpenRouter free tier — additional free models
  • Last resort: Local Ollama — completely free, runs on your machine

Just point your existing code at http://localhost:8080/v1 and keep using gpt-4, gpt-3.5-turbo, or any model name — the gateway maps it to the real free model automatically.


Quick Start

# Install
pip install freebuff-gateway

# Run the setup wizard
freebuff-gateway setup

# Start the gateway
freebuff-gateway start --port 8080

That's it. Your existing OpenAI-compatible tools now talk to free LLMs.


Features

Feature Description
OpenAI-compatible API Drop-in replacement for api.openai.com
Streaming + Non-streaming Full SSE streaming support
Multi-provider failover FreeBuff → OpenRouter → Ollama
Model mapping gpt-4 → MiniMax M2.7, gpt-3.5 → MiniMax M2, etc.
Rate limiting Per-IP and per-key sliding window
Usage dashboard Beautiful HTML dashboard with live stats
Cost tracking See how much you've saved vs. OpenAI pricing
SQLite storage Lightweight, no external DB needed
CLI-first freebuff-gateway start, setup, status, config

Usage

Start the server

# Default port 8080
freebuff-gateway start

# Custom port
freebuff-gateway start --port 9090 --host 127.0.0.1

Test with curl

# List models
curl http://localhost:8080/v1/models

# Chat completion (non-streaming)
curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

# Chat completion (streaming)
curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "stream": true,
    "messages": [{"role": "user", "content": "Write a poem"}]
  }'

Dashboard

Open http://localhost:8080/v1/dashboard to see:

  • Total tokens saved
  • Costs avoided (vs. OpenAI pricing)
  • Provider breakdown
  • Recent request log

Status

freebuff-gateway status

Shows configuration and usage statistics.


Configuration

Environment variables

Variable Default Description
FREEBUFF_TOKEN FreeBuff auth token (from freebuff.llm.pm)
FREEBUFF_BASE_URL https://freebuff.llm.pm/v1 FreeBuff API endpoint
OPENROUTER_API_KEY OpenRouter API key (free tier)
OLLAMA_BASE_URL http://localhost:11434/v1 Local Ollama endpoint
PORT 8080 Gateway listen port
HOST 0.0.0.0 Gateway bind address
RATE_LIMIT_PER_IP 60 Max requests per minute per IP
RATE_LIMIT_PER_KEY 120 Max requests per minute per API key

Config file

Configuration is stored in ~/.config/freebuff-gateway/config.json.

Model mapping

The gateway automatically maps common model names:

Your request Actual model
gpt-4 minimax/minimax-m2.7 (via FreeBuff)
gpt-4-turbo minimax/minimax-m2.7
gpt-3.5-turbo minimax/minimax-m2
claude-3-opus minimax/minimax-m2.7
claude-3-haiku google/gemini-2.5-flash-lite
gemini-pro google/gemini-2.5-flash-lite

You can customize mappings in ~/.config/freebuff-gateway/config.json.


Architecture

┌─────────────────────────────────────────────────────────┐
│                    Your Application                      │
│  (OpenAI SDK, curl, LangChain, any OpenAI-compatible)    │
└─────────────────────┬───────────────────────────────────┘
                      │ POST /v1/chat/completions
                      ▼
┌─────────────────────────────────────────────────────────┐
│              FreeBuff Gateway (localhost:8080)            │
│                                                          │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌────────┐ │
│  │ Rate     │→│ Model    │→│ Provider │→│ Usage  │ │
│  │ Limiter  │  │ Mapper   │  │ Router   │  │ DB     │ │
│  └──────────┘  └──────────┘  └──────────┘  └────────┘ │
│                                      │                   │
└──────────────────────────────────────┼───────────────────┘
                                       │
              ┌────────────────────────┼────────────────┐
              ▼                        ▼                ▼
     ┌────────────────┐      ┌──────────────┐    ┌──────────┐
     │ FreeBuff       │      │ OpenRouter   │    │ Ollama   │
     │ (Primary)      │      │ (Fallback 1) │    │(Fallback2)│
     │ free.llm.pm    │      │ openrouter.ai│    │ localhost │
     └────────────────┘      └──────────────┘    └──────────┘

Provider Setup

FreeBuff (Primary)

  1. Visit https://freebuff.llm.pm
  2. Log in or create an account
  3. Open DevTools → Application → Local Storage → copy your auth token
  4. Run freebuff-gateway setup and paste the token

Or set FREEBUFF_TOKEN=your_token_here in your environment.

OpenRouter (Fallback)

  1. Visit https://openrouter.ai/keys
  2. Create a free API key
  3. Run freebuff-gateway setup or set OPENROUTER_API_KEY

Ollama (Local Fallback)

  1. Install Ollama from https://ollama.com
  2. Pull a model: ollama pull llama3.2
  3. Start Ollama: ollama serve
  4. The gateway will auto-detect it at http://localhost:11434

Development

# Clone and install in dev mode
git clone https://github.com/freebuff-gateway/freebuff-gateway.git
cd freebuff-gateway
pip install -e .

# Run tests
pytest

License

MIT


FreeBuff Gateway is not affiliated with OpenAI, FreeBuff, OpenRouter, or Ollama.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

freebuff_gateway-0.1.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

freebuff_gateway-0.1.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file freebuff_gateway-0.1.0.tar.gz.

File metadata

  • Download URL: freebuff_gateway-0.1.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for freebuff_gateway-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e4352e29e22286368575e504d3462f139901a259ca67db88b9bbdb374f028f98
MD5 142261ed2315305711c83e8e7da78e7a
BLAKE2b-256 5898f14069675bb3a21f605234ffba596e4b3effb444ecc43f0fe7b58534b18e

See more details on using hashes here.

File details

Details for the file freebuff_gateway-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: freebuff_gateway-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for freebuff_gateway-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0abdf41d18ae462e9821202109708ae46f23702240dc128f27d6185f651e399a
MD5 3c81a44db10ca7306ec0699771c0f78a
BLAKE2b-256 5e17888e05526a6d019bcac9f157e2ce92b8275d298802acbd7faaf5452cf82d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page