<!--
{
  "availability" : [
    "iOS: 27.3.0 -",
    "iPadOS: 27.3.0 -",
    "macCatalyst: -",
    "macOS: 27.3.0 -",
    "visionOS: 27.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntents",
  "identifier" : "/documentation/AppIntents/GenerableEntity",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "App Intents"
    ],
    "preciseIdentifier" : "s:10AppIntents15GenerableEntityP"
  },
  "title" : "GenerableEntity"
}
-->

# GenerableEntity

An interface that tells a model it can create an entity and fill in its properties directly.

```
protocol GenerableEntity : TransientAppEntity
```

## Overview

The `GenerableEntity` protocol reduces the friction between a model’s output and your app’s custom types.
The addition of this protocol to an entity type tells the model it can generate instances of the
entity directly, and without using the entity’s query object. During the generation process, the model fills
in the properties of the entity according to the descriptions you provide for each of its properties.

To support this protocol in one of your custom entity types, precede your type declaration with the `@AppEntity` macro
and the [`generable`](/documentation/AppIntents/AppEntityTraits/generable) trait, as shown in the following example. In addition to this macro,
adopt the [`TransientAppEntity`](/documentation/AppIntents/TransientAppEntity) protocol to allow the system to create instances of your entity.

```swift
@AppEntity(.generable)
struct FlightSearch: TransientAppEntity {
    @Property(title: "Origin", description: "IATA code of the departure airport")
    var origin: String

    @Property(title: "Destination", description: "IATA code of the arrival airport")
    var destination: String

    @Property(title: "Date", description: "The day to depart")
    var date: Date
    // ...
}
```

For each declared property, include `title` and `description` parameters with values that the model
can use to map its output to the required value. For example, in the preceding code, the descriptions of the
`origin` and `destination` properties tell the model to fill in the property with an
International Air Transport Association (IATA) code that identifies the airport.

Declare each property of a generable entity as one of the following types:

- A plain value type, such as `Int`, `String`, or `Date`
- An [`AppEnum`](/documentation/AppIntents/AppEnum) type
- Another `GenerableEntity` type
- An array of one of these applicable types

> Important: In an entity that supports the `GenerableEntity` protocol, the compiler reports an error if a
> property contains a nongenerable type.

Generable entities are useful as parameter types for a [`ToolIntent`](/documentation/AppIntents/ToolIntent). In the following example,
a person can invoke the tool with the phrase “Find a business class flight from SFO to JFK next Friday.”
The tool’s one `search` parameter is a `FlightSearch` entity, which is a generable type. The model can create
a `FlightSearch` entity instance directly and fill its properties with values it retrieves from the provided
phrase. It can then call the intent’s [`perform()`](/documentation/AppIntents/AppIntent/perform()) method to deliver the results.

```swift
@AppIntent(.tool)
struct SearchFlights: AppIntent {
    static let title: LocalizedStringResource = "Search Flights"
    static let description = IntentDescription("Finds flights for a route and date.")

    @Parameter(title: "Search", description: "The route and date to search")
    var search: FlightSearch

    func perform() async throws -> some ReturnsValue<[FlightEntity]> {
        .result(value: try await FlightService.search(search))
    }
}
```

> Note: If a tool parameter contains a nongenerable, app-owned entity types, it runs entity
> queries to set the values of those parameters, instead of creating the entities directly.

## Relationships

### Inherits From

[`PersistentlyIdentifiable`](/documentation/AppIntents/PersistentlyIdentifiable)

[`TypeDisplayRepresentable`](/documentation/AppIntents/TypeDisplayRepresentable)

[`CustomLocalizedStringResourceConvertible`](/documentation/Foundation/CustomLocalizedStringResourceConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`InstanceDisplayRepresentable`](/documentation/AppIntents/InstanceDisplayRepresentable)

[`AppValue`](/documentation/AppIntents/AppValue)

[`DisplayRepresentable`](/documentation/AppIntents/DisplayRepresentable)

[`Identifiable`](/documentation/Swift/Identifiable)

[`TransientAppEntity`](/documentation/AppIntents/TransientAppEntity)

[`AppEntity`](/documentation/AppIntents/AppEntity)

---

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)