<!--
{
  "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/AIModel/specialize(contentsOf:options:cache:cachePolicy:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core AI",
      "CoreAI"
    ],
    "preciseIdentifier" : "s:13CoreAIRuntime7AIModelV0A11AIDelegatesE10specialize10contentsOf7options5cache0I6PolicyAC10Foundation3URLV_AD21SpecializationOptionsVAD0C5CacheCAP0J0VtYaKFZ"
  },
  "title" : "specialize(contentsOf:options:cache:cachePolicy:)"
}
-->

# specialize(contentsOf:options:cache:cachePolicy:)

Specializes a model for the current device.

```
@discardableResult static func specialize(contentsOf modelURL: URL, options: SpecializationOptions = .default, cache: AIModelCache = .default, cachePolicy: AIModelCache.Policy = .default) async throws -> AIModel
```

## Parameters

`modelURL`

The URL of a `.aimodel` or `.aimodelc` file.

`options`

Options for the specialization process.

`cache`

The cache to store the resulting specialized asset in.

`cachePolicy`

The policy to apply to the resulting specialized asset.

## Return Value

The model, ready for inference on the current device.

## Discussion

This method performs specialization on the input `.aimodel` or `.aimodelc`, storing the resulting specialized
assets in the specified cache.

> Throws: If specializing or loading the model fails.

---

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)