⚠️ Disclaimer (Vibe Coder Edition):
This project does not claim to be "professional" or ready for enterprise production! It is above all a "home project" created out of pure passion for AI, coded "on the vibe" (vibe coder) to have fun with local LLMs on Android. If the code isn't perfectly academic, that's normal—it's made with love! ❤️
Note: This API server is primarily developed, tested, and optimized for the Gemma model family (Gemma 2B, 4B, etc.) in
.litertlmor.tfliteformat. While other models may theoretically load, the internal prompt formatting and memory management are specifically tailored for Gemma.
LiteRT API Server is a powerful Android-based server that exposes Google's LiteRT (formerly TensorFlow Lite / MediaPipe) as a high-performance, local REST API.
Built in Kotlin with Ktor, this application turns any compatible Android device (Phone, Tablet, or TV Box) into an autonomous AI server running Large Language Models (LLMs) like Gemma entirely on-device (Edge AI).
- 🧠 Local LLM Inference: Run
.tflite/.litertlmmodels directly on the device using the CPU, GPU, or NPU. - 🌐 REST API: Exposes OpenAI-compatible
/v1/chat/completionsendpoints. - 🛠️ Built-in Web Admin Panel: Manage models, upload
.tflitefiles directly from your browser, and monitor hardware metrics. - 📊 Real-time Monitoring: Tracks RAM usage and device temperature to prevent thermal throttling.
- ⚙️ Dynamic Parameters: Supports modifying
temperature,topK,topP, and system prompts per request. - 🛡️ Secure Access: API Key (Bearer Token) support to secure your endpoints.
The server runs a local web interface accessible via browser on your network (e.g., http://<ANDROID_IP>:3000/admin).
From the dashboard, you can:
- Upload Base Models (
.tflite). - Manage active inferences.
- Restart the background service.
- Language: Kotlin
- Server Framework: Ktor (Embedded Server)
- AI Engine: Google LiteRT (MediaPipe / TFLite)
- Frontend (Admin Panel): Vanilla HTML/CSS/JS with a dark mode glassmorphism UI.
- Android Studio.
- An Android device running Android 10+ (a powerful GPU is recommended for LLM inference).
- Pre-converted
.tfliteor.litertlmmodels (e.g., Gemma 2B converted for LiteRT).
- Clone this repository.
- Open the project in Android Studio.
- Build and install the APK on your device.
- Launch the app and grant the necessary permissions (Storage & Network).
- The server will start automatically on port
3000.
You can query the server locally using standard curl or any OpenAI-compatible client.
curl -X POST http://<ANDROID_IP>:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"temperature": 0.7,
"topK": 40
}'This application is designed as a Homelab / Hobby project to be run on a trusted local network.
Important: The Web Administration Panel (/admin) is not authenticated. Anyone on your local network can access it, upload models, or restart the service.
If you plan to expose this API Server to the public internet or an untrusted network, DO NOT expose port 3000 directly. It is highly recommended to place the application behind a secure reverse proxy (like Nginx, Caddy, or Traefik), configure SSL/TLS, and add Basic Authentication (or Authelia) to protect the /admin routes.
This project is licensed under the MIT License.
Made with ❤️ by Clement Monteiro