From 58cb4ed5088c2c25f855fd954bd213476d623d87 Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Sat, 18 Apr 2026 10:17:59 +0700 Subject: [PATCH] feat: recognize OpenRouter :free models as zero-cost MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- includes/providers/class-open-router-pricing.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/providers/class-open-router-pricing.php b/includes/providers/class-open-router-pricing.php index 03ef3f2..89b58e8 100644 --- a/includes/providers/class-open-router-pricing.php +++ b/includes/providers/class-open-router-pricing.php @@ -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.