Skip to content

Commit 53dd277

Browse files
authored
fix(cost): restored cost reporting for agent block in console entry (#1253)
1 parent 0e8e8c7 commit 53dd277

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

apps/sim/providers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export async function executeProviderRequest(
8686
const { prompt: promptTokens = 0, completion: completionTokens = 0 } = response.tokens
8787
const useCachedInput = !!request.context && request.context.length > 0
8888

89-
if (shouldBillModelUsage(response.model, request.apiKey)) {
89+
if (shouldBillModelUsage(response.model)) {
9090
response.cost = calculateCost(response.model, promptTokens, completionTokens, useCachedInput)
9191
} else {
9292
response.cost = {

apps/sim/providers/utils.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -548,20 +548,11 @@ export function getHostedModels(): string[] {
548548
* Determine if model usage should be billed to the user
549549
*
550550
* @param model The model name
551-
* @param userProvidedApiKey Whether the user provided their own API key
552551
* @returns true if the usage should be billed to the user
553552
*/
554-
export function shouldBillModelUsage(model: string, userProvidedApiKey?: string): boolean {
553+
export function shouldBillModelUsage(model: string): boolean {
555554
const hostedModels = getHostedModels()
556-
if (!hostedModels.includes(model)) {
557-
return false
558-
}
559-
560-
if (userProvidedApiKey && userProvidedApiKey.trim() !== '') {
561-
return false
562-
}
563-
564-
return true
555+
return hostedModels.includes(model)
565556
}
566557

567558
/**

0 commit comments

Comments
 (0)