- Any-LLM Gateway setup with Docker Compose - Laravel 11 admin interface with Livewire - Dashboard with usage statistics and charts - Gateway Users management with budget tracking - API Keys management with revocation - Budget templates with assignment - Usage Logs with filtering and CSV export - Model Pricing management with calculator - PostgreSQL database integration - Complete authentication system for admins
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ModelPricing extends Model
|
|
{
|
|
protected $table = 'model_pricing';
|
|
protected $primaryKey = 'model_key';
|
|
public $incrementing = false;
|
|
protected $keyType = 'string';
|
|
|
|
protected $fillable = [
|
|
'model_key',
|
|
'input_price_per_million',
|
|
'output_price_per_million',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'input_price_per_million' => 'double',
|
|
'output_price_per_million' => 'double',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
// Accessors
|
|
public function getInputPriceFormattedAttribute()
|
|
{
|
|
return '$' . number_format($this->input_price_per_million, 2) . '/M';
|
|
}
|
|
|
|
public function getOutputPriceFormattedAttribute()
|
|
{
|
|
return '$' . number_format($this->output_price_per_million, 2) . '/M';
|
|
}
|
|
|
|
/**
|
|
* Calculate cost for given token counts
|
|
*/
|
|
public function calculateCost($inputTokens, $outputTokens)
|
|
{
|
|
$inputCost = ($inputTokens / 1000000) * $this->input_price_per_million;
|
|
$outputCost = ($outputTokens / 1000000) * $this->output_price_per_million;
|
|
|
|
return $inputCost + $outputCost;
|
|
}
|
|
}
|