---
title: "specialize(contentsOf:options:cache:cachePolicy:)"
framework: coreai
role: symbol
role_heading: Type Method
path: "coreai/aimodel/specialize(contentsof:options:cache:cachepolicy:)"
---

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

Specializes a model for the current device.

## Declaration

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

## Mentioned in

Managing model specialization and caching

## Return Value

Return Value The model, ready for inference on the current device.

## Discussion

Discussion This method performs specialization on the input .aimodel or .aimodelc, storing the resulting specialized assets in the specified cache. note: If specializing or loading the model fails.
