Make sure not to show prices for free models (#8864)

This commit is contained in:
Matt Rubens 2025-10-27 14:58:43 -04:00 committed by GitHub
parent e76ac42455
commit 84cf332f19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View file

@ -77,6 +77,8 @@ export const modelInfoSchema = z.object({
cachableFields: z.array(z.string()).optional(),
// Flag to indicate if the model is deprecated and should not be used
deprecated: z.boolean().optional(),
// Flag to indicate if the model is free (no cost)
isFree: z.boolean().optional(),
/**
* Service tiers with pricing information.
* Each tier can have a name (for OpenAI service tiers) and pricing overrides.

View file

@ -88,6 +88,7 @@ export async function getRooModels(baseUrl: string, apiKey?: string): Promise<Mo
cacheReadsPrice: cacheReadPrice,
description: model.description || model.name,
deprecated: model.deprecated || false,
isFree: tags.includes("free"),
}
}

View file

@ -117,13 +117,17 @@ export class RooHandler extends BaseOpenAiCompatibleProvider<string> {
}
if (lastUsage) {
// Check if the current model is marked as free
const model = this.getModel()
const isFreeModel = model.info.isFree ?? false
yield {
type: "usage",
inputTokens: lastUsage.prompt_tokens || 0,
outputTokens: lastUsage.completion_tokens || 0,
cacheWriteTokens: lastUsage.cache_creation_input_tokens,
cacheReadTokens: lastUsage.prompt_tokens_details?.cached_tokens,
totalCost: lastUsage.cost ?? 0,
totalCost: isFreeModel ? 0 : (lastUsage.cost ?? 0),
}
}
}