Skip to content

Commit 963de9d

Browse files
committed
Make sure not to show prices for free models
1 parent 634b1df commit 963de9d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

packages/types/src/model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ export const modelInfoSchema = z.object({
7777
cachableFields: z.array(z.string()).optional(),
7878
// Flag to indicate if the model is deprecated and should not be used
7979
deprecated: z.boolean().optional(),
80+
// Flag to indicate if the model is free (no cost)
81+
isFree: z.boolean().optional(),
8082
/**
8183
* Service tiers with pricing information.
8284
* Each tier can have a name (for OpenAI service tiers) and pricing overrides.

src/api/providers/fetchers/roo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export async function getRooModels(baseUrl: string, apiKey?: string): Promise<Mo
8888
cacheReadsPrice: cacheReadPrice,
8989
description: model.description || model.name,
9090
deprecated: model.deprecated || false,
91+
isFree: tags.includes("free"),
9192
}
9293
}
9394

src/api/providers/roo.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,17 @@ export class RooHandler extends BaseOpenAiCompatibleProvider<string> {
117117
}
118118

119119
if (lastUsage) {
120+
// Check if the current model is marked as free
121+
const model = this.getModel()
122+
const isFreeModel = model.info.isFree ?? false
123+
120124
yield {
121125
type: "usage",
122126
inputTokens: lastUsage.prompt_tokens || 0,
123127
outputTokens: lastUsage.completion_tokens || 0,
124128
cacheWriteTokens: lastUsage.cache_creation_input_tokens,
125129
cacheReadTokens: lastUsage.prompt_tokens_details?.cached_tokens,
126-
totalCost: lastUsage.cost ?? 0,
130+
totalCost: isFreeModel ? 0 : (lastUsage.cost ?? 0),
127131
}
128132
}
129133
}

0 commit comments

Comments
 (0)