Mengubah model AI gratis Freebuff menjadi format API OpenAI Chat Completions standar
Fitur Utama • Mulai Cepat • Cara Deploy • Dokumentasi API • Panel Admin • Daftar Model • FAQ
| Fitur | Keterangan |
|---|---|
| 🔄 Kompatibel OpenAI | Sepenuhnya kompatibel dengan endpoint /v1/chat/completions, bisa langsung menggantikan OpenAI API |
| 🤖 Kompatibel Anthropic | Mendukung endpoint /v1/messages, kompatibel dengan client seperti Claude Code |
| 🆓 Gratis Total | Berbasis model gratis Freebuff, tanpa biaya |
| 🎯 Dukungan Banyak Model | DeepSeek V4 Flash/Pro, Kimi K2.6, MiniMax M2.7/M3, Mimo V2.5/V2.5 Pro, Gemini |
| 🔑 Banyak API Key | Mendukung pembuatan banyak API Key, setiap Key bisa dikonfigurasi whitelist model independen |
| 📊 Panel Admin | Backend admin React modern, mendukung log real-time, manajemen Token, deteksi jaringan, dll. |
| 🌊 Output Streaming | Dukungan penuh respons streaming SSE |
| 🚀 Deploy Sekali Klik | Mendukung Vercel Serverless serta deploy lokal/server |
| 🔒 Autentikasi Aman | Session Cookie bertanda HMAC, rate-limit login, proteksi CSRF |
| 📱 Desain Responsif | Panel admin adaptif untuk desktop dan mobile |
Masalah: Pemanggilan langsung API Freebuff mengembalikan 403 free_mode_cli_required ("Free mode is only available through the freebuff CLI"), sehingga semua model tidak dapat digunakan.
Akar Masalah: Server upstream memvalidasi apakah system prompt dalam body chat/completions merupakan prompt Buffy asli dari CLI ("You are Buffy, the strategic coding assistant...Freebuff..."). Versi lama menggunakan prefix palsu "You are Buffy. [System Override...]", yang dikenali server sebagai permintaan non-CLI lalu ditolak.
Perbaikan:
- Tambah
freebuff2api/buffy_prompt.py: template system prompt Buffy asli yang diekstrak dari binary freebuff CLI (v0.0.135), tanggal dibuat dinamis openai_compat.py:normalize_chat_messagesselalu menyuntikkan prompt Buffy asli ke pesan system pertama (konten system kustom pengguna ditambahkan setelahnya, tidak lagi ditimpa)codebuff.py: versi User-Agent chat requestai-sdk/provider-utils/3.0.20→3.0.25(sesuai CLI)
Verifikasi: Uji end-to-end session → agent-runs → chat/completions mengembalikan 200 + respons streaming SSE, test suite tanpa regresi.
- Python 3.11+(disarankan 3.12)
- Node.js 18+(hanya untuk membangun frontend)
git clone https://github.com/t479842598/freebuff2apiNew.git
cd freebuff2apiNew# Buat virtual environment (disarankan)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Instal dependensi Python
pip install -r requirements.txtSalin template variabel lingkungan lalu edit:
cp .env.example .envEdit file .env, minimal isi variabel berikut:
# 🔑 Freebuff Token(wajib)
# Dapatkan dari https://www.codebuff.com
FREEBUFF_TOKEN=your_token_here
# 🔐 API Key(wajib)
# Kunci akses untuk memanggil endpoint /v1/*
FREEBUFF_API_KEY=sk-your-key-here
# 🛡️ Kunci Admin(wajib)
# Untuk login ke panel admin
FREEBUFF_ADMIN_KEY=sk-adminpython main.py
# atau
uvicorn freebuff2api.app:app --host 0.0.0.0 --port 8000# Health check
curl http://localhost:8000/healthz
# Dapatkan daftar model
curl http://localhost:8000/v1/models \
-H "Authorization: Bearer ***"
# Tes percakapan
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ***" \
-d '{
"model": "deepseek/deepseek-v4-flash",
"messages": [{"role": "user", "content": "Halo!"}]
}'Fork repositori ini ke akun GitHub Anda.
- Login ke Vercel
- Klik "New Project"
- Pilih repositori yang sudah di-fork
- Preset framework pilih "Other"
- Klik "Deploy"
Tambahkan variabel lingkungan di pengaturan proyek Vercel:
FREEBUFF_TOKEN- Token Freebuff AndaFREEBUFF_API_KEY- Kunci akses APIFREEBUFF_ADMIN_KEY- Kunci panel admin
Tambahkan domain Anda di pengaturan proyek Vercel → Domains.
# Gunakan daemon systemd (Linux)
sudo tee /etc/systemd/system/freebuff2api.service <<EOF
[Unit]
Description=Freebuff2API Service
After=network.target
[Service]
User=www-data
WorkingDirectory=/path/to/freebuff2api
ExecStart=/path/to/.venv/bin/uvicorn freebuff2api.app:app --host 0.0.0.0 --port 8000
Restart=always
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable freebuff2api
sudo systemctl start freebuff2apidocker build -t freebuff2api .
docker run -d \
-p 8000:8000 \
-e FREEBUFF_TOKEN=your_token \
-e FREEBUFF_API_KEY=sk-your-key \
-e FREEBUFF_ADMIN_KEY=sk-admin \
--name freebuff2api \
freebuff2apiGET /v1/models
Authorization: Bearer ***POST /v1/chat/completions
Authorization: Bearer ***
Content-Type: application/json
{
"model": "deepseek/deepseek-v4-flash",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Halo!"}
],
"stream": true,
"temperature": 0.7
}POST /v1/messages
Authorization: Bearer ***
Content-Type: application/json
{
"model": "deepseek/deepseek-v4-flash",
"messages": [
{"role": "user", "content": "Halo!"}
],
"stream": true,
"max_tokens": 4096
}| Parameter | Dukungan | Keterangan |
|---|---|---|
model |
✅ | ID model(lihat daftar model di bawah) |
messages |
✅ | Array pesan |
stream |
✅ | Output streaming |
temperature |
✅ | Parameter temperatur |
max_tokens |
✅ | Jumlah token output maksimum |
top_p |
✅ | Sampling Top-p |
stop |
✅ | Kata penghenti |
tools |
✅ | Pemanggilan fungsi (Function Calling) |
Akses http://localhost:8000/admin untuk masuk ke panel admin.
| Modul | Keterangan |
|---|---|
| 📊 Ringkasan | Status layanan, jumlah Token, jumlah model, lingkungan deploy |
| 🔑 Manajemen Token | Tambah/edit/hapus Token Freebuff, dukung verifikasi validitas |
| 🗝️ API Key | Buat banyak API Key, konfigurasi whitelist model |
| 📝 Log Operasional | Lihat log layanan secara real-time, filter berdasarkan level |
| 📈 Riwayat Permintaan | Lihat riwayat panggilan API, filter berdasarkan model/status |
| ⚙️ Lihat Env | Lihat isi file konfigurasi lingkungan |
| 🌐 Deteksi Jaringan | Deteksi IP publik, lokasi geografis, konektivitas layanan upstream |
| 🧪 Tes Model | Tes hasil pemanggilan model secara online |
| 🛡️ Pengaturan | Ubah kunci admin |
- Frontend: React 19 + TypeScript + Tailwind CSS v4 + komponen bergaya shadcn/ui
- Build: Vite 8, output ke
freebuff2api/admin_static/ - Backend: FastAPI melayani hasil build langsung, fallback rute SPA
| ID Model | Penyedia | Keterangan |
|---|---|---|
deepseek/deepseek-v4-flash |
DeepSeek | 🚀 Respons cepat, cocok untuk percakapan sehari-hari |
deepseek/deepseek-v4-pro |
DeepSeek | 💪 Performa tinggi, cocok untuk tugas kompleks |
moonshotai/kimi-k2.6 |
Moonshot | 🌙 Optimasi bahasa Mandarin, kemampuan teks panjang kuat |
minimax/minimax-m2.7 |
MiniMax | 🎯 Multimodal, value for money |
minimax/minimax-m3 |
MiniMax | 🚀 Versi terbaru, performa meningkat |
mimo/mimo-v2.5 |
Mimo | 🔬 Kemampuan kode kuat |
mimo/mimo-v2.5-pro |
Mimo | 💪 Versi Pro, kemampuan kode lebih kuat |
| ID Model | Keterangan |
|---|---|
google/gemini-2.5-flash-lite |
⚡ Ringan dan cepat |
google/gemini-3.1-flash-lite-preview |
🔬 Versi pratinjau terbaru |
google/gemini-3.1-pro-preview |
💪 Versi Pro |
| Nama Variabel | Wajib | Default | Keterangan |
|---|---|---|---|
FREEBUFF_TOKEN |
✅ | - | Token Freebuff(banyak dipisah koma) |
FREEBUFF_API_KEY |
✅ | - | Kunci akses API |
FREEBUFF_ADMIN_KEY |
✅ | sk-admin |
Kunci panel admin( |
FREEBUFF_API_BASE_URL |
❌ | https://www.codebuff.com |
Alamat API upstream |
FREEBUFF_TIMEOUT |
❌ | 60 |
Timeout permintaan(detik) |
FREEBUFF_PROXY_ENABLED |
❌ | false |
Aktifkan proxy atau tidak |
FREEBUFF_PROXY_URL |
❌ | - | Alamat proxy(mendukung socks5) |
FREEBUFF_DEBUG |
❌ | false |
Mode debug |
FREEBUFF_LOG_LEVEL |
❌ | INFO |
Level log |
FREEBUFF_HOST |
❌ | 0.0.0.0 |
Alamat listen |
FREEBUFF_PORT |
❌ | 8000 |
Port listen |
- Ubah kunci default: Wajib ubah
FREEBUFF_ADMIN_KEYdanFREEBUFF_API_KEYsebelum deploy - Gunakan HTTPS: Disarankan konfigurasi SSL/TLS di lingkungan produksi
- Batasi akses: Batasi sumber akses melalui firewall atau API Key
- Rotasi berkala: Ganti Token dan API Key secara berkala
cd web
# Instal dependensi
npm install
# Jalankan server pengembangan (hot reload)
npm run dev
# Build versi produksi
npm run buildFrontend menggunakan:
- React 19 + TypeScript
- Tailwind CSS v4
- Build Vite 8
- Proxy ke backend
localhost:8000
freebuff2apiNew/
├── freebuff2api/ # 🐍 Inti backend Python
│ ├── app.py # Aplikasi utama FastAPI
│ ├── admin.py # API panel admin
│ ├── codebuff.py # Client upstream Freebuff
│ ├── config.py # Pemuatan konfigurasi
│ ├── models.py # Definisi model
│ ├── buffy_prompt.py # 🐝 System prompt Buffy asli(wajib untuk validasi upstream)
│ ├── openai_compat.py # Lapisan kompatibilitas format OpenAI
│ ├── anthropic_compat.py # Lapisan kompatibilitas format Anthropic
│ ├── usage.py # Model data
│ ├── usage_store.py # Lapisan penyimpanan
│ ├── logging_config.py # Konfigurasi log
│ └── admin_static/ # 🎨 Hasil build frontend
├── web/ # 🎨 Kode sumber frontend React
│ ├── src/pages/ # 10 komponen halaman
│ ├── src/components/ # Pustaka komponen UI
│ ├── src/hooks/ # React Hooks
│ └── src/lib/ # Fungsi utilitas
├── main.py # 🏃 Entry point eksekusi lokal
├── requirements.txt # 📦 Dependensi Python
├── vercel.json # ⚙️ Konfigurasi Vercel
└── .env.example # 📝 Template variabel lingkungan
A: Ada dua cara:
- Panel Admin: Akses
/admin→ Manajemen Token → Tambah - Variabel Lingkungan: Set
FREEBUFF_TOKENdi file.env
A: Kunjungi https://www.codebuff.com, daftar akun lalu dapatkan API Token di halaman pengaturan.
A: Semua client yang mendukung OpenAI API bisa digunakan, termasuk:
- ChatGPT Next Web
- LobeChat
- ChatBox
- Cursor
- VS Code + Continue
- Claude Code(menggunakan endpoint
/v1/messages)
A: Versi gratis Vercel memiliki batasan berikut:
- Bandwidth 100GB per bulan
- 1 eksekusi fungsi per detik
- Waktu eksekusi fungsi ≤ 10 detik
Disarankan pengguna dengan trafik besar menggunakan deploy lokal/server.
Selamat datang untuk mengirim Issue dan Pull Request!
- Fork repositori ini
- Buat branch fitur:
git checkout -b feature/amazing-feature - Commit perubahan:
git commit -m 'Add amazing feature' - Push branch:
git push origin feature/amazing-feature - Kirim Pull Request
Proyek ini menggunakan lisensi MIT - lihat file LICENSE
- Freebuff - Penyedia model AI gratis
- FastAPI - Framework web Python berperforma tinggi
- React - Pustaka UI frontend
- Tailwind CSS - Framework CSS utility-first
- Vercel - Platform deploy Serverless
⭐ Jika bermanfaat, berikan Star sebagai dukungan!