<!--
{
  "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/init(contentsOf:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core AI",
      "CoreAI"
    ],
    "preciseIdentifier" : "s:13CoreAIRuntime7AIModelV0A11AIDelegatesE10contentsOf7optionsAC10Foundation3URLV_AD21SpecializationOptionsVtYaKcfc"
  },
  "title" : "init(contentsOf:options:)"
}
-->

# init(contentsOf:options:)

Creates an [`AIModel`](/documentation/CoreAI/AIModel) from a `.aimodel`or `.aimodelc` file.

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

## 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`](/documentation/CoreAI/AIModelCache/default) 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)