Status: Project ini masih dalam tahap pengembangan aktif (work in progress). Beberapa fitur, flow auth, dan endpoint dapat berubah sewaktu-waktu.
LeoAPI adalah backend FastAPI untuk image generation Leonardo AI dengan endpoint OpenAI-compatible, Admin Dashboard, Studio UI, Telegram bot, dan Cookie Pool berbasis full-cookie.
| Area | Detail |
|---|---|
| OpenAI-compatible endpoint | POST /v1/images/generations |
| Cookie Pool | Multi-cookie rotasi + refresh profile/session |
| Full-cookie auth | Input utama wajib full cookie string, bukan JWT-only |
| Auto refresh token | JWT fallback di-refresh otomatis dari full cookie saat runtime |
| Studio Dashboard | Batch submit + polling job progress realtime |
| Studio Prompt Builder | Multiline draft, add/edit/delete, hidden preview item |
| Studio UX | Dark mode, sidebar rapi, compact lightbox preview |
| Telegram Bot | Enable/disable, token, allowlist chat IDs, test connection |
| Auto save image | Simpan hasil generation ke folder lokal (opsional) |
| Persistensi | SQLite di data/app.db |
- Request generation tetap menggunakan Bearer JWT.
- Sumber utama auth adalah full cookie.
- JWT fallback hanya dipakai jika valid, fresh, dan cocok token Leonardo.
- Saat backend berhasil resolve JWT baru dari full cookie, fallback token disimpan ulang otomatis ke Cookie Pool.
Tujuan alur ini: menghindari kondisi token cepat expired walau cookie login masih valid.
- Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh- Install dependencies
uv sync- Run server
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload| Area | Path |
|---|---|
| Health | /health |
| OpenAI images | /v1/images/generations |
| Admin login | /admin/login |
| Studio login | /studio/login |
| Studio dashboard | /studio/dashboard |
| Scope | Username | Password |
|---|---|---|
| Admin | admin | admin123 |
| Studio | studio | studio123 |
Ganti credential default sebelum dipakai produksi.
| Aspect Ratio | Resolution |
|---|---|
| 16:9 | 2752x1536 |
| 9:16 | 1536x2752 |
| 1:1 | 1536x1536 |
| 4:3 | 2048x1536 |
Alias size yang tetap diterima: 1344x768, 768x1344, 1024x1024, 1152x896.
Extension ExLeo dipakai untuk ambil full cookie dari browser dengan format siap pakai di LeoAPI:
cookie=name=value; ...
token=... (opsional)Catatan:
- Format export JSON terenkripsi dari cookie manager eksternal bukan format direct-use untuk LeoAPI.
- LeoAPI menolak JWT-only tanpa full cookie.
- Submit batch ke POST /studio/api/images/batch.
- Dapatkan job_id.
- Poll status ke GET /studio/api/images/batch/{job_id}.
- UI menampilkan request id + status job queue realtime.
Dokumentasi endpoint terbaru ada di API.md.
Project ini menggunakan lisensi MIT. Lihat file LICENSE.