<!--
{
  "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/LanguageModelSession/DynamicProfile",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Foundation Models",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:16FoundationModels20LanguageModelSessionC14DynamicProfileP"
  },
  "title" : "LanguageModelSession.DynamicProfile"
}
-->

# LanguageModelSession.DynamicProfile

A dynamic profile that contains one or more profiles.

```
protocol DynamicProfile
```

## Overview

A dynamic profile is the top-level coordination layer that manages profiles. It
determines which [`LanguageModelSession.DynamicProfile.Profile`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/Profile) is in an active state and allows a [`LanguageModelSession`](/documentation/FoundationModels/LanguageModelSession)
to switch between entirely different configurations as app state changes. A body
must resolve to a single profile.

[`DynamicInstructions`](/documentation/FoundationModels/DynamicInstructions) declares what content and tools the model sees, and
[`LanguageModelSession.DynamicProfile.Profile`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/Profile) binds that content to how a single configuration runs. That
configuration includes details like the model to use, temperature, reasoning
level, and so on.

```swift
struct PresentationProfile: LanguageModelSession.DynamicProfile {
    // The data source for the profile.
    var isEditingImage = true
    var isEditingAnimation = false

    // Determine which profile to load based on the current state.
    var body: some LanguageModelSession.DynamicProfile {
        if isEditingImage {
            // Use the editing image profile.
        } else if isEditingAnimation {
            // Use the editing animation profile.
        } else {
            // Use the default profile.
        }
    }
}
```

Use [`historyTransform(_:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/historyTransform(_:)) to perform stateless transcript transforms. This
allows you to modify the transcript that’s sent to the model, but doesn’t impact
the global transcript state. For example, the request might only need the last
twenty entries instead of the full transcript:

```swift
Profile {
    // The instructions and tools necessary for the task.
}
.historyTransform { history in
    Array(history.suffix(20))
}
```

## Topics

### Implementing a dynamic profile

[`body`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/body-swift.property)

The content of the dynamic profile.

[`Body`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/Body-swift.associatedtype)

The type of dynamic profile that represent this profile.

[`LanguageModelSession.DynamicProfile.DynamicProfile`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/DynamicProfile)

[`LanguageModelSession.DynamicProfile.Profile`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/Profile)

[`LanguageModelSession.DynamicProfile.SessionProperty`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/SessionProperty)

### Transforming the history

[`historyTransform(_:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/historyTransform(_:))

Applies a transformation to the history prior to invoking the model.

### Observing life cycle modifiers

[`onActivate(perform:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/onActivate(perform:))

Runs an action when this dynamic profile becomes active.

[`onDeactivate(perform:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/onDeactivate(perform:))

Runs an action when this dynamic profile becomes inactive.

[`onPrompt(perform:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/onPrompt(perform:))

Runs an action before the model is invoked for this dynamic profile.

[`onReasoning(perform:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/onReasoning(perform:))

Runs an action whenever this dynamic profile produces reasoning.

[`onResponse(perform:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/onResponse(perform:))

Runs an action after this dynamic profile produces a response.

[`onToolCall(perform:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/onToolCall(perform:))

Runs an action whenever a tool is called within this dynamic profile.

[`onToolOutput(perform:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/onToolOutput(perform:))

Runs an action whenever a tool call output is received within this dynamic profile.

### Applying tool modifiers

[`toolCallingMode(_:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/toolCallingMode(_:))

### Configuring the model

[`model(_:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/model(_:))

Sets the model.

[`temperature(_:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/temperature(_:))

Sets the model temperature.

[`samplingMode(_:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/samplingMode(_:))

Sets the samping mode.

[`reasoningLevel(_:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/reasoningLevel(_:))

Sets the reasoning level.

[`maximumResponseTokens(_:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/maximumResponseTokens(_:))

Sets the maximum response tokens.

[`modifier(_:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/modifier(_:))

Applies a modifier to the dynamic profile.

### Handling the error policy

[`transcriptErrorHandlingPolicy(_:)`](/documentation/FoundationModels/LanguageModelSession/DynamicProfile/transcriptErrorHandlingPolicy(_:))

Sets the policy for managing the transcript when errors occur.



---

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)