Portable, offline local AI for Windows, macOS, Linux, and ARM64 Android. The same GGUF model is shared by every platform; each operating system uses its own llama.cpp runtime.
The model is not included in this repository. Add your own compatible GGUF to
LocalAI/models/before starting LocalAI.
- Offline llama.cpp web interface with local coding-agent tools
- Windows x64 and ARM64 runtimes
- macOS Apple Silicon and Intel runtimes
- Linux x64 and ARM64 CPU/Vulkan runtimes
- Android ARM64 runtime and Termux agent bridge
- Automatic GGUF model selection
- Configurable context size and desktop GPU acceleration
- Desktop and Android start/stop launchers
- llama.cpp build b10516
No account or cloud API is required. The local interface listens only on
127.0.0.1.
- Add a model
- Windows
- macOS
- Linux
- Redmi and Android with Termux
- Agent tools and permissions
- Model features
- Privacy and safety
Place one or more llama.cpp-compatible GGUF files in:
LocalAI/models/
Do not create separate model copies for Windows, macOS, Linux, or Android.
When there is one primary GGUF, it is selected automatically. When there are several, write the preferred filename or relative path on the first line of:
LocalAI/models/default-model.txt
Example:
qwen3-8b-q4_K_M.gguf
If the preference is missing or stale, the launchers select another usable
primary GGUF. Files beginning with mmproj and secondary split-model shards
are not selected as the main model.
For a vision model, place its matching mmproj file beside the main GGUF.
- Connect the USB.
- Open the USB in File Explorer.
- Double-click
START AI.bat. - Wait for
LOCAL AI READYand the browser to open. - Chat at the local page. No API key is required.
- Before ejecting the USB, double-click
STOP AI.bat.
The launcher selects Windows x64 or ARM64 automatically. GPU acceleration can be changed with the included GPU settings launcher. CPU mode remains available for maximum compatibility.
For terminal chat, run LocalCLI.bat.
- Connect the USB.
- Open
START AI.command. - Wait for
LOCAL AI READYand the browser to open. - Before ejecting, run
STOP AI.command.
If macOS blocks the launcher, use Finder's Open action or allow it through the normal Privacy & Security prompt. Do not disable or bypass Gatekeeper.
For terminal chat, run LocalCLI.command.
From a terminal in the USB root, run:
bash "START AI.sh"Stop it before ejecting:
bash "STOP AI.sh"For terminal chat:
bash LocalCLI.shThe launcher handles exFAT executable-bit limitations and reads the model directly from the USB.
This section is the complete user guide for Redmi/HyperOS and other compatible ARM64 Android devices. A plain Android phone cannot execute the Windows, macOS, or ordinary Linux launchers.
The detailed offline text copy is also available as
ANDROID REDMI GUIDE.txt.
- ARM64 Android device;
uname -min Termux must showaarch64orarm64 - USB OTG support and a reliable adapter
- Ability to read the exFAT USB
- At least 8 GB RAM; 12 GB or more is preferred for an 8B Q4 model
- Several hundred MB of free internal storage
- Termux from the official F-Droid package or Termux GitHub project
- No root is required
The small Android runtime, agent bridge, and web interface use approximately 123 MB in Termux-private storage. The multi-gigabyte GGUF remains on the USB.
Press Cancel. Never format, erase, or adopt the LocalAI USB as internal storage.
Try these steps:
- Disconnect and reconnect the OTG adapter while the Redmi is unlocked.
- Open the Xiaomi/Android Files app and look for the USB.
- Try another known-good OTG adapter or powered hub.
- Restart the phone and reconnect the USB.
- Test the USB on a computer to confirm that its files remain readable.
Open Termux and run these commands while online:
pkg update
pkg install curl
termux-setup-storageApprove the Files/Media permission. On Redmi/HyperOS, settings are commonly under:
Settings > Apps > Manage apps > Termux > App permissions > Files and media
Settings > Apps > Manage apps > Termux > Battery saver > No restrictions
Menu names vary by HyperOS version. After changing permissions, close and reopen Termux.
Confirm the architecture:
uname -mContinue only if the result is aarch64 or arm64.
Android usually identifies a removable volume with an ID such as 1234-ABCD,
not the USB label. Do not type XXXX-XXXX literally.
Run:
ls -la /storage
find /storage -maxdepth 4 -type f -iname '*.gguf' 2>/dev/nullA working result resembles:
/storage/1234-ABCD/LocalAI/models/qwen3-8b-q4_K_M.gguf
The USB root in that example is /storage/1234-ABCD.
Some devices also expose /mnt/media_rw/ID, but permission denied there is
normal on many non-rooted phones. Prefer a readable /storage/ID path.
Replace 1234-ABCD with the actual ID shown on the Redmi:
bash "/storage/1234-ABCD/LocalAI/android/setup-termux.sh"Successful setup reports:
LocalAI Termux runtime and agent bridge installed.
The GGUF model was NOT copied; it remains on the USB.
Start with: ~/localai-start
Confirm the commands were installed:
ls -l ~/localai-start ~/localai-stopAndroid external storage is mounted noexec, so invoke the installer with
bash; do not run ./setup-termux.sh.
If Termux can read the GGUF but cannot read the setup script directly, use the Android Files app to create this temporary folder under Internal storage > Download:
LocalAI-Setup/
LocalAI/
android/ from USB LocalAI/android
android-arm64/ from USB LocalAI/android-arm64
web/ from USB LocalAI/web
runtime/
model-selection.sh from USB LocalAI/runtime/model-selection.sh
Then run:
bash ~/storage/downloads/LocalAI-Setup/LocalAI/android/setup-termux.shThis temporary setup copy is approximately 123 MB and does not contain the model. If Termux cannot read the GGUF itself, this fallback cannot bypass that Android permission limitation.
Every time you use LocalAI:
-
Connect the USB and confirm it appears in the Files app.
-
Open Termux.
-
Run:
~/localai-start -
Keep Termux running while the model loads.
-
Wait for
LOCAL AI READY. -
Use the browser page opened automatically.
-
Before unplugging the USB, run:
~/localai-stop
Wait for It is safe to disconnect the USB before removing it.
Use ~/localai-start so the model and bridge are ready before the browser opens.
It now opens a normal localhost page without an API key or authenticated link.
Automatic selection normally requires no command-line argument. To select one model for the current start:
~/localai-start "/storage/1234-ABCD/LocalAI/models/model-name.gguf"Stop LocalAI before replacing, renaming, or removing a model file.
- 4096 tokens is the safest default for an 8B Q4 model.
- 8192 may work on a 12 GB Redmi, but consumes more RAM and may be slower.
- Close memory-heavy apps before loading the model.
Change context under Settings > General > Context size in the web interface, then restart LocalAI. It can also be set in Termux:
printf '%s\n' 4096 > ~/.localai-usb-context-size- The Android launcher uses the ARM64 CPU runtime for compatibility.
- Set Termux battery usage to No restrictions in HyperOS.
- Do not swipe Termux away while generating.
- Lock Termux in Recent apps if HyperOS offers that option.
- Long generations can heat the phone and cause thermal throttling.
- A powered OTG hub may help if the USB connection is unstable.
- Shorter prompts, responses, and 4096 context use less RAM.
Find the real volume ID again:
find /storage -maxdepth 4 -type f -iname '*.gguf' 2>/dev/nullQuote the complete path and do not type the example ID literally.
Run termux-setup-storage, grant Files/Media permission in HyperOS, fully close
and reopen Termux, then retry. Invoke external scripts with bash.
Confirm the Files app sees the USB and the model is in LocalAI/models/. If
the find command returns nothing, Android is not granting Termux direct USB
access. The launcher will not silently copy the model. Some Android builds make
USB files available only through the Storage Access Framework used by file
managers; ordinary Termux commands cannot bypass that restriction.
Close stale LocalAI tabs and run:
~/localai-startIf LocalAI is already running, this reopens the local page.
Check the local bridge:
curl -s http://127.0.0.1:8080/api/statusPort 8080 is the loopback-only interface. Port 8081 is the private llama-server behind it and is not the chat website. Neither requires an API key.
Use 4096 context, close other apps, enable No restrictions for Termux, and verify that the selected model fits available RAM.
Check the logs:
tail -n 60 ~/.localai-usb/agent-bridge.log
tail -n 80 ~/.localai-usb/llama-server.logThen safely retry:
~/localai-stop
~/localai-startEnable the required tools in the chat and use an instruct model with reliable tool/function-call behavior. Small, base, or incompatible models may ignore tools even when the interface offers them. Start a new chat after changing the model.
After updating the USB files:
- Run
~/localai-stop. - Reconnect the updated USB.
- Run the setup script again from its current
/storage/IDpath.
This refreshes the runtime, bridge, model selector, web UI, and launchers. It does not copy or modify the GGUF.
| Action | Command |
|---|---|
| Grant storage access | termux-setup-storage |
| Find models on USB | find /storage -maxdepth 4 -type f -iname '*.gguf' 2>/dev/null |
| Install | bash "/storage/ID/LocalAI/android/setup-termux.sh" |
| Start | ~/localai-start |
| Start a specific model | ~/localai-start "/storage/ID/LocalAI/models/model.gguf" |
| Stop safely | ~/localai-stop |
| Check status | curl -s http://127.0.0.1:8080/api/status |
| Bridge log | tail -n 60 ~/.localai-usb/agent-bridge.log |
| llama.cpp log | tail -n 80 ~/.localai-usb/llama-server.log |
The interface can expose file reading, searching, writing, editing, and shell commands. Enable the desired tools in the current chat.
- Approval mode shows each operation before it runs.
- Always allow permits enabled tools to operate without asking every time.
Approval mode is recommended for unfamiliar models. Always allow does not grant root or bypass the operating system. Tools run with the permissions of the signed-in desktop user or, on Android, the Termux app.
Features depend on the loaded model:
- Tool calling requires a model that can reliably follow function/tool schemas.
- Images require a vision-capable GGUF and matching
mmprojfile. - A text-only model cannot understand images just because an upload button is visible.
- PDF/DOCX text extraction is an interface feature. Scanned pages need OCR or a vision model.
- Reasoning, coding quality, context length, and multilingual ability depend on the model and available device memory.
- No web-search or cloud tool is bundled by default.
- The model server binds only to
127.0.0.1, never the LAN. - Normal inference is local and offline.
- The API/session key protects the local browser/agent session; it is generated locally and should not be published or reused.
- Agent commands can modify files accessible to the current user. Keep backups and use approval mode when appropriate.
- Always stop LocalAI before ejecting the USB.
AI model files, credentials, logs, caches, and operating-system-generated USB metadata are intentionally excluded. Large runtime files use Git LFS, so a full development clone requires Git LFS:
git lfs install
git clone https://github.com/Patt-00/LocalAI-USB-Interface.gitThe USB stores the model. The connected device's CPU/GPU and RAM perform the AI calculations.