Skip to main content

Plugin Selection

Choose the appropriate backend plugin for your model type and format.
val plugin_id: String?  // Backend plugin to use
Available Plugins:
  • "cpu_gpu" - GGUF backend for CPU/GPU/Hexagon NPU (LLM, VLM). Device is selected via device_id + nGpuLayers.
  • "npu" - NPU backend for NEXA format models (LLM, VLM, Embeddings, ASR, CV, Rerank)
  • "whisper_cpp" - Whisper.cpp backend for ASR
  • "tts_cpp" - TTS backend for text-to-speech

Device Selection

Control which hardware device processes your model.
val device_id: String?  // Device to use for the model
Available Values:
  • null - CPU (default)
  • "GPUOpenCL" - GPU acceleration via OpenCL
  • "HTP0" - Qualcomm Hexagon NPU acceleration
Hardware Acceleration with GGUF (plugin_id = "cpu_gpu"):
  • GPU: set device_id = "GPUOpenCL" and set nGpuLayers > 0 in ModelConfig
  • Hexagon NPU (GGML backend): set device_id = "HTP0" and set nGpuLayers > 0 in ModelConfig
If nGpuLayers = 0 (or device_id = null), the model runs on CPU.

LLM Data Structures

LlmCreateInput

data class LlmCreateInput(
    val model_name: String? = null,      // Model name (required for NPU, empty for CPU/GPU)
    val model_path: String,              // Path to model file or folder
    val tokenizer_path: String? = null,  // Optional tokenizer path
    val config: ModelConfig,             // Model configuration
    val plugin_id: String? = null,       // "npu", "cpu_gpu", etc.
    val device_id: String? = null        // null, "GPUOpenCL", "HTP0"
)

ChatMessage

data class ChatMessage(
    val role: String,        // "system", "user", "assistant"
    val content: String      // Message text
)

GenerationConfig

data class GenerationConfig(
    val maxTokens: Int? = null,           // Maximum tokens to generate
    val temperature: Float = 0.7f,        // Sampling temperature
    val topP: Float = 0.9f,              // Nucleus sampling
    val topK: Int = 40,                  // Top-K sampling
    val repeatPenalty: Float = 1.1f,     // Repetition penalty
    val seed: Int = -1                   // Random seed (-1 for random)
)

LlmStreamResult

sealed class LlmStreamResult {
    data class Token(val text: String) : LlmStreamResult()
    object Completed : LlmStreamResult()
    data class Error(val throwable: Throwable) : LlmStreamResult()
}

Multimodal Data Structures

VlmCreateInput

data class VlmCreateInput(
    val model_name: String? = null,            // Model name (required for NPU)
    val model_path: String,                    // Path to VLM model
    val tokenizer_path: String? = null,        // Optional tokenizer path
    val mmproj_path: String? = null,           // Vision projection weights (for GGUF models)
    val config: ModelConfig,                   // Model configuration
    val plugin_id: String? = null,             // "npu" for NPU, "cpu_gpu" for CPU/GPU
    val device_id: String? = null              // null for CPU, "GPUOpenCL" for GPU, "HTP0" for NPU
)

VlmChatMessage

data class VlmChatMessage(
    val role: String,                          // "system", "user", "assistant"
    val contents: List<VlmContent>             // Mixed text/image/audio content
)

VlmContent

data class VlmContent(
    val type: String,                          // "text", "image", "audio"
    val content: String                        // Text or file path
)

Embeddings Data Structures

EmbedderCreateInput

data class EmbedderCreateInput(
    val model_name: String? = null,            // Model name for NPU
    val model_path: String,                    // Path to embedder model
    val tokenizer_path: String? = null,        // Path to tokenizer
    val config: ModelConfig,                   // Model configuration
    val plugin_id: String? = null,             // "npu" for NPU, null for CPU
    val device_id: String? = null              // Device ID (optional)
)

EmbeddingConfig

data class EmbeddingConfig(
    val normalize: Boolean = true              // Normalize embeddings (default: true)
)

ASR Data Structures

AsrCreateInput

