| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
FoundationModels.TokenCount
Returns the token count for the specified instructions.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| FoundationModels | 16.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |
MBS( "FoundationModels.TokenCount"; FoundationModel ) More
Parameters
| Parameter | Description | Example |
|---|---|---|
| FoundationModel | The identifier for the model. | $model |
Result
Returns number or error.
Description
Returns the token count for the specified instructions.Examples
Queries token count:
Set Variable [ $text ; Value: "Hello World." ]
Set Variable [ $tokencount ; Value: MBS("FoundationModels.TokenCount"; $$session; $Text) ]
#
Show Custom Dialog [ "Token Count" ; $tokencount ]
Example result: 11
Set Variable [ $tokencount ; Value: MBS("FoundationModels.TokenCount"; $$session; $Text) ]
#
Show Custom Dialog [ "Token Count" ; $tokencount ]
Example result: 11
See also
Release notes
- Version 16.2
- Added FoundationModels.ContextSize and FoundationModels.TokenCount functions for macOS/iOS 26.4.
Example Databases
Blog Entries
This function checks for a license.
Created 10th April 2026, last changed 11st April 2026
FoundationModels.SupportsLocale - FoundationModels.Transcript