diff --git a/packages/types/src/model.ts b/packages/types/src/model.ts index 8d67d3977f0..a97519af1f1 100644 --- a/packages/types/src/model.ts +++ b/packages/types/src/model.ts @@ -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. diff --git a/src/api/providers/fetchers/roo.ts b/src/api/providers/fetchers/roo.ts index d7b212c3e87..1238f86b9a3 100644 --- a/src/api/providers/fetchers/roo.ts +++ b/src/api/providers/fetchers/roo.ts @@ -88,6 +88,7 @@ export async function getRooModels(baseUrl: string, apiKey?: string): Promise { } 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), } } }