<!--
{
  "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/Reasoning/Action-swift.struct/replaceTextSegment(_:segmentID:tokenCount:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation Models",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:16FoundationModels38LanguageModelExecutorGenerationChannelV9ReasoningV6ActionV18replaceTextSegment_9segmentID10tokenCountAGSS_SSSgSitFZ"
  },
  "title" : "replaceTextSegment(_:segmentID:tokenCount:)"
}
-->

# replaceTextSegment(_:segmentID:tokenCount:)

Creates an action that replaces the entry’s current text segment.

```
static func replaceTextSegment(_ text: String, segmentID: String? = nil, tokenCount: Int) -> LanguageModelExecutorGenerationChannel.Reasoning.Action
```

## Parameters

`text`

The replacement text for the segment.

`segmentID`

The identifier of the segment to replace, or `nil` for the current
segment.

`tokenCount`

The number of the tokens the replacement text carries.

---

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)