<!--
{
  "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/TextSegmentReplacement",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation Models",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:16FoundationModels38LanguageModelExecutorGenerationChannelV22TextSegmentReplacementV"
  },
  "title" : "LanguageModelExecutorGenerationChannel.TextSegmentReplacement"
}
-->

# LanguageModelExecutorGenerationChannel.TextSegmentReplacement

A replacement for a streaming entry’s current text segment.

```
struct TextSegmentReplacement
```

## Overview

The `tokenCount` is the producer’s count of tokens carried by `content` and
is used by safety or usage accounting to credit the replacement against.

## Topics

### Handling the replacement

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

The replacement text for the entry’s current text segment.

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

The number of tokens the replacement text carries.

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

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

## Relationships

### Conforms To

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

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

---

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)