From 53dd277cfe24ed0b36c5e0fd18aab578a9a51a5f Mon Sep 17 00:00:00 2001 From: Waleed Date: Thu, 4 Sep 2025 21:12:15 -0700 Subject: [PATCH] fix(cost): restored cost reporting for agent block in console entry (#1253) --- apps/sim/providers/index.ts | 2 +- apps/sim/providers/utils.ts | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/apps/sim/providers/index.ts b/apps/sim/providers/index.ts index 7ad55af35d..a464ff91dc 100644 --- a/apps/sim/providers/index.ts +++ b/apps/sim/providers/index.ts @@ -86,7 +86,7 @@ export async function executeProviderRequest( const { prompt: promptTokens = 0, completion: completionTokens = 0 } = response.tokens const useCachedInput = !!request.context && request.context.length > 0 - if (shouldBillModelUsage(response.model, request.apiKey)) { + if (shouldBillModelUsage(response.model)) { response.cost = calculateCost(response.model, promptTokens, completionTokens, useCachedInput) } else { response.cost = { diff --git a/apps/sim/providers/utils.ts b/apps/sim/providers/utils.ts index 78b5115198..b3d5bdee72 100644 --- a/apps/sim/providers/utils.ts +++ b/apps/sim/providers/utils.ts @@ -548,20 +548,11 @@ export function getHostedModels(): string[] { * Determine if model usage should be billed to the user * * @param model The model name - * @param userProvidedApiKey Whether the user provided their own API key * @returns true if the usage should be billed to the user */ -export function shouldBillModelUsage(model: string, userProvidedApiKey?: string): boolean { +export function shouldBillModelUsage(model: string): boolean { const hostedModels = getHostedModels() - if (!hostedModels.includes(model)) { - return false - } - - if (userProvidedApiKey && userProvidedApiKey.trim() !== '') { - return false - } - - return true + return hostedModels.includes(model) } /**