OpenAI-compatible proxy server for Freebuff that translates standard OpenAI API requests into Freebuff's backend format with multi-token rotation and Docker deployment.
OpenAI-compatible proxy server for Freebuff that translates standard OpenAI API requests into Freebuff's backend format with multi-token rotation and Docker deployment.
Freebuff2API is an OpenAI-compatible proxy server written in Go that translates standard OpenAI API requests into Freebuff's backend format. It enables any OpenAI-compatible client, SDK, or CLI tool to use Freebuff's free models without modification.
What It Does
Exposes standard OpenAI endpoints (/v1/chat/completions, etc.)
Dynamically randomizes client fingerprints to mimic official Freebuff SDK behavior
Rotates multiple auth tokens on a configurable interval
Routes outbound traffic through an optional HTTP proxy
Ships as a multi-arch Docker image for easy deployment
Getting Auth Tokens
Before deploying, obtain one or more Freebuff auth tokens:
Method 1 — Web (easiest):
Visit https://freebuff.llm.pm, log in with your Freebuff account, and copy the displayed token.
Copy the authToken value — this is your AUTH_TOKENS value.
Installation & Deployment
Docker (Recommended)
# Single token
docker run -d --name freebuff2api \
-p 8080:8080 \
-e AUTH_TOKENS="$FREEBUFF_TOKEN" \
ghcr.io/quorinex/freebuff2api:latest
# Multiple tokens (comma-separated for higher throughput)
docker run -d --name freebuff2api \
-p 8080:8080 \
-e AUTH_TOKENS="$FREEBUFF_TOKEN_1,$FREEBUFF_TOKEN_2,$FREEBUFF_TOKEN_3" \
ghcr.io/quorinex/freebuff2api:latest
# With HTTP proxy and API key protection
docker run -d --name freebuff2api \
-p 8080:8080 \
-e AUTH_TOKENS="$FREEBUFF_TOKEN" \
-e API_KEYS="$MY_PROXY_API_KEY" \
-e HTTP_PROXY="$HTTP_PROXY_URL" \
ghcr.io/quorinex/freebuff2api:latest
Docker Compose
# docker-compose.ymlversion:"3.8"services:freebuff2api:image:ghcr.io/quorinex/freebuff2api:latestcontainer_name:freebuff2apirestart:unless-stoppedports:-"8080:8080"environment:AUTH_TOKENS:"${FREEBUFF_TOKENS}"API_KEYS:"${PROXY_API_KEYS}"ROTATION_INTERVAL:"6h"REQUEST_TIMEOUT:"15m"# Or mount a config file:# volumes:# - ./config.json:/app/config.json# command: ["-config", "/app/config.json"]
git clone https://github.com/Quorinex/Freebuff2API.git
cd Freebuff2API
go build -o freebuff2api .
# Run with config file
./freebuff2api -config config.json
# Run with environment variables
AUTH_TOKENS="$FREEBUFF_TOKEN" ./freebuff2api
from openai import OpenAI
import os
client = OpenAI(
base_url="http://localhost:8080/v1",
api_key=os.environ.get("PROXY_API_KEY", "unused"), # any value if API_KEYS is empty
)
response = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain async/await in Python."},
],
)
print(response.choices[0].message.content)
Streaming
from openai import OpenAI
import os
client = OpenAI(
base_url="http://localhost:8080/v1",
api_key=os.environ.get("PROXY_API_KEY", "unused"),
)
stream = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[{"role": "user", "content": "Write a short poem."}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content isnotNone:
print(chunk.choices[0].delta.content, end="", flush=True)
print()
from langchain_openai import ChatOpenAI
import os
llm = ChatOpenAI(
model="claude-3-5-sonnet",
openai_api_base="http://localhost:8080/v1",
openai_api_key=os.environ.get("PROXY_API_KEY", "unused"),
)
result = llm.invoke("What is the capital of France?")
print(result.content)
Check AUTH_TOKENS is set correctly (not empty, no extra whitespace).
Request timeouts
Increase REQUEST_TIMEOUT beyond default 15m for very long completions:
{"REQUEST_TIMEOUT":"30m"}
Connection refused on localhost:8080
Confirm the container/process is running: docker ps or ps aux | grep freebuff2api
Check LISTEN_ADDR — if set to a specific interface (e.g., 127.0.0.1:8080), ensure you're connecting to the right address.
For Docker, verify the port mapping: -p 8080:8080
Docker container exits immediately
# Check logs
docker logs freebuff2api
# Common cause: AUTH_TOKENS not set
docker run --rm -e AUTH_TOKENS="$FREEBUFF_TOKEN" ghcr.io/quorinex/freebuff2api:latest
Multiple tokens not rotating
Verify tokens are comma-separated (env var) or a JSON array (config file).
Check ROTATION_INTERVAL is a valid Go duration string: "1h", "30m", "6h", etc.
Project Structure (Source)
Freebuff2API/
├── main.go # Entry point, config loading, server startup
├── config.json # Default config file (gitignored if contains secrets)
├── Dockerfile # Multi-arch Docker build
├── go.mod / go.sum # Go module dependencies
├── README.md
└── README_zh.md
Key CLI Flag
./freebuff2api -config /path/to/config.json
The only CLI flag is -config to specify an alternate config file path. All other configuration is via the JSON file or environment variables.