1. Go to this page and download the library: Download token27/nexus-ai-pricing 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-pricing example snippets
use Token27\NexusAI\Pricing\Engine\PricingEngine;
$result = PricingEngine::for('claude-sonnet-4-6')->calculate(
inputTokens: 250,
outputTokens: 400,
cacheWriteTokens: 800, // Anthropic 5-minute surcharge
cacheReadTokens: 5000 // 90% discounted block
);
echo $result->totalCostUsd(); // Output standard metrics seamlessly
echo $result->cacheSavingsUsd(); // Output exactly what was saved against baselines
// Processes offline immediately avoiding Network HTTP limits
$estimated = PricingEngine::for('gpt-4o-mini')
->estimate('Generate a dense historical assessment regarding the Roman Empire.');
echo $estimated->format();