Array of text instructions to include in session to guide prompt evaluation.
Model mode. Controls active model for the session. Default: onDevice
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"
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.
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 text instruction for the model to the instructions array.
Create new instance.
StaticcreateCheck 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.
StaticavailableList all available modes on the device.
StaticisCheck 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.
OptionallastIf a previous function returned an error, the error description will be available in this property
A JSON formatted output of the session's current transcript of prompts and responses. Can be useful in troubleshooting.
Get a response from the on-device language model.
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.
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