Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

FoundationModels.SetMaximumResponseTokens

Sets the maximum number of tokens the model is allowed to produce in its response.

Component Version macOS Windows Linux Server iOS SDK
FoundationModels 15.5 ✅ Yes ❌ No ❌ No ❌ No ✅ Yes
MBS( "FoundationModels.SetMaximumResponseTokens"; FoundationModel; maximumResponseTokens )   More

Parameters

Parameter Description Example
FoundationModel The identifier for the model. $model
maximumResponseTokens The maximum response tokens to use.

Result

Returns OK or error.

Description

Sets the maximum number of tokens the model is allowed to produce in its response.

If the model produce `maximumResponseTokens` before it naturally completes its response, the response will be terminated early. No error will be thrown. This property can be used to protect against unexpectedly verbose responses and runaway generations.

If no value is specified, then the model is allowed to produce the longest answer its context size supports. If the response exceeds that limit without terminating, an error will be thrown.

Examples

Set maximum response tokens to 100:

Set Variable [ $r; Value: MBS( "FoundationModels.SetMaximumResponseTokens"; 100 ) ]

See also

This function is free to use.

Created 26th September 2025, last changed 27th September 2025


FoundationModels.Respond - FoundationModels.SetTemperature