<?php
 namespace App\AI\SymfonyAiExtend\Claude; use Symfony\AI\Platform\Bridge\Anthropic\Claude; use Symfony\AI\Platform\Bridge\Anthropic\ModelCatalog as AnthropicModelCatalog; use Symfony\AI\Platform\Capability; final class ModelCatalog { private const SYSTEM_ROLE_TURNS = [ 'claude-opus-4-8', 'claude-fable-5', ]; private const NO_TOOL_CHOICE_TOOL = [ 'claude-fable-5', ]; public static function supportsToolChoiceTool(string $model): bool { return !in_array($model, self::NO_TOOL_CHOICE_TOOL, true); } public static function supportsSystemRoleTurns(string $model): bool { return in_array($model, self::SYSTEM_ROLE_TURNS, true); } public static function create(): AnthropicModelCatalog { return new AnthropicModelCatalog([ 'claude-opus-4-8' => [ 'class' => Claude::class, 'capabilities' => [ Capability::INPUT_MESSAGES, Capability::INPUT_IMAGE, Capability::INPUT_PDF, Capability::OUTPUT_TEXT, Capability::OUTPUT_STREAMING, Capability::OUTPUT_STRUCTURED, Capability::THINKING, Capability::TOOL_CALLING, ], ], 'claude-fable-5' => [ 'class' => Claude::class, 'capabilities' => [ Capability::INPUT_MESSAGES, Capability::INPUT_IMAGE, Capability::INPUT_PDF, Capability::OUTPUT_TEXT, Capability::OUTPUT_STREAMING, Capability::OUTPUT_STRUCTURED, Capability::THINKING, Capability::TOOL_CALLING, ], ], ]); } private const PRICING = [ 'claude-fable-5' => [ 'input' => 10.00, 'output' => 50.00, 'cache_write' => 12.50, 'cache_read' => 1.00, ], 'claude-opus-4-8' => [ 'input' => 5.00, 'output' => 25.00, 'cache_write' => 6.25, 'cache_read' => 0.50, ], 'claude-sonnet-4-6' => [ 'input' => 3.00, 'output' => 15.00, 'cache_write' => 3.75, 'cache_read' => 0.30, ], 'claude-haiku-4-5-20251001' => [ 'input' => 1.00, 'output' => 5.00, 'cache_write' => 1.25, 'cache_read' => 0.10, ], ]; public static function getPricing(string $model): ?array { return self::PRICING[$model] ?? null; } public static function calculateCost(string $model, int $inputTokens, int $outputTokens, int $cachedTokens): ?float { $pricing = self::getPricing($model); $cost = ($inputTokens / 1000000) * $pricing['input'] + ($outputTokens / 1000000) * $pricing['output'] + ($cachedTokens / 1000000) * $pricing['cache_read']; return round($cost, 3); } }