1. Go to this page and download the library: Download token27/nexus-ai-tokenizer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
token27 / nexus-ai-tokenizer example snippets
use Token27\Tokenizer\Engine\TokenizerEngine;
$text = 'Hello world! This is a test of the token counting library.';
// Automatically resolves 'gpt-4o' to Tiktoken (o200k_base)
$count = TokenizerEngine::for('gpt-4o')->count($text);
echo $count->count(); // 14
echo $count->strategy(); // tiktoken:o200k_base
echo $count->isApproximate() ? 'Yes' : 'No'; // No