Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-llm`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/llm/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Install
Section titled “Install”bun add @capgo/capacitor-llmbunx cap syncImport
Section titled “Import”import { CapgoLLM } from '@capgo/capacitor-llm';API Overview
Section titled “API Overview”createChat
Section titled “createChat”Creates a new chat session
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.createChat();sendMessage
Section titled “sendMessage”Sends a message to the AI in a specific chat session
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.sendMessage({} as { chatId: string; message: string });getReadiness
Section titled “getReadiness”Gets the readiness status of the LLM
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.getReadiness();setModel
Section titled “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({} as ModelOptions);downloadModel
Section titled “downloadModel”Downloads a model from a URL and saves it to the appropriate location
- iOS: Downloads to the app’s documents directory
- Android: Downloads to the app’s files directory
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.downloadModel({} as DownloadModelOptions);Type Reference
Section titled “Type Reference”ModelOptions
Section titled “ModelOptions”Model configuration options.
export interface ModelOptions { /** Model path or "Apple Intelligence" for iOS system model */ path: string; /** Model file type/extension (e.g., "task", "bin", "litertlm"). If not provided, will be extracted from path. */ modelType?: string; /** Maximum number of tokens the model handles */ maxTokens?: number; /** Number of tokens the model considers at each step */ topk?: number; /** Amount of randomness in generation (0.0-1.0) */ temperature?: number; /** Random seed for generation */ randomSeed?: number;}DownloadModelOptions
Section titled “DownloadModelOptions”Options for downloading a model.
export interface DownloadModelOptions { /** URL of the model file to download */ url: string; /** Optional: URL of companion file (e.g., .litertlm for Android) */ companionUrl?: string; /** Optional: Custom filename (defaults to filename from URL) */ filename?: string;}DownloadModelResult
Section titled “DownloadModelResult”Result of model download.
export interface DownloadModelResult { /** Path where the model was saved */ path: string; /** Path where the companion file was saved (if applicable) */ companionPath?: string;}TextFromAiEvent
Section titled “TextFromAiEvent”Event data for text received from AI.
export interface TextFromAiEvent { /** The text content from AI - this is an incremental chunk, not the full text */ text: string; /** The chat session ID */ chatId: string; /** Whether this is a complete chunk (true) or partial streaming data (false) */ isChunk?: boolean;}AiFinishedEvent
Section titled “AiFinishedEvent”Event data for AI completion.
export interface AiFinishedEvent { /** The chat session ID that finished */ chatId: string;}DownloadProgressEvent
Section titled “DownloadProgressEvent”Event data for download progress.
export interface DownloadProgressEvent { /** Percentage of download completed (0-100) */ progress: number; /** Total bytes to download */ totalBytes?: number; /** Bytes downloaded so far */ downloadedBytes?: number;}ReadinessChangeEvent
Section titled “ReadinessChangeEvent”Event data for readiness status changes.
export interface ReadinessChangeEvent { /** The readiness status */ readiness: string;}Source Of Truth
Section titled “Source Of Truth”This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.