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

# DynamicInstructions

A type that represents dynamic instructions.

```
protocol DynamicInstructions
```

## Overview

Dynamic instructions provide a declarative approach to assembling instructions
and tools that a [`LanguageModelSession`](/documentation/FoundationModels/LanguageModelSession) uses. The framework evaluates them
before every request to the model, so the body can contain conditional logic
that’s based on current app state.

```swift
struct PresentationInstructions: DynamicInstructions {
    // The data source for conditional instructions.
    var isEditingImage = true

    var body: some DynamicInstructions {
        // The instructions and tools that remain the same across any use of this type.
        Instructions {
            "Help people improve their presentation."
        }
        ListPhotosTool()
        AddPhotoTool()

        // Depending on the state of the app, include additional instructions
        // that provide the model with more task-specific instructions and tools.
        if isEditingImage {
            ImageEditingInstructions()
        }
    }
}
```

## Topics

### Implementing dynamic instructions

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

The content of the dynamic instructions.

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

The type of dynamic instructions that represent these instructions.

[`DynamicInstructions.ForEach`](/documentation/FoundationModels/DynamicInstructions/ForEach)

[`DynamicInstructions.SessionProperty`](/documentation/FoundationModels/DynamicInstructions/SessionProperty)

### Building dynamic instructions

[`DynamicInstructionsBuilder`](/documentation/FoundationModels/DynamicInstructionsBuilder)

[`EmptyDynamicInstructions`](/documentation/FoundationModels/EmptyDynamicInstructions)

An empty dynamic instructions type.

[`ConditionalDynamicInstructions`](/documentation/FoundationModels/ConditionalDynamicInstructions)

A dynamic instructions type that conditionally selects between two conditions.

[`AnyDynamicInstructions`](/documentation/FoundationModels/AnyDynamicInstructions)

A dynamic instructions type that’s type-erased.

[`TupleDynamicInstructions`](/documentation/FoundationModels/TupleDynamicInstructions)

A dynamic instructions type that represents a tuple.



---

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)