Platforms to show: All Mac Windows Linux Cross-Platform
Back to LanguageModelSessionsMBS class.
LanguageModelSessionsMBS.Constructor(Model as SystemLanguageModelsMBS = nil, Instructions as InstructionsMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
model: The language model to use for this session.
instructions: Instructions that control the model's behavior.
See also:
LanguageModelSessionsMBS.Constructor(Model as SystemLanguageModelsMBS = nil, Instructions as String)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
model: The language model to use for this session.
instructions: Instructions that control the model's behavior.
See also:
LanguageModelSessionsMBS.Constructor(Model as SystemLanguageModelsMBS = nil, Transcript as TranscriptMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
model: The language model to use for this session.
transcript: A transcript to resume from.
See also:
LanguageModelSessionsMBS.prewarm(Prompt as PromptMBS = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
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 1s before the call to respond.
Note: 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.
LanguageModelSessionsMBS.respond(prompt as PromptMBS) as ResponseMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
prompt: A prompt for the model to respond to.
We wait for the answer and return it.
If temperature >= 0 or maximumResponseTokens >= 0, we pass these as options.
See also:
- respond(prompt as PromptMBS, theDelegate as ResponseCompletedMBS, tag as Variant = nil)
- respond(prompt as String) as String
- respond(prompt as String, theDelegate as ResponseCompletedMBS, tag as Variant = nil)
Some examples using this method:
LanguageModelSessionsMBS.respond(prompt as PromptMBS, theDelegate as ResponseCompletedMBS, tag as Variant = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
prompt: A prompt for the model to respond to.
We call the delegate later to report result and pass through tag value.
If temperature >= 0 or maximumResponseTokens >= 0, we pass these as options.
See also:
LanguageModelSessionsMBS.respond(prompt as String) as String
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
prompt: A prompt for the model to respond to.
We wait for the answer and return it.
If temperature >= 0 or maximumResponseTokens >= 0, we pass these as options.
See also:
LanguageModelSessionsMBS.respond(prompt as String, theDelegate as ResponseCompletedMBS, tag as Variant = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
prompt: A prompt for the model to respond to.
We call the delegate later to report result and pass through tag value.
If temperature >= 0 or maximumResponseTokens >= 0, we pass these as options.
See also:
LanguageModelSessionsMBS.tokenCount(prompt as PromptMBS) as Integer New in 26.2
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 26.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
New for macOS/iOS 26.4 or newer.
See also:
LanguageModelSessionsMBS.tokenCount(prompt as PromptMBS, theDelegate as TokenCountCompletedMBS, tag as Variant = nil) New in 26.2
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 26.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
New for macOS/iOS 26.4 or newer.
See also:
LanguageModelSessionsMBS.tokenCount(prompt as String) as Integer New in 26.2
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 26.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
New for macOS/iOS 26.4 or newer.
See also:
LanguageModelSessionsMBS.tokenCount(prompt as String, theDelegate as TokenCountCompletedMBS, tag as Variant = nil) New in 26.2
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 26.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Calls TokenCountCompletedMBS event later.
New for macOS/iOS 26.4 or newer.
See also:
LanguageModelSessionsMBS.transcript as TranscriptMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Foundation Models | MBS Swift Plugin | 25.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Some examples using this method:
The items on this page are in the following plugins: MBS Swift Plugin.