Skip to main content
← All packages
@taaltreelabs/on-device-llm-androidStable

On-device AI for your Android app.

Connect eligible Android devices to Gemini Nano through Google’s ML Kit GenAI Prompt API. Use the same provider interface, router, and React hooks as the Apple package.

v2.0.0 · Available on npm

WHERE A REQUEST GOESArchitecture overview
01Your appA message. A task. A conversation.
02Your routing policyAvailability, context, and your preferences.
ON DEVICE ↓
Gemini NanoML Kit / AICore on eligible Android devices.
CONFIGURED FALLBACK ↓
Cloud providerAn OpenAI-compatible endpoint.
Cloud fallback sends request content to your configured endpoint. ML Kit also sends usage and performance metrics to Google.
01

Add Android deliberately.

Install the provider separately and add the pinned ML Kit SDK to your app. Google’s native dependencies are not bundled into the provider package.

02

Keep the same interface.

Use the LLMProvider contract, context manager, router, and React hooks from on-device-llm. Choose which providers your app can use.

03

Check the device first.

Read availability and capabilities at runtime. Device eligibility depends on AICore support; the Android provider does not offer structured output or tool calling.

A LOOK AT THE API

A few lines
to begin.

Check the model before you ask it to work. Handle unavailable devices and generation errors in your interface.

API example. Requires the native module in a compatible app build. Add the ML Kit SDK explicitly.

Read the setup guide →
First generation
import { createAndroidProvider } from '@taaltreelabs/on-device-llm-android';

const model = createAndroidProvider();
const availability = await model.availability();

if (availability.available) {
try {
const result = await model.generate({
messages: [{ role: 'user', content: 'Explain why leaves change color.' }],
});
console.log(result.text);
} catch (error) {
// Availability does not guarantee generation will succeed.
console.error('Generation failed', error);
}
} else {
console.log('Model unavailable:', availability.reason);
}

See where it fits.

Review the documented requirements and platform support, then follow a guide for your integration.

Compatibility & limitations →