<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FoundationModels",
  "identifier" : "/documentation/FoundationModels/LanguageModelExecutorGenerationChannel/TextFragment",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation Models",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:16FoundationModels38LanguageModelExecutorGenerationChannelV12TextFragmentV"
  },
  "title" : "LanguageModelExecutorGenerationChannel.TextFragment"
}
-->

# LanguageModelExecutorGenerationChannel.TextFragment

Text appended to a streaming entry’s current text segment.

```
struct TextFragment
```

## Overview

Use this type when appending text with [`LanguageModelExecutorGenerationChannel.Response`](/documentation/FoundationModels/LanguageModelExecutorGenerationChannel/Response) and [`LanguageModelExecutorGenerationChannel.Reasoning`](/documentation/FoundationModels/LanguageModelExecutorGenerationChannel/Reasoning) actions.

## Topics

### Handling the text fragment

[`var content: String`](/documentation/FoundationModels/LanguageModelExecutorGenerationChannel/TextFragment/content)

The text to append to the entry’s current text segment.

[`var tokenCount: Int`](/documentation/FoundationModels/LanguageModelExecutorGenerationChannel/TextFragment/tokenCount)

The number of tokens the text carries.

[`var segmentID: String?`](/documentation/FoundationModels/LanguageModelExecutorGenerationChannel/TextFragment/segmentID)

The identifier of the text segment to append to, or empty to append to the
current segment.

## Relationships

### Conforms To

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

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

---

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)