Tokenize
Basic Usage
int[] tokens = await "Hello, world!"
.Tokenize()
.ExecuteAsync();
Debug.Log($"Token IDs: {string.Join(", ", tokens)}");
Debug.Log($"Token count: {tokens.Length}");Input Types
String Input
int[] tokens = await "Sample text"
.Tokenize()
.ExecuteAsync();Prompt Input
var prompt = new Prompt("Analyze this text");
int[] tokens = await prompt
.Tokenize()
.ExecuteAsync();What Are Tokens?
Token Examples
Unity Integration Examples
Example 1: Token Counter Display
Example 2: Token Inspector
Example 3: Analyze Prompt Efficiency
Tokenization vs Token Counting
Method
Returns
Use Case
Provider Support
OpenAI
Anthropic
Best Practices
✅ Good Practices
❌ Bad Practices
Understanding Token Patterns
Common Patterns
Next Steps
Last updated