Skip to main content
@capgo/capacitor-llm Device APIs Open source

LLM Capacitor plugin

Run Large Language Models locally on-device with Apple Intelligence and MLX support

Install

bun add @capgo/capacitor-llm bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-llm
  • pnpm add @capgo/capacitor-llm
  • yarn add @capgo/capacitor-llm

Guide

How to use LLM in Capacitor

Test on device

Download the Capgo app, then scan the QR code.

LLM plugin preview QR code

Using @capgo/capacitor-llm

LLM Plugin interface for interacting with on-device language models.

Install

bun add @capgo/capacitor-llm
bunx cap sync

What This Plugin Exposes

  • createChat - Creates a new chat session.
  • sendMessage - Sends a message to the AI in a specific chat session.
  • getReadiness - Gets the readiness status of the LLM.
  • setModel - Sets the model configuration - iOS: Use "Apple Intelligence" as path for system model, or provide path to MediaPipe model - Android: Path to a MediaPipe model file (in assets or files directory).

Example Usage

createChat

Creates a new chat session.

import { CapgoLLM } from '@capgo/capacitor-llm';

const result = await CapgoLLM.createChat();
console.log(result);

sendMessage

Sends a message to the AI in a specific chat session.

import { CapgoLLM } from '@capgo/capacitor-llm';

await CapgoLLM.sendMessage({
  chatId: 'chat-id-123',
  message: 'Hello from Capacitor',
});

getReadiness

Gets the readiness status of the LLM.

import { CapgoLLM } from '@capgo/capacitor-llm';

const result = await CapgoLLM.getReadiness();
console.log(result);

setModel

Sets the model configuration - iOS: Use "Apple Intelligence" as path for system model, or provide path to MediaPipe model - Android: Path to a MediaPipe model file (in assets or files directory).

import { CapgoLLM } from '@capgo/capacitor-llm';

await CapgoLLM.setModel({
  path: 'path/to/file',
  modelType: 'task',
});

Full Reference

Keep going from Using @capgo/capacitor-llm

If you are using Using @capgo/capacitor-llm to plan dashboard and API operations, connect it with @capgo/capacitor-llm for the implementation detail in @capgo/capacitor-llm, Getting Started for the implementation detail in Getting Started, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, and API Keys for the implementation detail in API Keys.

FAQ

LLM plugin FAQ

How do I install the LLM plugin in a Capacitor app?

Run "bun add @capgo/capacitor-llm" (or "npm install @capgo/capacitor-llm"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-llm" in your app code.

Does @capgo/capacitor-llm work with React, Vue and Angular?

Yes. LLM is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-llm support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-llm free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-llm/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses LLM without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship LLM changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo