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

# Prompt

A prompt from a person to the model.

```
struct Prompt
```

## Overview

Prompts can contain content written by you, an outside source, or input directly from people using
your app. You can initialize a `Prompt` from a string literal:

```swift
let prompt = Prompt("What are miniature schnauzers known for?")
```

Use [`PromptBuilder`](/documentation/FoundationModels/PromptBuilder) to dynamically control the prompt’s content based on your app’s state. The
code below shows if the Boolean is `true`, the prompt includes a second line of text:

```swift
let responseShouldRhyme = true
let prompt = Prompt {
    "Answer the following question: Do Siberian Huskies love cold weather?"
    if responseShouldRhyme {
        "Your response MUST rhyme!"
    }
}
```

If your prompt includes input from people, consider wrapping the input in a string template with your
own prompt to better steer the model’s response. For more information on handling inputs in your
prompts, see [Improving the safety of generative model output](/documentation/FoundationModels/improving-the-safety-of-generative-model-output).

Prompting the same session eventually leads to exceeding the context window size. You can recover
from this error by removing entries from the transcript and trying again. For more information on
managing the context window size, see [Managing the context window](/documentation/FoundationModels/managing-the-context-window).

## Topics

### Creating a prompt

[`init(_:)`](/documentation/FoundationModels/Prompt/init(_:))

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

A type that represents a prompt builder.

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

A type whose value can represent a prompt.



---

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)