---
title: "prewarm(promptPrefix:)"
framework: foundationmodels
role: symbol
role_heading: Instance Method
path: "foundationmodels/languagemodelsession/prewarm(promptprefix:)"
---

# prewarm(promptPrefix:)

Requests that the system eagerly load the resources required for this session into memory and optionally caches a prefix of your prompt.

## Declaration

```swift
final func prewarm(promptPrefix: Prompt? = nil)
```

## Mentioned in

Optimizing key-value caching in language model sessions

## Discussion

Discussion This method can be useful in cases where you have a strong signal that the user will interact with session within a few seconds. For example, you might call prewarm when the user begins typing into a text field. If you know a prefix for the future prompt, passing it to prewarm will allow the system to process the prompt eagerly and reduce latency for the future request. important: You should only use prewarm when you have a window of at least 1 second before the call to a respond method, like respond(to:options:) or streamResponse(to:options:). Calling this method does not guarantee that the system loads your assets immediately, particularly if your app is running in the background or the system is under load.
