Skip to content

Commit 63c77db

Browse files
committed
fix: remove duplicate charging of imageDescriptionCost
1 parent 19e5a61 commit 63c77db

1 file changed

Lines changed: 1 addition & 18 deletions

File tree

  • apps/chat/src/app/api/chatbots/[chatbotId]/chat

apps/chat/src/app/api/chatbots/[chatbotId]/chat/route.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -915,30 +915,13 @@ export async function POST(
915915
})
916916
imageDescription = descriptionResult.text
917917

918-
// deduct credits for image description generation
918+
// compute image description cost; billed via creditsUsed at finish/abort
919919
if (descriptionResult.usage) {
920920
imageDescriptionCost = calcCost(
921921
selectedModelConfig.cost,
922922
descriptionResult.usage.inputTokens || 0,
923923
descriptionResult.usage.outputTokens || 0
924924
)
925-
if (imageDescriptionCost > 0) {
926-
try {
927-
await CreditsService.decrementCredits(
928-
participantId,
929-
chatbotId,
930-
imageDescriptionCost
931-
)
932-
} catch (creditsError) {
933-
console.error(
934-
'Failed to decrement credits for image description:',
935-
{
936-
requestId,
937-
error: creditsError,
938-
}
939-
)
940-
}
941-
}
942925
}
943926
} catch (error) {
944927
console.error('Failed to generate image description:', {

0 commit comments

Comments
 (0)