<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreAI",
  "identifier" : "/documentation/CoreAI/AIModelCache/model(for:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core AI",
      "CoreAI"
    ],
    "preciseIdentifier" : "s:15CoreAIDelegates12AIModelCacheC5model3for7options0A9AIRuntime0C0VSg10Foundation3URLV_AA21SpecializationOptionsVtKF"
  },
  "title" : "model(for:options:)"
}
-->

# model(for:options:)

Returns a previously specialized model from the cache, if available.

```
final func model(for modelURL: URL, options: SpecializationOptions) throws -> AIModel?
```

## Parameters

`modelURL`

The URL of an `.aimodel` file that you previously specialized.

`options`

The specialization options to match against.

## Return Value

The model if a matching cache entry exists, or `nil` otherwise.

## Discussion

If this cache holds a specialized asset from previously specializing the model at
`modelURL` with the specified `options`, this method loads and returns the model.
This method never performs specialization.

> Throws: If a cache entry was found but the specialized asset failed to load.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)