PHP code example of deus-global / deus-ai-token-fee-guru
1. Go to this page and download the library: Download deus-global/deus-ai-token-fee-guru 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/ */
deus-global / deus-ai-token-fee-guru example snippets
use function DeusGlobal\TokenFeeGuru\calculate_tokens;
use function DeusGlobal\TokenFeeGuru\format_cost;
// Quick calculation
$result = calculate_tokens('gpt-5-mini', 1000, 500, 0.1);
echo format_cost($result['cost_breakdown']['total_cost_for_all_users']);
$client = new Client();
// Use newly added models
$result = $client
->setModel('claude-3-5-sonnet-20241022')
->setInputTokens(1000)
->setOutputTokens(500)
->calculate();
// Compare across different vendors
$comparison = $client
->compareModels([
'gpt-5-mini',
'claude-3-5-sonnet-20241022',
'gemini-1.5-pro'
]);
// Load custom pricing data from different location
$client = new Client([
'pricing_table_path' => '/path/to/your/custom_pricing.csv'
]);
// Or via CLI
./vendor/bin/deus-token-calculator --pricing-table-path=/path/to/custom_pricing.csv --list-available-models
// Custom data source
class ApiDataSource implements DataSourceInterface {
// Implementation...
}
// Custom calculator
class AdvancedCalculator implements CalculatorInterface {
// Implementation...
}
// Usage
$client = new Client([
'data_source' => new ApiDataSource(),
'calculator' => new AdvancedCalculator(),
]);
bash
# Run usage examples
composer examples
# Test model extension functionality
php test_extension.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.