# Class ModelCache

java.lang.Object
com.codename1.ai.inference.ModelCache

public final class ModelCache extends Object
Downloads large LiteRT models once and exposes the cached file as a `ModelSource`. Small models can instead be packaged directly with `ModelSource.resource(String)`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static AsyncResource<ModelSource>`
  `fetch(String url, String cacheKey)`
  `static AsyncResource<ModelSource>`
  `fetch(String url, String cacheKey, String sha256)`
  Fetches a model into the app-private `ai-models` directory.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### fetch

    public static AsyncResource<ModelSource> fetch(String url, String cacheKey, String sha256)
    Fetches a model into the app-private `ai-models` directory.
    Parameters:
      `url` - HTTPS URL of the model
      `cacheKey` - stable cache name, independent of the URL
      `sha256` - optional lowercase or uppercase SHA-256 hex digest
    Returns:
      asynchronous cached model source

  - ### fetch

    public static AsyncResource<ModelSource> fetch(String url, String cacheKey)