<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLModel/init(contentsOf:configuration:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core ML"
    ],
    "preciseIdentifier" : "c:objc(cs)MLModel(cm)modelWithContentsOfURL:configuration:error:"
  },
  "title" : "init(contentsOf:configuration:)"
}
-->

# init(contentsOf:configuration:)

Creates a Core ML model instance from a compiled model file and a custom configuration.

```
convenience init(contentsOf url: URL, configuration: MLModelConfiguration) throws
```

## Parameters

`url`

The path to a compiled model file (*ModelName*`.mlmodelc`), typically with the `URL` that [`compileModel(at:)`](/documentation/CoreML/MLModel/compileModel(at:)-6442s) returns.

`configuration`

The runtime settings for the new model instance.

## Discussion

In most cases, your app won’t need to create a model object directly. Consider the programmer-friendly wrapper class that Xcode automatically generates when you add a model to your project (see [Integrating a Core ML Model into Your App](/documentation/CoreML/integrating-a-core-ml-model-into-your-app)).

If the wrapper class doesn’t meet your app’s needs or you need to customize the model’s configuration, use this initializer to create a model object from any compiled model file you can access. Typically, you use this initializer after your app has downloaded and compiled a model, which is one technique for saving space in your app (see [Downloading and Compiling a Model on the User’s Device](/documentation/CoreML/downloading-and-compiling-a-model-on-the-user-s-device)).

---

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)