<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FoundationModels",
  "identifier" : "/documentation/FoundationModels/ConvertibleFromGeneratedContent/init(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation Models"
    ],
    "preciseIdentifier" : "s:16FoundationModels31ConvertibleFromGeneratedContentPyxAA0eF0VKcfc"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates an instance from content generated by a model.

```
init(_ content: GeneratedContent) throws
```

## Discussion

Conformance to this protocol is provided by the `@Generable` macro.
You can provide a manual implementation to map values onto properties using
different names. To manually initialize your type from generated content,
decode the values as shown below:

```swift
struct Person: ConvertibleFromGeneratedContent {
    var name: String
    var age: Int

    init(_ content: GeneratedContent) {
        self.name = try content.value(forProperty: "firstName")
        self.age = try content.value(forProperty: "ageInYears")
    }
}
```

> Important: If your type also conforms to ``doc://com.apple.foundationmodels/documentation/FoundationModels/ConvertibleToGeneratedContent``,
> it is critical that this implementation be symmetrical with ``doc://com.apple.foundationmodels/documentation/FoundationModels/ConvertibleToGeneratedContent/generatedContent``.

> SeeAlso: `@Generable` macro ``doc://com.apple.foundationmodels/documentation/FoundationModels/Generable(description:)``

---

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)