Installation & Setup Guide

Zero-Dependency Deployment, Environment Diagnostics & Local Engine Provisioning (Termux-AIChain)

WHY NOT LANGCHAIN ON MOBILE?

The Android Bionic Compilation Barrier

Attempting to run pip install langchain on Android Termux triggers an avalanche of 48+ dependencies. Packages like pydantic-core, tiktoken, and chromadb do not publish prebuilt wheels for the Android Bionic C runtime. Users face grueling C++/Rust build failures, broken shared library links, and Out-Of-Memory compilation crashes.

termux-aichain eliminates this completely: It has zero external dependencies and is implemented strictly using the Python standard library and Node.js standard modules. No compiler is ever required.

1-Step Zero-Dependency Installation

Install the package instantly with zero external compilation overhead:

# Python 3.10+ (Termux or Linux):
pip install --upgrade termux-aichain

# Node.js 18+ ESM (Termux or Linux):
npm install termux-aichain

System Prerequisites & Optional Tool Bindings

Subsystem / Package Type Necessity Technical Purpose
python (3.10 ~ 3.14) Runtime Required Host interpreter for LCEL pipe execution, StateGraph, and SQLite vector store.
nodejs (18.x ~ 26.x) Runtime Optional Required only if running the Node.js / TypeScript ESM agent pipeline.
termux-api (APK + pkg) System Tool Recommended Required for smartphone hardware tools (battery probe, GPS, haptics, notifications).
llama-server / BitNet Inference Engine Recommended Local OpenAI-compatible inference server running on 127.0.0.1:8080.

Termux Hardware API Provisioning

To enable direct smartphone actuation (battery percentage, device temperature, vibration, GPS, notifications), install the Termux-API bridge:

# 1. Update Termux package mirrors
pkg update -y

# 2. Install the Termux-API CLI helper
pkg install -y termux-api

# 3. Ensure the companion Termux:API Android APK is installed from F-Droid or GitHub Releases.

Automated Environment Diagnostics CLI

termux-aichain includes built-in diagnostic tools to verify the mobile environment in one command:

# Run end-to-end environment verification
termux-aichain setup

# Print installed version, Python runtime, and detected toolchain
termux-aichain info

Example diagnostic output on Samsung Galaxy S25:

[AIChain Diagnostics]
  * Python Runtime       : 3.13.13 (ARM64 Bionic) [OK]
  * Node.js Runtime      : v26.3.1 (ARM64)        [OK]
  * Termux:API Bridge    : Functional             [OK]
  * SQLite3 Kernel       : 3.46.1 (Vector Ready)  [OK]
  * Ecosystem Hooks      : 6/6 Active             [OK]
[Status] System ready for sovereign edge agent orchestration.

Connecting Local Inference Backends

Launch your local ARM64 llama-server with optimal thread allocation (e.g. 8 threads for Snapdragon 8 Elite / Oryon CPU):

# Launch llama-server on port 8080
llama-server \
  -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf \
  -c 2048 \
  -t 8 \
  --port 8080 \
  --chat-template llama3

Instant Verification Script

from termux_aichain import LocalAgent

# Verify connection to local llama-server
agent = LocalAgent.local(model="llama3")
print(agent.run("Respond with 'READY' to confirm operational status."))
# Output: READY

Next Steps