---
title: "model(for:options:)"
framework: coreai
role: symbol
role_heading: Instance Method
path: "coreai/aimodelcache/model(for:options:)"
---

# model(for:options:)

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

## Declaration

```swift
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.

## Mentioned in

Managing model specialization and caching

## Return Value

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

## Discussion

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. note: If a cache entry was found but the specialized asset failed to load.
