init
TypeScriptstatic init(): GenerationIDSwift declarationinit()Creates a unique identifier.
struct · iOS 26.0+ · SDK 27.1
struct GenerationIDA unique identifier that is stable for the duration of a response, but not across responses. The framework guarantees a `GenerationID` to be both present and stable when you receive it from a ``LanguageModelSession``. When you create an instance of `GenerationID` there is no guarantee an identifier is present or stable. ```swift @Generable struct Person: Equatable { var id: GenerationID var name: String } struct PeopleView: View { @State private var session = LanguageModelSession() @State private var people = [Person.PartiallyGenerated]() var body: some View { // A person's name changes as the response is generated, // and two people can have the same name, so it is not suitable // for use as an id. // // `GenerationID` receives special treatment and is guaranteed // to be both present and stable. List { ForEach(people) { person in Text("Name: \(person.name)") } } .task { do { for try! await people in stream.streamResponse( to: "Who were the first 3 presidents of the US?", generating: [Person].self ) { withAnimation { self.people = people } } catch { // Handle the thrown error. } } } } ```
static init(): GenerationIDSwift declarationinit()Creates a unique identifier.
No declarations were skipped in this snapshot.