---
title: "Modelverse"
sidebar_label: "Modelverse"
description: "Kotlin binding reference: Modelverse."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.modelverse](../index.md)/[Modelverse](index.md)

# Modelverse

[common]\
object [Modelverse](index.md)

The entry of the Modelverse binding: loads the three native libraries in the one order that works, then answers the library's version.

Call [load](load.md) once per process before any other member of this package. It is idempotent: a second call returns at once. The order is the cross-language invariant of the ClikaRT bindings: the runtime library first ([ClikaRt.load](../../io.clika.runtime/ClikaRt/load.md)), then the model library `libClikaRT_modelverse.so`, then this binding's JNI bridge `libclika_modelverse_jni.so`, which resolves the two already-loaded images and never carries a copy of either.

On a desktop JVM the three libraries sit on `java.library.path` (the runtime distribution's `lib/` with the bridge built beside it); on Android an app copies `lib/libClikaRT.so` and `lib/libClikaRT_modelverse.so` from the ClikaRT Android payload into its own `jniLibs/arm64-v8a/`, the AAR of this module bundles the bridge alone, and the entry is `Modelverse.load(context, license)` (the Android file of this package), which pins the cache root first.

## Properties

| Name | Summary |
|---|---|
| [isLoaded](isLoaded.md) | [common]<br>val [isLoaded](isLoaded.md): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>True once [load](load.md) has succeeded in this process. |
| [version](version.md) | [common]<br>val [version](version.md): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>The model library's version string, the same as the runtime's. |

## Functions

| Name | Summary |
|---|---|
| [bench](bench.md) | [common]<br>fun [bench](bench.md)(model: [GenerativeModel](../GenerativeModel/index.md), options: [BenchOptions](../BenchOptions/index.md) = BenchOptions()): [BenchReport](../BenchReport/index.md)<br>The serving-path benchmark over a loaded [model](bench.md), the command line's `bench` verb in process: [options](bench.md)' cells times its concurrency widths, one (cell, width) at a time through the serving pipeline over the model, answered as a [BenchReport](../BenchReport/index.md) (the rows typed, the CSV text the verb prints, the run's configuration document). The call blocks for the sweep, minutes for the command line's default cells on a phone; a chat sent to the model meanwhile waits behind it, and a `close()` of the model waits for the sweep to end (the sweep has no cancel). A setup failure (a closed model, an option the library refuses) throws [ModelverseException](../ModelverseException/index.md); a cell the model's window cannot fit is a [BenchRowStatus.SKIPPED](../BenchRowStatus/SKIPPED/index.md) row and a failed row a [BenchRowStatus.ERROR](../BenchRowStatus/ERROR/index.md) row, never an exception. The measurement runs on the device the model loaded on; the configuration document names it. |
| [check](check.md) | [common]<br>fun [check](check.md)(source: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [CheckOptions](../CheckOptions/index.md) = CheckOptions()): [FitReport](../FitReport/index.md)<br>Does the model [source](check.md) loads as (a hub repo id, a hub URL, a local directory or a `.gguf` file) fit a device, judged from its metadata alone: the command line's `check` verb in process. Nothing is fetched beyond the model's small documents and its file listing, and nothing runs. One [FitVerdict](../FitVerdict/index.md) per device [options](check.md) names (this machine's inventory, one device by its spelling, or the caller's own [FitDevice](../FitDevice/index.md)s: a phone's memory, the budget left for one step), each with the law's terms, the grade, the admitted context and the reason; the report's `table` is the verb's. A source that cannot be read or a device spelling no device matches throws [ModelverseException](../ModelverseException/index.md). |
| [deviceMemory](deviceMemory.md) | [common]<br>fun [deviceMemory](deviceMemory.md)(device: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [DeviceMemory](../DeviceMemory/index.md)<br>A device's memory as the runtime reads it: [device](deviceMemory.md) in the runtime's own spelling (`cpu`, `cuda:0`, `vulkan:0`). A device the runtime cannot read refuses with [ModelverseException](../ModelverseException/index.md). |
| [hardware](hardware.md) | [common]<br>fun [hardware](hardware.md)(): [HardwareReport](../HardwareReport/index.md)<br>The inventory of this machine's compute: the runtime's version, the CPU's cores and every backend with its devices and their memory, what the `devices` command prints. Read fresh on every call. |
| [load](load.md) | [common]<br>fun [load](load.md)(license: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)? = null)<br>Load the runtime, the model library and the bridge, in that order, then read the library's version. [license](load.md) is the runtime's license credential (the `CLIKA1-...` text, or the path of a file holding it), placed for this process before the first model runs; `null` leaves the process environment as it is (the runtime then reads its own variable, or the per-user license file). The credential is handed to the runtime and never logged. A second call is a no-op. |
| [load](../load.md) | [android]<br>@[JvmOverloads](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.jvm/-jvm-overloads/index.html)<br>fun [Modelverse](index.md).[load](../load.md)(context: Context, license: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)? = null)<br>The Android entry: pin the runtime's cache root under the app's cache directory and place [license](../load.md) through [ClikaRtAndroid.load](../../io.clika.runtime/ClikaRtAndroid/load.md), then [Modelverse.load](load.md). One call readies the binding on Android; a second call is a no-op. [license](../load.md) is the runtime's license credential (the `CLIKA1-...` text, or the path of a file holding it); `null` leaves the process environment as it is. |
| [maxContextLength](maxContextLength.md) | [common]<br>fun [maxContextLength](maxContextLength.md)(source: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [CheckOptions](../CheckOptions/index.md) = CheckOptions()): [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)<br>The largest context the one device [options](maxContextLength.md) names can serve [source](maxContextLength.md) at, from the same law: the admitted window of its verdict (the largest rung of the context ladder up to the model's own window, or up to [CheckOptions.maxSeq](../CheckOptions/maxSeq.md) when given, whose need keeps [FitGrade.GOOD](../FitGrade/GOOD/index.md) or better), 0 when no context fits. [options](maxContextLength.md) must judge exactly one device (one [FitDevice](../FitDevice/index.md), or one `device` spelling); more refuses with IllegalArgumentException. |
| [pipeline](pipeline.md) | [common]<br>fun [pipeline](pipeline.md)(task: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), model: [PreTrainedModel](../PreTrainedModel/index.md)): [Pipeline](../Pipeline/index.md)<br>The pipeline of [task](pipeline.md) over an already loaded [model](pipeline.md); a model of another class refuses with IllegalArgumentException.<br>[common]<br>fun [pipeline](pipeline.md)(task: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), source: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [LoadOptions](../LoadOptions/index.md) = LoadOptions(), stageObserver: [StageObserver](../StageObserver/index.md)? = null): [Pipeline](../Pipeline/index.md)<br>The pipeline of [task](pipeline.md) (transformers' task strings: `text-generation`, `automatic-speech-recognition`, `text-to-speech`, `translation`, `image-to-text`, `object-detection`, `depth-estimation`, `image-feature-extraction`, `zero-shot-image-classification`, `feature-extraction`, `text-ranking`, `voice-activity-detection`, `text-to-image`, `text-to-video`, and their aliases) over the model [source](pipeline.md) loads as: a snapshot directory, a hub repo id or a GGUF file, under [options](pipeline.md). [stageObserver](pipeline.md) is installed on the model where its kind reports stages ([GenerativeModel](../GenerativeModel/index.md)); a kind that reports none refuses it. An unknown task refuses with IllegalArgumentException naming the tasks; a task whose handle is not in this binding refuses with [ModelverseException](../ModelverseException/index.md). The pipeline owns the model. |
| [registeredArchitectures](registeredArchitectures.md) | [common]<br>fun [registeredArchitectures](registeredArchitectures.md)(): [Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt;<br>The `architectures[0]` names of every runnable family. |
| [registeredGgufArchitectures](registeredGgufArchitectures.md) | [common]<br>fun [registeredGgufArchitectures](registeredGgufArchitectures.md)(): [Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt;<br>The GGUF architecture names of every runnable family. |
| [registeredModelTypes](registeredModelTypes.md) | [common]<br>fun [registeredModelTypes](registeredModelTypes.md)(): [Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt;<br>The `model_type` values of every runnable family. |
| [registry](registry.md) | [common]<br>fun [registry](registry.md)(): [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[RegisteredFamily](../RegisteredFamily/index.md)&gt;<br>The catalog of registered families, read once and kept. |
| [selfTest](selfTest.md) | [common]<br>fun [selfTest](selfTest.md)(): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>The bridge's own check of the model library: a line naming the families it serves. |
| [serve](serve.md) | [common]<br>fun [serve](serve.md)(model: [GenerativeModel](../GenerativeModel/index.md), options: [ServeOptions](../ServeOptions/index.md) = ServeOptions()): [Server](../Server/index.md)<br>A [Server](../Server/index.md) over a loaded [model](serve.md) under [options](serve.md), not yet listening ([Server.start](../Server/start.md)). The server holds the model: the model's `close()` refuses until the server is closed.<br>[common]<br>fun [serve](serve.md)(task: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), source: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), loadOptions: [LoadOptions](../LoadOptions/index.md) = LoadOptions(), options: [ServeOptions](../ServeOptions/index.md) = ServeOptions()): [Server](../Server/index.md)<br>A [Server](../Server/index.md) over the model [source](serve.md) loads as (through [AutoModel.fromPretrained](../AutoModel/fromPretrained.md) with [task](serve.md), `text-generation` by default), not yet listening. The server owns nothing more than any other: the loaded model is answered through [Server.model](../Server/model.md) and is the caller's to close after the server. |
| [snapshot](snapshot.md) | [common]<br>fun [snapshot](snapshot.md)(source: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [LoadOptions](../LoadOptions/index.md) = LoadOptions(), listener: [DownloadListener](../DownloadListener/index.md)? = null): [Snapshot](../Snapshot/index.md)<br>Download, or find in the cache, the model files of [source](snapshot.md) (a hub repo id, a model-page URL, or a local directory, answered as it is) and say where they rest: the one resolve `clikart-cli fetch` runs. The checkpoint's planning verdict runs first, so an unservable checkpoint refuses before any weight byte moves; the files land in the hub cache ([LoadOptions.cacheDir](../LoadOptions/cacheDir.md), else the hub's own) under [options](snapshot.md)' hub knobs (the revision, the token, the offline switch), a GGUF repository's option through [LoadOptions.weights](../LoadOptions/weights.md) (several options and no pick refuse naming them); the family's companions fetch too, each named in the answer with its outcome. [listener](snapshot.md) hears each file's progress and may stop the download. A later load of [Snapshot.loadPath](../Snapshot/loadPath.md) with `offline = true` runs from the cache alone. Refuses with [ModelverseException](../ModelverseException/index.md) carrying the hub's own code name. |