feat: recognize OpenRouter :free models as zero-cost
Models with the :free suffix (e.g. google/gemini-2.5-flash-preview:free) are served at no charge by OpenRouter. The cost estimator now returns $0.00 for these models instead of falling through to the conservative $10/$30 per-million-token fallback. No changes needed in the model picker or provider — :free models use the same API endpoint and already appear in the registry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -114,6 +114,11 @@ class PRAutoBlogger_OpenRouter_Pricing {
|
||||
* @return float Estimated cost in USD.
|
||||
*/
|
||||
public function estimate_cost( string $model, int $prompt_tokens, int $completion_tokens ): float {
|
||||
// OpenRouter `:free` suffix models cost nothing.
|
||||
if ( ':free' === substr( $model, -5 ) ) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
$pricing = self::MODEL_PRICING[ $model ] ?? null;
|
||||
|
||||
// Fall back to cached model list pricing.
|
||||
|
||||
Reference in New Issue
Block a user