---
title: "init(contentsOf:options:)"
framework: coreai
role: symbol
role_heading: Initializer
path: "coreai/aimodel/init(contentsof:options:)"
---

# init(contentsOf:options:)

Creates an AIModel from a .aimodelor .aimodelc file.

## Declaration

```swift
init(contentsOf modelURL: URL, options: SpecializationOptions = .default) async throws
```

## Parameters

- `modelURL`: The URL of a .aimodel or .aimodelc file.
- `options`: Options for the specialization process.

## Mentioned in

Compiling Core AI models ahead of time Integrating on-device AI models in your app with Core AI Managing model specialization and caching

## Discussion

Discussion This initializer specializes the model if needed, caching the result for future calls. Specializing the model can take a significant amount of time depending on model size and the compute unit types it targets. This initializer always uses the default cache. note: If specializing or loading the model fails.

## See Also

### Creating a model

- [init(resolvingBookmark:)](coreai/aimodel/init(resolvingbookmark:).md)
