Make project production-grade for public release
- Add adaptive app icon with AI chip + signal wave vector design - Add Apache 2.0 LICENSE file - Rewrite README with badges, full API docs, Python examples, device compatibility table, dependency licenses, and ToS disclaimer - Extract all hardcoded layout strings to strings.xml - Add roundIcon support in AndroidManifest - Add GitHub community files: issue templates, PR template, CONTRIBUTING.md, SECURITY.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
51
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
51
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
name: Bug Report
|
||||
description: Report a bug with the Pixel10 AI Server
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to report a bug.
|
||||
- type: input
|
||||
id: device
|
||||
attributes:
|
||||
label: Device
|
||||
description: Which device are you using?
|
||||
placeholder: "e.g. Pixel 10 Pro"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: android-version
|
||||
attributes:
|
||||
label: Android Version
|
||||
placeholder: "e.g. Android 16 (API 36)"
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: backend
|
||||
attributes:
|
||||
label: AI Backend
|
||||
options:
|
||||
- Gemini Nano (ML Kit)
|
||||
- MediaPipe (custom model)
|
||||
- Not sure
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: What happened?
|
||||
description: Describe the bug clearly.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: What did you expect to happen?
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Logs
|
||||
description: Paste any relevant logs from the app or logcat.
|
||||
render: shell
|
||||
16
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
16
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Feature Request
|
||||
description: Suggest a new feature or improvement
|
||||
labels: ["enhancement"]
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the feature
|
||||
description: What would you like to see added or changed?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: use-case
|
||||
attributes:
|
||||
label: Use case
|
||||
description: How would you use this feature?
|
||||
17
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
17
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
## Summary
|
||||
|
||||
<!-- What does this PR do? -->
|
||||
|
||||
## Changes
|
||||
|
||||
-
|
||||
|
||||
## Testing
|
||||
|
||||
- [ ] Builds successfully (`./gradlew assembleDebug`)
|
||||
- [ ] Tested on device
|
||||
- [ ] API endpoints verified with curl
|
||||
|
||||
## Notes
|
||||
|
||||
<!-- Any additional context or screenshots -->
|
||||
31
CONTRIBUTING.md
Normal file
31
CONTRIBUTING.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Contributing to Pixel10 AI Server
|
||||
|
||||
Contributions are welcome! Here's how to get started.
|
||||
|
||||
## Development Setup
|
||||
|
||||
1. Clone the repo
|
||||
2. Open in Android Studio (Ladybug or newer) or build from CLI
|
||||
3. Ensure you have JDK 17+ and Android SDK 35 installed
|
||||
4. Build: `./gradlew assembleDebug`
|
||||
|
||||
## Making Changes
|
||||
|
||||
1. Fork the repo and create a branch from `main`
|
||||
2. Make your changes
|
||||
3. Test on a physical device (emulators don't have Tensor TPU or AICore)
|
||||
4. Submit a pull request
|
||||
|
||||
## Code Style
|
||||
|
||||
- Follow existing Kotlin conventions in the project
|
||||
- Use coroutines for async work (no callbacks)
|
||||
- Keep the OpenAI API compatibility — don't break existing endpoints
|
||||
|
||||
## Reporting Issues
|
||||
|
||||
Use the GitHub issue templates for bug reports and feature requests. Include your device model and Android version.
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.
|
||||
190
LICENSE
Normal file
190
LICENSE
Normal file
@@ -0,0 +1,190 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to the Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by the Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding any notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2025 alexpolo1
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
213
README.md
213
README.md
@@ -1,142 +1,207 @@
|
||||
# Pixel10 AI Server
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/Android-12%2B-3DDC84?logo=android&logoColor=white" alt="Android 12+">
|
||||
<img src="https://img.shields.io/badge/Kotlin-2.1-7F52FF?logo=kotlin&logoColor=white" alt="Kotlin">
|
||||
<img src="https://img.shields.io/badge/API-OpenAI_Compatible-412991?logo=openai&logoColor=white" alt="OpenAI Compatible">
|
||||
<img src="https://img.shields.io/github/license/alexpolo1/Pixel10-ai" alt="License">
|
||||
<img src="https://img.shields.io/github/v/release/alexpolo1/Pixel10-ai" alt="Release">
|
||||
</p>
|
||||
|
||||
Turn your Pixel 10 into a free AI API server. This Android app exposes the Tensor G5's on-device AI chip via a REST API, letting any device on your network make AI inference requests — no cloud, no API keys, no costs.
|
||||
<h1 align="center">Pixel10 AI Server</h1>
|
||||
|
||||
## How It Works
|
||||
<p align="center">
|
||||
<strong>Turn your Pixel into a free, private AI API server.</strong><br>
|
||||
Run Gemini Nano on the Tensor G5 chip and expose it as a local REST API — no cloud, no API keys, no cost.
|
||||
</p>
|
||||
|
||||
The app runs an HTTP server directly on your phone that accepts OpenAI-compatible API requests. Under the hood, it uses Google's on-device AI stack:
|
||||
---
|
||||
|
||||
1. **Gemini Nano** (preferred) — The system-provided model via ML Kit Prompt API, hardware-accelerated on the Tensor G5 TPU with a 32K token context window
|
||||
2. **MediaPipe LLM** (fallback) — For custom open-weight models like Gemma 3n or Gemma 2B that you supply yourself
|
||||
## What is this?
|
||||
|
||||
An Android app that turns your Pixel phone into a self-hosted AI inference server. It runs an HTTP server directly on the device, accepting **OpenAI-compatible** API requests over your local network.
|
||||
|
||||
Under the hood it uses Google's on-device AI stack:
|
||||
|
||||
- **Gemini Nano** via ML Kit Prompt API — hardware-accelerated on the Tensor G5 TPU
|
||||
- **MediaPipe LLM** as fallback — for custom open-weight models like Gemma 3n
|
||||
|
||||
All inference runs entirely on-device. Your data never leaves the phone.
|
||||
|
||||
## API Endpoints
|
||||
## Features
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| `POST` | `/v1/chat/completions` | Chat completion (OpenAI-compatible) |
|
||||
| `POST` | `/v1/completions` | Text completion |
|
||||
| `GET` | `/v1/models` | List available models |
|
||||
| `GET` | `/health` | Server status and device info |
|
||||
- **OpenAI-compatible API** — drop-in replacement for `openai.ChatCompletion.create()`
|
||||
- **Streaming support** — real-time Server-Sent Events (SSE) token streaming
|
||||
- **Zero configuration** — install, tap Start, done
|
||||
- **Fully offline** — no internet required after install
|
||||
- **Private by design** — prompts and responses stay on your device
|
||||
- **Background service** — keeps serving even when the app is minimized
|
||||
- **Custom model support** — bring your own Gemma, LLaMA, or other compatible models
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Install and Launch
|
||||
### 1. Install
|
||||
|
||||
Build the APK in Android Studio and install on your Pixel 10 (or Pixel 9/8 series).
|
||||
Download the APK from [Releases](https://github.com/alexpolo1/Pixel10-ai/releases) and install:
|
||||
|
||||
```bash
|
||||
adb install app-debug.apk
|
||||
```
|
||||
|
||||
Or build from source (see [Building](#building) below).
|
||||
|
||||
### 2. Start the Server
|
||||
|
||||
Open the app and tap **Start Server**. The app will:
|
||||
- Load the AI model (Gemini Nano or your custom model)
|
||||
- Start the HTTP server on the configured port (default: 8080)
|
||||
- Display the local IP address to connect to
|
||||
Open **Pixel10 AI Server**, tap **Start Server**. The app will load the model and display your device's IP address.
|
||||
|
||||
### 3. Make Requests
|
||||
### 3. Send Requests
|
||||
|
||||
From any device on the same WiFi network:
|
||||
From any device on the same network:
|
||||
|
||||
```bash
|
||||
# Chat completion
|
||||
curl http://<phone-ip>:8080/v1/chat/completions \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"messages": [
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
{"role": "user", "content": "What is the Tensor G5 chip?"}
|
||||
]
|
||||
"messages": [{"role": "user", "content": "What is the Tensor G5 chip?"}]
|
||||
}'
|
||||
|
||||
# Simple completion
|
||||
curl http://<phone-ip>:8080/v1/completions \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"prompt": "Explain quantum computing in simple terms"}'
|
||||
|
||||
# Health check
|
||||
curl http://<phone-ip>:8080/health
|
||||
|
||||
# List models
|
||||
curl http://<phone-ip>:8080/v1/models
|
||||
```
|
||||
|
||||
### Use with Python OpenAI Library
|
||||
## API Reference
|
||||
|
||||
All endpoints follow the [OpenAI API](https://platform.openai.com/docs/api-reference) format.
|
||||
|
||||
### Endpoints
|
||||
|
||||
| Method | Path | Description |
|
||||
|--------|------|-------------|
|
||||
| `POST` | `/v1/chat/completions` | Chat completion (supports streaming) |
|
||||
| `POST` | `/v1/completions` | Text completion |
|
||||
| `GET` | `/v1/models` | List available models |
|
||||
| `GET` | `/health` | Server status, device info, uptime |
|
||||
|
||||
### Chat Completion
|
||||
|
||||
```bash
|
||||
curl http://<phone-ip>:8080/v1/chat/completions \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"model": "pixel10-on-device",
|
||||
"messages": [
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
{"role": "user", "content": "Explain quantum computing briefly."}
|
||||
],
|
||||
"temperature": 0.7,
|
||||
"max_tokens": 1024,
|
||||
"stream": false
|
||||
}'
|
||||
```
|
||||
|
||||
### Streaming
|
||||
|
||||
```bash
|
||||
curl -N http://<phone-ip>:8080/v1/chat/completions \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"model": "pixel10-on-device",
|
||||
"messages": [{"role": "user", "content": "Write a haiku about the ocean."}],
|
||||
"stream": true
|
||||
}'
|
||||
```
|
||||
|
||||
### Python (OpenAI SDK)
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(
|
||||
base_url="http://<phone-ip>:8080/v1",
|
||||
api_key="not-needed" # no auth required
|
||||
api_key="not-needed"
|
||||
)
|
||||
|
||||
response = client.chat.completions.create(
|
||||
model="pixel10-on-device",
|
||||
messages=[
|
||||
{"role": "user", "content": "Hello from my laptop!"}
|
||||
]
|
||||
messages=[{"role": "user", "content": "Hello from my laptop!"}]
|
||||
)
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
|
||||
## Using Custom Models (MediaPipe)
|
||||
## Custom Models (MediaPipe)
|
||||
|
||||
If Gemini Nano isn't available on your device, you can use custom models:
|
||||
If Gemini Nano isn't available on your device, you can use custom open-weight models:
|
||||
|
||||
1. Download a compatible model (e.g., [Gemma 3n E2B](https://ai.google.dev/edge/mediapipe/solutions/genai/llm_inference/android))
|
||||
1. Download a compatible model (e.g. [Gemma 3n E2B](https://ai.google.dev/edge/mediapipe/solutions/genai/llm_inference/android))
|
||||
2. Push to the device:
|
||||
```bash
|
||||
adb push gemma-3n-E2B.task /data/data/com.pixel10.ai/files/
|
||||
```
|
||||
3. Restart the app — it will auto-detect the model file
|
||||
3. Restart the app — it auto-detects model files
|
||||
|
||||
Supported model formats: `.task`, `.bin`, `.tflite`
|
||||
**Supported formats:** `.task`, `.bin`, `.tflite`
|
||||
|
||||
## Supported Devices
|
||||
|
||||
- **Pixel 10 / 10 Pro / 10 Pro XL** — Full Tensor G5 TPU acceleration
|
||||
- **Pixel 9 series** — Tensor G4 TPU
|
||||
- **Pixel 8 series** — Tensor G3 TPU
|
||||
- Other Android 12+ devices — MediaPipe backend with custom models
|
||||
|
||||
## Requirements
|
||||
|
||||
- Android 12 (API 31) or higher
|
||||
- WiFi connection (for network access to the API)
|
||||
- For Gemini Nano: Pixel device with AICore support
|
||||
- For custom models: Compatible model file placed in app directory
|
||||
| Device | Chip | Backend |
|
||||
|--------|------|---------|
|
||||
| Pixel 10 / Pro / Pro XL | Tensor G5 | Gemini Nano (TPU-accelerated) |
|
||||
| Pixel 9 series | Tensor G4 | Gemini Nano (TPU-accelerated) |
|
||||
| Pixel 8 series | Tensor G3 | Gemini Nano (TPU-accelerated) |
|
||||
| Other Android 12+ | Various | MediaPipe with custom models |
|
||||
|
||||
## Building
|
||||
|
||||
```bash
|
||||
# Clone the repo
|
||||
git clone <repo-url>
|
||||
git clone https://github.com/alexpolo1/Pixel10-ai.git
|
||||
cd Pixel10-ai
|
||||
|
||||
# Open in Android Studio and build, or:
|
||||
./gradlew assembleDebug
|
||||
|
||||
# Install on connected device
|
||||
adb install app/build/outputs/apk/debug/app-debug.apk
|
||||
```
|
||||
|
||||
**Requirements:** JDK 17+, Android SDK 35
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
com.pixel10.ai/
|
||||
├── Pixel10AIApp.kt # Application init
|
||||
├── inference/
|
||||
│ ├── OnDeviceModel.kt # Unified model interface
|
||||
│ ├── GeminiNanoModel.kt # Gemini Nano via ML Kit Prompt API
|
||||
│ └── MediaPipeModel.kt # Custom models via MediaPipe LLM
|
||||
│ ├── OnDeviceModel.kt # Unified inference interface
|
||||
│ ├── GeminiNanoModel.kt # ML Kit Prompt API backend
|
||||
│ └── MediaPipeModel.kt # MediaPipe LLM backend
|
||||
├── server/
|
||||
│ ├── AIApiServer.kt # NanoHTTPD-based REST API server
|
||||
│ ├── ApiModels.kt # Request/response data classes
|
||||
│ └── ApiServerService.kt # Foreground service for background operation
|
||||
├── ui/
|
||||
│ └── MainActivity.kt # Server controls and status dashboard
|
||||
└── Pixel10AIApp.kt # Application class
|
||||
│ ├── AIApiServer.kt # NanoHTTPD REST server
|
||||
│ ├── ApiModels.kt # Request/response models
|
||||
│ └── ApiServerService.kt # Foreground service
|
||||
└── ui/
|
||||
└── MainActivity.kt # Server controls & dashboard
|
||||
```
|
||||
|
||||
## Disclaimer
|
||||
|
||||
> This project is provided for **educational and experimental purposes only**.
|
||||
>
|
||||
> The Gemini Nano model is accessed through the ML Kit GenAI API, which is subject to [Google's ML Kit Terms of Service](https://developers.google.com/ml-kit/terms) and the [GenAI API Additional Terms](https://developers.google.com/ml-kit/genai-terms). Exposing on-device models as a network API may not be a documented use case under those terms. Users are responsible for reviewing and complying with all applicable terms of service.
|
||||
>
|
||||
> This project is not affiliated with, endorsed by, or sponsored by Google.
|
||||
|
||||
## Dependencies
|
||||
|
||||
| Library | License |
|
||||
|---------|---------|
|
||||
| [ML Kit GenAI](https://developers.google.com/ml-kit) | Google ToS |
|
||||
| [MediaPipe](https://github.com/google-ai-edge/mediapipe) | Apache 2.0 |
|
||||
| [NanoHTTPD](https://github.com/NanoHttpd/nanohttpd) | BSD 3-Clause |
|
||||
| [Gson](https://github.com/google/gson) | Apache 2.0 |
|
||||
| [AndroidX](https://developer.android.com/jetpack/androidx) | Apache 2.0 |
|
||||
| [Kotlin Coroutines](https://github.com/Kotlin/kotlinx.coroutines) | Apache 2.0 |
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
```
|
||||
Copyright 2025 alexpolo1
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
```
|
||||
|
||||
See [LICENSE](LICENSE) for the full text.
|
||||
|
||||
16
SECURITY.md
Normal file
16
SECURITY.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Security
|
||||
|
||||
## Important
|
||||
|
||||
This app runs an **unauthenticated HTTP server** on your local network. By design, anyone on the same network can send requests to the API. Do not expose this server to the public internet.
|
||||
|
||||
## Reporting Vulnerabilities
|
||||
|
||||
If you discover a security issue, please open a GitHub issue or contact the maintainer directly. Since this is a local-network tool, most security concerns relate to network exposure rather than data handling.
|
||||
|
||||
## Scope
|
||||
|
||||
- The server binds to all network interfaces on the configured port
|
||||
- No authentication or API keys are required
|
||||
- All inference is local — no data is sent to external servers
|
||||
- CORS is permissive (`*`) for local development convenience
|
||||
@@ -21,6 +21,7 @@
|
||||
android:name=".Pixel10AIApp"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
|
||||
19
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
19
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
|
||||
<!-- Gradient-style background: deep blue -->
|
||||
<path
|
||||
android:fillColor="#0D47A1"
|
||||
android:pathData="M0,0h108v108H0z" />
|
||||
|
||||
<!-- Subtle grid pattern for tech feel -->
|
||||
<path
|
||||
android:strokeColor="#1565C0"
|
||||
android:strokeWidth="0.3"
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,18h108M0,36h108M0,54h108M0,72h108M0,90h108M18,0v108M36,0v108M54,0v108M72,0v108M90,0v108" />
|
||||
</vector>
|
||||
71
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
71
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
|
||||
<!-- AI chip body — rounded square centered in safe zone -->
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M38,38h32c2.2,0 4,1.8 4,4v24c0,2.2 -1.8,4 -4,4H38c-2.2,0 -4,-1.8 -4,-4V42c0,-2.2 1.8,-4 4,-4z" />
|
||||
|
||||
<!-- Chip pins — top -->
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="2"
|
||||
android:pathData="M44,34v4M50,34v4M56,34v4M62,34v4" />
|
||||
|
||||
<!-- Chip pins — bottom -->
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="2"
|
||||
android:pathData="M44,70v4M50,70v4M56,70v4M62,70v4" />
|
||||
|
||||
<!-- Chip pins — left -->
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="2"
|
||||
android:pathData="M30,44h4M30,50h4M30,56h4M30,62h4" />
|
||||
|
||||
<!-- Chip pins — right -->
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="2"
|
||||
android:pathData="M74,44h4M74,50h4M74,56h4M74,62h4" />
|
||||
|
||||
<!-- Inner circuit — brain/AI pattern -->
|
||||
<path
|
||||
android:fillColor="#1A73E8"
|
||||
android:pathData="M46,46h16c1.1,0 2,0.9 2,2v12c0,1.1 -0.9,2 -2,2H46c-1.1,0 -2,-0.9 -2,-2V48c0,-1.1 0.9,-2 2,-2z" />
|
||||
|
||||
<!-- Neural network nodes -->
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M50,52a1.5,1.5 0,1 1,0 -0.01zM58,52a1.5,1.5 0,1 1,0 -0.01zM54,56a1.5,1.5 0,1 1,0 -0.01z" />
|
||||
|
||||
<!-- Neural connections -->
|
||||
<path
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="0.8"
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M50,52L54,56M58,52L54,56M50,52L58,52" />
|
||||
|
||||
<!-- Signal waves — right side of chip (API/broadcast) -->
|
||||
<path
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="1.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeLineCap="round"
|
||||
android:pathData="M80,50a6,6 0,0 1,0 8" />
|
||||
<path
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="1.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeLineCap="round"
|
||||
android:pathData="M84,47a10,10 0,0 1,0 14" />
|
||||
</vector>
|
||||
@@ -12,7 +12,7 @@
|
||||
android:id="@+id/tvTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Pixel10 AI Server"
|
||||
android:text="@string/app_title"
|
||||
android:textColor="@color/on_surface"
|
||||
android:textSize="28sp"
|
||||
android:textStyle="bold"
|
||||
@@ -24,7 +24,7 @@
|
||||
android:id="@+id/tvSubtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="On-device AI inference API"
|
||||
android:text="@string/app_subtitle"
|
||||
android:textColor="@color/log_text"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="4dp"
|
||||
@@ -78,7 +78,7 @@
|
||||
android:id="@+id/tvServerUrl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="http://—"
|
||||
android:text="@string/server_url_placeholder"
|
||||
android:textColor="@color/log_text"
|
||||
android:textSize="14sp"
|
||||
android:fontFamily="monospace"
|
||||
@@ -89,7 +89,7 @@
|
||||
android:id="@+id/tvModelStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Model: not loaded"
|
||||
android:text="@string/model_not_loaded"
|
||||
android:textColor="@color/log_text"
|
||||
android:textSize="13sp"
|
||||
android:layout_marginTop="4dp" />
|
||||
@@ -120,7 +120,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Port:"
|
||||
android:text="@string/port_label"
|
||||
android:textColor="@color/on_surface"
|
||||
android:textSize="16sp" />
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="8080"
|
||||
android:text="@string/port_default"
|
||||
android:inputType="number"
|
||||
android:textColor="@color/on_surface"
|
||||
android:backgroundTint="@color/primary"
|
||||
@@ -156,7 +156,7 @@
|
||||
android:id="@+id/tvLogLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Request Log"
|
||||
android:text="@string/request_log_label"
|
||||
android:textColor="@color/on_surface"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
|
||||
6
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
6
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
6
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
6
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/primary" />
|
||||
<foreground android:drawable="@color/on_primary" />
|
||||
</adaptive-icon>
|
||||
@@ -1,17 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Pixel10 AI Server</string>
|
||||
<string name="app_name">Pixel10 AI</string>
|
||||
<string name="app_title">Pixel10 AI Server</string>
|
||||
<string name="app_subtitle">On-device AI inference API</string>
|
||||
|
||||
<!-- Server status -->
|
||||
<string name="server_status_stopped">Server Stopped</string>
|
||||
<string name="server_status_starting">Starting Server…</string>
|
||||
<string name="server_status_starting">Starting Server\u2026</string>
|
||||
<string name="server_status_running">Server Running</string>
|
||||
<string name="server_status_error">Server Error</string>
|
||||
<string name="btn_start">Start Server</string>
|
||||
<string name="btn_stop">Stop Server</string>
|
||||
<string name="model_loading">Loading AI model…</string>
|
||||
<string name="server_url_placeholder">http://\u2014</string>
|
||||
|
||||
<!-- Model status -->
|
||||
<string name="model_loading">Loading AI model\u2026</string>
|
||||
<string name="model_ready">AI model ready</string>
|
||||
<string name="model_error">AI model failed to load</string>
|
||||
<string name="model_not_loaded">Model: not loaded</string>
|
||||
|
||||
<!-- Controls -->
|
||||
<string name="btn_start">Start Server</string>
|
||||
<string name="btn_stop">Stop Server</string>
|
||||
<string name="port_label">Port:</string>
|
||||
<string name="port_default">8080</string>
|
||||
<string name="requests_served">Requests served: %d</string>
|
||||
<string name="request_log_label">Request Log</string>
|
||||
|
||||
<!-- Notification -->
|
||||
<string name="notification_channel_name">AI Server</string>
|
||||
<string name="notification_channel_desc">Pixel10 AI API Server status</string>
|
||||
<string name="notification_channel_desc">Shows when the AI inference server is running</string>
|
||||
<string name="notification_title">Pixel10 AI Server</string>
|
||||
<string name="notification_text">Serving AI inference on port %d</string>
|
||||
<string name="notification_text">Serving on port %d \u2022 Tap to open</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user