fix: recognize openrouter/free router as zero-cost

The free models router (openrouter/free) doesn't use the :free suffix,
so it needs an explicit check alongside the suffix-based one.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
peptiderepo
2026-04-18 10:20:32 +07:00
parent 58cb4ed508
commit 2c2a2acc7d

View File

@@ -114,8 +114,8 @@ 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 ) ) {
// OpenRouter free models: the `openrouter/free` router and any `:free` suffix model.
if ( 'openrouter/free' === $model || ':free' === substr( $model, -5 ) ) {
return 0.0;
}