data class AsrCreateInput(
    val model_name: String? = null,            // Model name for NPU
    val model_path: String,                    // Path to ASR model
    val config: ModelConfig,                   // Model configuration
    val plugin_id: String? = null,             // "whisper_cpp" for whisper.cpp, "npu" for NPU
    val device_id: String? = null              // Device ID (optional)
)

AsrTranscribeInput

data class AsrTranscribeInput(
    val audioPath: String,                     // Path to audio file (.wav, .mp3, etc.)
    val language: String,                      // Language code: "en", "zh", "es", etc.
    val timestamps: String? = null             // Optional: timestamp format
)

AsrTranscriptionResult

data class AsrTranscriptionResult(
    val result: AsrResult,                     // Transcription result
    val profileData: String                    // Performance metrics
)

TTS Data Structures

TtsCreateInput

data class TtsCreateInput(
    val model_name: String? = null,            // Model name (empty for CPU/GPU)
    val model_path: String,                    // Path to TTS model
    val vocoder_path: String? = null,          // Optional vocoder path
    val config: ModelConfig,                   // Model configuration
    val plugin_id: String? = null,             // "tts_cpp" for TTS backend
    val device_id: String? = null              // Device ID (optional)
)

TtsSynthesizeInput

data class TtsSynthesizeInput(
    val textUtf8: String,                      // Text to synthesize (UTF-8 encoding)
    val config: TtsConfig? = null,             // Optional TTS configuration
    val outputPath: String? = null             // Optional output file path (null for auto-generated)
)

TtsConfig

data class TtsConfig(
    val voice: String? = null,                 // Voice identifier
    val speed: Float = 1.0f,                   // Speech speed (1.0 = normal)
    val seed: Int = -1,                        // Random seed (-1 for random)
    val sampleRate: Int = 22050                // Output sample rate in Hz
)

TtsSynthesizeOutput

data class TtsSynthesizeOutput(
    val outputPath: String,                    // Path to generated audio file
    val profileData: String                    // Performance metrics
)

Rerank Data Structures

RerankerCreateInput

data class RerankerCreateInput(
    val model_name: String? = null,            // Model name for NPU
    val model_path: String,                    // Path to reranker model
    val tokenizer_path: String? = null,        // Path to tokenizer
    val config: ModelConfig,                   // Model configuration
    val plugin_id: String? = null,             // "npu" for NPU, null for CPU
    val device_id: String? = null              // Device ID (optional)
)

RerankConfig

data class RerankConfig(
    val topN: Int? = null                      // Return only top N results (null = all)
)

RerankerResult

data class RerankerResult(
    val scores: FloatArray,                    // Relevance scores (0.0 - 1.0)
    val scoreCount: Int,                       // Number of scores
    val profileData: String                    // Performance metrics
)

Computer Vision Data Structures

CVCreateInput

data class CVCreateInput(
    val model_name: String,                    // Model name: "paddleocr", etc.
    val config: CVModelConfig,                 // CV model configuration
    val plugin_id: String? = null              // "npu" for NPU, "cpu_gpu" for CPU/GPU
)

CVModelConfig

data class CVModelConfig(
    val capabilities: CVCapability,            // OCR, DETECTION, CLASSIFICATION
    val det_model_path: String? = null,        // Detection model path
    val rec_model_path: String? = null,        // Recognition model path
    val char_dict_path: String? = null,        // Character dictionary path
    val qnn_model_folder_path: String? = null, // QNN model folder (NPU)
    val qnn_lib_folder_path: String? = null    // QNN library path (NPU)
)

CVCapability

enum class CVCapability {
    OCR,                                       // Optical Character Recognition
    DETECTION,                                 // Object detection
    CLASSIFICATION                             // Image classification
}

CVResult

data class CVResult(
    val text: String,                          // Recognized text (OCR)
    val confidence: Float,                     // Confidence score (0.0 - 1.0)
    val boundingBox: BoundingBox?,             // Bounding box coordinates
    val label: String?,                        // Class label (classification)
    val score: Float                           // Detection/classification score
)

Need Help?

Join our community to get support, share your projects, and connect with other developers.