Class ModelSession
Configuration
instructions
Array of text instructions to include in session to guide prompt evaluation.
mode
Model mode. Controls active model for the session. Default: onDevice
reasoning Level
A reasoning level supported by the current model in use for the session. The on-device model does not support levels, pcc mode, for example, supports "light", "moderate", and "deep"
temperature
Value between 0.0 and 1.0 indicating the temperature to assign the session. Higher values allow the model to be more creative, but less predictable in generating responses.
tool Sets
Enable or disable tools sets to extend functionality of the model. Only enable tool sets you expect to use, as additional ones impact your token usage.
Default: ["drafts", "editor"]
add Instruction
Add text instruction for the model to the instructions array.
Parameters
- instruction: string
Returns null
add Tool Set
Constructor
constructor
Create new instance.
Returns ModelSession
Staticcreate
Modes
is Available
Check whether ModelSession, as configured, is available for use on the current device. Allows graceful fall back on devices that do not support Foundation Models, or are running older OS versions.
Staticavailable Modes
List all available modes on the device.
Returns modelSessionMode[]
Staticis Available
Check availability of ModelSession a model session mode on the current device. Allows graceful fall back on devices that do not support Foundation Models, or are running older OS versions.
Parameters
- mode: modelSessionMode
Returns boolean
Other
Optionallast Error
If a previous function returned an error, the error description will be available in this property
transcript
A JSON formatted output of the session's current transcript of prompts and responses. Can be useful in troubleshooting.
respond
Get a response from the on-device language model.
Parameters
- prompt: string
Text prompt to submit to the model.
Optionalschema: ModelSessionSchemaOptional schema object to get responses in a structured format. If schema is not passed, responses will be in string format.
Returns object
- prompt: string

Prompt the on-device ModelSession, part of the Foundation Models API introduced in iOS/macOS 27. Requires OS 27 and a device that supports (and has enabled) Apple Intelligence.
The
ModelSessionobject allows working with both on-device and Private Cloud Compute LLM Models, as well as Claude Sonnet and Opus models.For example actions and more details on selection of model modes, see User Guide
Example
Prompting the On-Device LLM